Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
735714ed
Commit
735714ed
authored
Jul 06, 2016
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add method GetActiveCell to api builder ApiWorksheet
parent
b8859a32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
296 additions
and
287 deletions
+296
-287
cell/apiBuilder.js
cell/apiBuilder.js
+296
-287
No files found.
cell/apiBuilder.js
View file @
735714ed
...
...
@@ -32,317 +32,326 @@
"
use strict
"
;
(
function
(
window
,
builder
)
{
/**
* @global
* @class
* @name Api
*/
var
Api
=
window
[
"
Asc
"
][
"
spreadsheet_api
"
];
(
function
(
window
,
builder
)
{
/**
* @global
* @class
* @name Api
*/
var
Api
=
window
[
"
Asc
"
][
"
spreadsheet_api
"
];
/**
* Class representing a sheet.
* @constructor
*/
function
ApiWorksheet
(
worksheet
)
{
this
.
worksheet
=
worksheet
;
}
/**
* Class representing a sheet.
* @constructor
*/
function
ApiWorksheet
(
worksheet
,
worksheetView
)
{
this
.
worksheet
=
worksheet
;
this
.
worksheetView
=
worksheetView
;
}
/**
* Class representing a range.
* @constructor
*/
function
ApiRange
(
range
)
{
this
.
range
=
range
;
}
/**
* Class representing a range.
* @constructor
*/
function
ApiRange
(
range
)
{
this
.
range
=
range
;
}
/**
* Class representing a graphical object.
* @constructor
*/
function
ApiDrawing
(
Drawing
)
{
this
.
Drawing
=
Drawing
;
}
/**
* Class representing a graphical object.
* @constructor
*/
function
ApiDrawing
(
Drawing
)
{
this
.
Drawing
=
Drawing
;
}
/**
* This type specifies the types, create charts
* @typedef {("bar" | "barStacked" | "barStackedPercent" | "bar3D" | "barStacked3D" | "barStackedPercent3D" | "barStackedPercent3DPerspective" | "horizontalBar" | "horizontalBarStacked" | "horizontalBarStackedPercent" | "horizontalBar3D" | "horizontalBarStacked3D" | "horizontalBarStackedPercent3D" | "lineNormal" | "lineStacked" | "lineStackedPercent" | "line3D" | "pie" | "pie3D" | "doughnut" | "scatter" | "stock")} ChartType
*/
/**
* This type specifies the types, create charts
* @typedef {("bar" | "barStacked" | "barStackedPercent" | "bar3D" | "barStacked3D" | "barStackedPercent3D" | "barStackedPercent3DPerspective" | "horizontalBar" | "horizontalBarStacked" | "horizontalBarStackedPercent" | "horizontalBar3D" | "horizontalBarStacked3D" | "horizontalBarStackedPercent3D" | "lineNormal" | "lineStacked" | "lineStackedPercent" | "line3D" | "pie" | "pie3D" | "doughnut" | "scatter" | "stock")} ChartType
*/
/**
* Class representing a Chart.
* @constructor
*
*/
function
ApiChart
(
Chart
)
{
ApiChart
.
superclass
.
constructor
.
call
(
this
,
Chart
.
parent
);
this
.
Chart
=
Chart
;
}
AscCommon
.
extendClass
(
ApiChart
,
ApiDrawing
);
/**
* Class representing a Chart.
* @constructor
*
*/
function
ApiChart
(
Chart
)
{
ApiChart
.
superclass
.
constructor
.
call
(
this
,
Chart
.
parent
);
this
.
Chart
=
Chart
;
}
/**
* Returns an object that represents the active sheet
* @memberof Api
* @returns {ApiWorksheet}
*/
Api
.
prototype
.
GetActiveSheet
=
function
()
{
return
new
ApiWorksheet
(
this
.
wbModel
.
getWorksheet
(
this
.
wbModel
.
getActive
()));
};
AscCommon
.
extendClass
(
ApiChart
,
ApiDrawing
);
/**
* Set sheet name
* @memberof ApiWorksheet
* @param {string} name
*/
ApiWorksheet
.
prototype
.
SetName
=
function
(
name
)
{
this
.
worksheet
.
setName
(
name
);
};
/**
* Returns an object that represents the active sheet
* @memberof Api
* @returns {ApiWorksheet}
*/
Api
.
prototype
.
GetActiveSheet
=
function
()
{
var
index
=
this
.
wbModel
.
getActive
();
return
new
ApiWorksheet
(
this
.
wbModel
.
getWorksheet
(
index
),
this
.
wb
.
getWorksheet
(
index
));
};
/**
* Returns an object that represents the range
* @memberof ApiWorksheet
* @param {string} sRange
* @returns {ApiRange}
*/
ApiWorksheet
.
prototype
.
GetRange
=
function
(
sRange
)
{
return
new
ApiRange
(
this
.
worksheet
.
getRange2
(
sRange
));
};
/**
* Returns an object that represents the active cell
* @memberof ApiWorksheet
* @returns {ApiRange}
*/
ApiWorksheet
.
prototype
.
GetActiveCell
=
function
()
{
var
ar
=
this
.
worksheetView
.
activeRange
;
return
new
ApiRange
(
this
.
worksheet
.
getCell3
(
ar
.
startRow
,
ar
.
startCol
));
};
/**
* Format as tabl
e
* @memberof ApiWorksheet
* @param {string} sRang
e
*/
ApiWorksheet
.
prototype
.
FormatAsTable
=
function
(
sRang
e
)
{
this
.
worksheet
.
autoFilters
.
addAutoFilter
(
'
TableStyleLight9
'
,
AscCommonExcel
.
g_oRangeCache
.
getAscRange
(
sRange
)
);
};
/**
* Set sheet nam
e
* @memberof ApiWorksheet
* @param {string} nam
e
*/
ApiWorksheet
.
prototype
.
SetName
=
function
(
nam
e
)
{
this
.
worksheet
.
setName
(
name
);
};
/**
* Set column width
* @memberof ApiWorksheet
* @param {number} column
* @param {number} width
*/
ApiWorksheet
.
prototype
.
SetColumnWidth
=
function
(
column
,
width
)
{
this
.
worksheet
.
setColWidth
(
width
,
column
,
column
);
};
/**
* Returns an object that represents the range
* @memberof ApiWorksheet
* @param {string} sRange
* @returns {ApiRange}
*/
ApiWorksheet
.
prototype
.
GetRange
=
function
(
sRange
)
{
return
new
ApiRange
(
this
.
worksheet
.
getRange2
(
sRange
)
);
};
/**
* Set column width
* @memberof ApiWorksheet
* @param {string} sDataRange
* @param {bool} bInRows
* @param {ChartType} sType
* @param {number} nStyleIndex
* @param {number} nFromCol
* @param {number} nFromRow
* @param {number} nToCol
* @param {number} nToRow
*/
ApiWorksheet
.
prototype
.
AddChart
=
function
(
sDataRange
,
bInRows
,
sType
,
nStyleIndex
,
nFromCol
,
nFromRow
,
nToCol
,
nToRow
)
{
/**
* Format as table
* @memberof ApiWorksheet
* @param {string} sRange
*/
ApiWorksheet
.
prototype
.
FormatAsTable
=
function
(
sRange
)
{
this
.
worksheet
.
autoFilters
.
addAutoFilter
(
'
TableStyleLight9
'
,
AscCommonExcel
.
g_oRangeCache
.
getAscRange
(
sRange
));
};
History
.
Create_NewPoint
();
var
settings
=
new
AscCommon
.
asc_ChartSettings
();
switch
(
sType
)
{
case
"
bar
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barNormal
;
break
;
}
case
"
barStacked
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStacked
;
break
;
}
case
"
barStackedPercent
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStackedPer
;
break
;
}
case
"
bar3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barNormal3d
;
break
;
}
case
"
barStacked3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStacked3d
;
break
;
}
case
"
barStackedPercent3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStackedPer3d
;
break
;
}
case
"
barStackedPercent3DPerspective
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barNormal3dPerspective
;
break
;
}
case
"
horizontalBar
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarNormal
;
break
;
}
case
"
horizontalBarStacked
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStacked
;
break
;
}
case
"
horizontalBarStackedPercent
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStackedPer
;
break
;
}
case
"
horizontalBar3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarNormal3d
;
break
;
}
case
"
horizontalBarStacked3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStacked3d
;
break
;
}
case
"
horizontalBarStackedPercent3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStackedPer3d
;
break
;
}
case
"
lineNormal
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
lineNormal
;
break
;
}
case
"
lineStacked
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
lineStacked
;
break
;
}
case
"
lineStackedPercent
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
lineStackedPer
;
break
;
}
case
"
line3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
line3d
;
break
;
}
case
"
pie
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
pie
;
break
;
}
case
"
pie3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
pie3d
;
break
;
}
case
"
doughnut
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
doughnut
;
break
;
}
case
"
scatter
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
scatter
;
break
;
}
case
"
stock
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
stock
;
break
;
}
}
settings
.
style
=
nStyleIndex
;
settings
.
inColumns
=
!
bInRows
;
settings
.
range
=
sDataRange
;
var
oChart
=
AscFormat
.
DrawingObjectsController
.
prototype
.
getChartSpace
(
this
.
worksheet
,
settings
);
oChart
.
setWorksheet
(
this
.
worksheet
);
oChart
.
setBFromSerialize
(
true
);
oChart
.
addToDrawingObjects
();
oChart
.
setDrawingBaseCoords
(
nFromCol
,
0
,
nFromRow
,
0
,
nToCol
,
0
,
nToRow
,
0
,
0
,
0
,
0
,
0
);
if
(
AscFormat
.
isRealNumber
(
nStyleIndex
))
{
oChart
.
setStyle
(
nStyleIndex
);
}
};
/**
* Set column width
* @memberof ApiWorksheet
* @param {number} column
* @param {number} width
*/
ApiWorksheet
.
prototype
.
SetColumnWidth
=
function
(
column
,
width
)
{
this
.
worksheet
.
setColWidth
(
width
,
column
,
column
);
};
/**
* Set cell value
* @memberof ApiRange
* @param {string} val
*/
ApiRange
.
prototype
.
SetValue
=
function
(
val
)
{
this
.
range
.
setValue
(
val
);
};
/**
* Set column width
* @memberof ApiWorksheet
* @param {string} sDataRange
* @param {bool} bInRows
* @param {ChartType} sType
* @param {number} nStyleIndex
* @param {number} nFromCol
* @param {number} nFromRow
* @param {number} nToCol
* @param {number} nToRow
*/
ApiWorksheet
.
prototype
.
AddChart
=
function
(
sDataRange
,
bInRows
,
sType
,
nStyleIndex
,
nFromCol
,
nFromRow
,
nToCol
,
nToRow
)
{
/**
* Set text color in the rgb format.
* @param {byte} r
* @param {byte} g
* @param {byte} b
*/
ApiRange
.
prototype
.
SetFontColor
=
function
(
r
,
g
,
b
)
{
this
.
range
.
setFontcolor
(
new
AscCommonExcel
.
RgbColor
((
r
<<
16
)
+
(
g
<<
8
)
+
b
));
};
History
.
Create_NewPoint
();
var
settings
=
new
AscCommon
.
asc_ChartSettings
();
switch
(
sType
)
{
case
"
bar
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barNormal
;
break
;
}
case
"
barStacked
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStacked
;
break
;
}
case
"
barStackedPercent
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStackedPer
;
break
;
}
case
"
bar3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barNormal3d
;
break
;
}
case
"
barStacked3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStacked3d
;
break
;
}
case
"
barStackedPercent3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barStackedPer3d
;
break
;
}
case
"
barStackedPercent3DPerspective
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
barNormal3dPerspective
;
break
;
}
case
"
horizontalBar
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarNormal
;
break
;
}
case
"
horizontalBarStacked
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStacked
;
break
;
}
case
"
horizontalBarStackedPercent
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStackedPer
;
break
;
}
case
"
horizontalBar3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarNormal3d
;
break
;
}
case
"
horizontalBarStacked3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStacked3d
;
break
;
}
case
"
horizontalBarStackedPercent3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
hBarStackedPer3d
;
break
;
}
case
"
lineNormal
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
lineNormal
;
break
;
}
case
"
lineStacked
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
lineStacked
;
break
;
}
case
"
lineStackedPercent
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
lineStackedPer
;
break
;
}
case
"
line3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
line3d
;
break
;
}
case
"
pie
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
pie
;
break
;
}
case
"
pie3D
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
pie3d
;
break
;
}
case
"
doughnut
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
doughnut
;
break
;
}
case
"
scatter
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
scatter
;
break
;
}
case
"
stock
"
:
{
settings
.
type
=
Asc
.
c_oAscChartTypeSettings
.
stock
;
break
;
}
}
settings
.
style
=
nStyleIndex
;
settings
.
inColumns
=
!
bInRows
;
settings
.
range
=
sDataRange
;
var
oChart
=
AscFormat
.
DrawingObjectsController
.
prototype
.
getChartSpace
(
this
.
worksheet
,
settings
);
oChart
.
setWorksheet
(
this
.
worksheet
);
oChart
.
setBFromSerialize
(
true
);
oChart
.
addToDrawingObjects
();
oChart
.
setDrawingBaseCoords
(
nFromCol
,
0
,
nFromRow
,
0
,
nToCol
,
0
,
nToRow
,
0
,
0
,
0
,
0
,
0
);
if
(
AscFormat
.
isRealNumber
(
nStyleIndex
))
{
oChart
.
setStyle
(
nStyleIndex
);
}
};
/**
* Set font size
* @param {number} size
*/
ApiRange
.
prototype
.
SetFontSize
=
function
(
size
)
{
this
.
range
.
setFontsize
(
size
);
};
/**
* Set cell value
* @memberof ApiRange
* @param {string} val
*/
ApiRange
.
prototype
.
SetValue
=
function
(
val
)
{
this
.
range
.
setValue
(
val
);
};
/**
* Set font name
* @param {string} name
*/
ApiRange
.
prototype
.
SetFontName
=
function
(
name
)
{
this
.
range
.
setFontname
(
name
);
};
/**
* Set text color in the rgb format.
* @param {byte} r
* @param {byte} g
* @param {byte} b
*/
ApiRange
.
prototype
.
SetFontColor
=
function
(
r
,
g
,
b
)
{
this
.
range
.
setFontcolor
(
new
AscCommonExcel
.
RgbColor
((
r
<<
16
)
+
(
g
<<
8
)
+
b
));
};
/**
* Set align vertical
* @param {'center' | 'bottom' | 'top'} valu
e
*/
ApiRange
.
prototype
.
SetAlignVertical
=
function
(
valu
e
)
{
this
.
range
.
setAlignVertical
(
valu
e
);
};
/**
* Set font size
* @param {number} siz
e
*/
ApiRange
.
prototype
.
SetFontSize
=
function
(
siz
e
)
{
this
.
range
.
setFontsize
(
siz
e
);
};
/**
* Set align horizontal
* @param {'left' | 'right' | 'center' | 'justify'} valu
e
*/
ApiRange
.
prototype
.
SetAlignHorizontal
=
function
(
valu
e
)
{
this
.
range
.
setAlignHorizontal
(
valu
e
);
};
/**
* Set font name
* @param {string} nam
e
*/
ApiRange
.
prototype
.
SetFontName
=
function
(
nam
e
)
{
this
.
range
.
setFontname
(
nam
e
);
};
/**
* Set align vertical
* @param {'center' | 'bottom' | 'top'} value
*/
ApiRange
.
prototype
.
SetAlignVertical
=
function
(
value
)
{
this
.
range
.
setAlignVertical
(
value
);
};
/**
* Set align horizontal
* @param {'left' | 'right' | 'center' | 'justify'} value
*/
ApiRange
.
prototype
.
SetAlignHorizontal
=
function
(
value
)
{
this
.
range
.
setAlignHorizontal
(
value
);
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Export
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Api
.
prototype
[
"
GetActiveSheet
"
]
=
Api
.
prototype
.
GetActiveSheet
;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Export
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Api
.
prototype
[
"
GetActiveSheet
"
]
=
Api
.
prototype
.
GetActiveSheet
;
ApiWorksheet
.
prototype
[
"
SetName
"
]
=
ApiWorksheet
.
prototype
.
SetName
;
ApiWorksheet
.
prototype
[
"
GetRange
"
]
=
ApiWorksheet
.
prototype
.
GetRange
;
ApiWorksheet
.
prototype
[
"
FormatAsTable
"
]
=
ApiWorksheet
.
prototype
.
FormatAsTable
;
ApiWorksheet
.
prototype
[
"
SetColumnWidth
"
]
=
ApiWorksheet
.
prototype
.
SetColumnWidth
;
ApiWorksheet
.
prototype
[
"
AddChart
"
]
=
ApiWorksheet
.
prototype
.
AddChart
;
ApiWorksheet
.
prototype
[
"
GetActiveCell
"
]
=
ApiWorksheet
.
prototype
.
GetActiveCell
;
ApiWorksheet
.
prototype
[
"
SetName
"
]
=
ApiWorksheet
.
prototype
.
SetName
;
ApiWorksheet
.
prototype
[
"
GetRange
"
]
=
ApiWorksheet
.
prototype
.
GetRange
;
ApiWorksheet
.
prototype
[
"
FormatAsTable
"
]
=
ApiWorksheet
.
prototype
.
FormatAsTable
;
ApiWorksheet
.
prototype
[
"
SetColumnWidth
"
]
=
ApiWorksheet
.
prototype
.
SetColumnWidth
;
ApiWorksheet
.
prototype
[
"
AddChart
"
]
=
ApiWorksheet
.
prototype
.
AddChart
;
ApiRange
.
prototype
[
"
SetValue
"
]
=
ApiRange
.
prototype
.
SetValue
;
ApiRange
.
prototype
[
"
SetFontColor
"
]
=
ApiRange
.
prototype
.
SetFontColor
;
ApiRange
.
prototype
[
"
SetFontSize
"
]
=
ApiRange
.
prototype
.
SetFontSize
;
ApiRange
.
prototype
[
"
SetFontName
"
]
=
ApiRange
.
prototype
.
SetFontName
;
ApiRange
.
prototype
[
"
SetAlignVertical
"
]
=
ApiRange
.
prototype
.
SetAlignVertical
;
ApiRange
.
prototype
[
"
SetAlignHorizontal
"
]
=
ApiRange
.
prototype
.
SetAlignHorizontal
;
ApiRange
.
prototype
[
"
SetValue
"
]
=
ApiRange
.
prototype
.
SetValue
;
ApiRange
.
prototype
[
"
SetFontColor
"
]
=
ApiRange
.
prototype
.
SetFontColor
;
ApiRange
.
prototype
[
"
SetFontSize
"
]
=
ApiRange
.
prototype
.
SetFontSize
;
ApiRange
.
prototype
[
"
SetFontName
"
]
=
ApiRange
.
prototype
.
SetFontName
;
ApiRange
.
prototype
[
"
SetAlignVertical
"
]
=
ApiRange
.
prototype
.
SetAlignVertical
;
ApiRange
.
prototype
[
"
SetAlignHorizontal
"
]
=
ApiRange
.
prototype
.
SetAlignHorizontal
;
}(
window
,
null
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment