aspose.cells.node.samples 25.4.0 → 25.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -38
- package/package.json +2 -2
- package/src/samples.js +708 -708
package/src/samples.js
CHANGED
|
@@ -4,17 +4,17 @@ function sampleStyle() {
|
|
|
4
4
|
|
|
5
5
|
var excel = new Workbook();
|
|
6
6
|
var style = excel.createStyle();
|
|
7
|
-
style.
|
|
8
|
-
style.
|
|
7
|
+
style.font.setName("Times New Roman");
|
|
8
|
+
style.font.setColor(Color.Blue);
|
|
9
9
|
for (var i = 0; i < 100; i++) {
|
|
10
|
-
excel.
|
|
10
|
+
excel.worksheets.get(0).cells.get(0, i).setStyle(style);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
//Second method
|
|
14
|
-
var style1 = excel.
|
|
15
|
-
style1.
|
|
16
|
-
style1.
|
|
17
|
-
excel.
|
|
14
|
+
var style1 = excel.worksheets.get(0).cells.get("A1").getStyle();
|
|
15
|
+
style1.font.setName("Times New Roman");
|
|
16
|
+
style1.font.color = Color.Blue;
|
|
17
|
+
excel.worksheets.get(0).cells.get("A1").setStyle(style1);
|
|
18
18
|
|
|
19
19
|
//First method is a fast and efficient way to change several cell-formatting properties on multiple cells at the same time.
|
|
20
20
|
//If you want to change a single cell's style properties, second method can be used.
|
|
@@ -25,18 +25,18 @@ function sampleChartTitle() {
|
|
|
25
25
|
const { Workbook, Color, ChartType } = require("aspose.cells.node");
|
|
26
26
|
|
|
27
27
|
var excel = new Workbook();
|
|
28
|
-
var charts = excel.
|
|
28
|
+
var charts = excel.worksheets.get(0).charts;
|
|
29
29
|
//Create a chart
|
|
30
30
|
var chart = charts.get(charts.add(ChartType.Column, 1, 1, 10, 10));
|
|
31
31
|
|
|
32
32
|
//Setting the title of a chart
|
|
33
|
-
chart.
|
|
33
|
+
chart.title.text = "Title";
|
|
34
34
|
//Setting the font color of the chart title to blue
|
|
35
|
-
chart.
|
|
35
|
+
chart.title.getFont().color = Color.Blue;
|
|
36
36
|
//Setting the title of category axis of the chart
|
|
37
|
-
chart.
|
|
37
|
+
chart.categoryAxis.title.text = "Category";
|
|
38
38
|
//Setting the title of value axis of the chart
|
|
39
|
-
chart.
|
|
39
|
+
chart.valueAxis.title.text = "Value";
|
|
40
40
|
}
|
|
41
41
|
sampleChartTitle();
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ function sampleTablesListObject() {
|
|
|
44
44
|
const { Workbook, CellsHelper, TotalsCalculation } = require("aspose.cells.node");
|
|
45
45
|
|
|
46
46
|
var workbook = new Workbook();
|
|
47
|
-
var cells = workbook.
|
|
47
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
48
48
|
for (var i = 0; i < 5; i++) {
|
|
49
49
|
cells.get(0, i).putValue(CellsHelper.columnIndexToName(i));
|
|
50
50
|
}
|
|
@@ -53,11 +53,11 @@ function sampleTablesListObject() {
|
|
|
53
53
|
cells.get(row, column).putValue(row * column);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
var tables = workbook.
|
|
56
|
+
var tables = workbook.worksheets.get(0).getListObjects();
|
|
57
57
|
var index = tables.add(0, 0, 9, 4, true);
|
|
58
58
|
var table = tables.get(0);
|
|
59
|
-
table.
|
|
60
|
-
table.
|
|
59
|
+
table.showTotals = true;
|
|
60
|
+
table.listColumns.get(4).totalsCalculation = TotalsCalculation.Sum;
|
|
61
61
|
workbook.save("output/Book1.xlsx");
|
|
62
62
|
}
|
|
63
63
|
sampleTablesListObject();
|
|
@@ -66,13 +66,13 @@ function sampleDrawingFormat() {
|
|
|
66
66
|
const { Workbook, ChartType, Color, GradientStyleType } = require("aspose.cells.node");
|
|
67
67
|
|
|
68
68
|
var excel = new Workbook();
|
|
69
|
-
var charts = excel.
|
|
69
|
+
var charts = excel.worksheets.get(0).charts;
|
|
70
70
|
//Create a chart
|
|
71
71
|
var chart = charts.get(charts.add(ChartType.Column, 1, 1, 10, 10));
|
|
72
|
-
chart.
|
|
72
|
+
chart.nSeries.add("A1:C5", true);
|
|
73
73
|
|
|
74
74
|
//Filling the area of the 2nd NSeries with a gradient
|
|
75
|
-
chart.
|
|
75
|
+
chart.nSeries.get(1).area.fillFormat.setOneColorGradient(Color.Lime, 1, GradientStyleType.Horizontal, 1);
|
|
76
76
|
}
|
|
77
77
|
sampleDrawingFormat();
|
|
78
78
|
|
|
@@ -83,7 +83,7 @@ function samplePropertiesCustomDocumentPropertyCollection() {
|
|
|
83
83
|
var workbook = new Workbook("input/CustomProperties.xlsx");
|
|
84
84
|
|
|
85
85
|
//Retrieve a list of all custom document properties of the Excel file
|
|
86
|
-
var customProperties = workbook.
|
|
86
|
+
var customProperties = workbook.worksheets.customDocumentProperties;
|
|
87
87
|
}
|
|
88
88
|
samplePropertiesCustomDocumentPropertyCollection();
|
|
89
89
|
|
|
@@ -94,7 +94,7 @@ function samplePropertyDocumentPropertyCollection() {
|
|
|
94
94
|
var workbook = new Workbook("input/CustomProperties.xlsx");
|
|
95
95
|
|
|
96
96
|
//Retrieve a list of all custom document properties of the Excel file
|
|
97
|
-
var customProperties = workbook.
|
|
97
|
+
var customProperties = workbook.worksheets.customDocumentProperties;
|
|
98
98
|
|
|
99
99
|
//Accessng a custom document property by using the property index
|
|
100
100
|
var customProperty1 = customProperties.get(3);
|
|
@@ -102,7 +102,7 @@ function samplePropertyDocumentPropertyCollection() {
|
|
|
102
102
|
//Accessng a custom document property by using the property name
|
|
103
103
|
var customProperty2 = customProperties.get("rox_Meta1");
|
|
104
104
|
|
|
105
|
-
console.log("Custom Properties: " + customProperties.
|
|
105
|
+
console.log("Custom Properties: " + customProperties.count);
|
|
106
106
|
}
|
|
107
107
|
samplePropertyDocumentPropertyCollection();
|
|
108
108
|
|
|
@@ -112,12 +112,12 @@ function sampleDrawingPicture() {
|
|
|
112
112
|
//Instantiating a Workbook object
|
|
113
113
|
var workbook = new Workbook();
|
|
114
114
|
//Adding a new worksheet to the Workbook object
|
|
115
|
-
var sheetIndex = workbook.
|
|
115
|
+
var sheetIndex = workbook.worksheets.add();
|
|
116
116
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
117
|
-
var worksheet = workbook.
|
|
117
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
118
118
|
//Adding a picture at the location of a cell whose row and column indices
|
|
119
119
|
//are 5 in the worksheet. It is "F6" cell
|
|
120
|
-
worksheet.
|
|
120
|
+
worksheet.pictures.add(5, 5, "input/image.gif");
|
|
121
121
|
//Saving the Excel file
|
|
122
122
|
workbook.save("output/Book1.xls", SaveFormat.Excel97To2003);
|
|
123
123
|
}
|
|
@@ -130,13 +130,13 @@ function sampleHorizontalPageBreak() {
|
|
|
130
130
|
var workbook = new Workbook();
|
|
131
131
|
|
|
132
132
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
133
|
-
var worksheet = workbook.
|
|
133
|
+
var worksheet = workbook.worksheets.get(0);
|
|
134
134
|
|
|
135
135
|
//Add a page break at cell Y30
|
|
136
|
-
var Index = worksheet.
|
|
136
|
+
var Index = worksheet.horizontalPageBreaks.add("Y30");
|
|
137
137
|
|
|
138
138
|
//get the newly added horizontal page break
|
|
139
|
-
var hPageBreak = worksheet.
|
|
139
|
+
var hPageBreak = worksheet.horizontalPageBreaks.get(Index);
|
|
140
140
|
}
|
|
141
141
|
sampleHorizontalPageBreak();
|
|
142
142
|
|
|
@@ -150,29 +150,29 @@ function sampleChartsFloor() {
|
|
|
150
150
|
//Instantiate the workbook object
|
|
151
151
|
var workbook = new Workbook();
|
|
152
152
|
//Get cells collection
|
|
153
|
-
var cells = workbook.
|
|
153
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
154
154
|
//Put values in cells
|
|
155
155
|
cells.get("A1").putValue(1);
|
|
156
156
|
cells.get("A2").putValue(2);
|
|
157
157
|
cells.get("A3").putValue(3);
|
|
158
158
|
|
|
159
159
|
//get charts colletion
|
|
160
|
-
var charts = workbook.
|
|
160
|
+
var charts = workbook.worksheets.get(0).charts;
|
|
161
161
|
//add a new chart
|
|
162
162
|
var index = charts.add(ChartType.Column3DStacked, 5, 0, 15, 5);
|
|
163
163
|
//get the newly added chart
|
|
164
164
|
var chart = charts.get(index);
|
|
165
165
|
//set charts nseries
|
|
166
|
-
chart.
|
|
166
|
+
chart.nSeries.add("A1:A3", true);
|
|
167
167
|
//Show data labels
|
|
168
|
-
chart.
|
|
168
|
+
chart.nSeries.get(0).dataLabels.showValue = true;
|
|
169
169
|
|
|
170
170
|
//Get chart's floor
|
|
171
|
-
var floor = chart.
|
|
171
|
+
var floor = chart.floor;
|
|
172
172
|
//set floor's border as red
|
|
173
|
-
floor.
|
|
173
|
+
floor.border.color = new Color("red");
|
|
174
174
|
//set fill format
|
|
175
|
-
floor.
|
|
175
|
+
floor.fillFormat.setPresetColorGradient(GradientPresetType.CalmWater, GradientStyleType.DiagonalDown, 2);
|
|
176
176
|
|
|
177
177
|
//save the file
|
|
178
178
|
workbook.save("output/ChartsFloor.xls");
|
|
@@ -185,35 +185,35 @@ function sampleDrawingArea() {
|
|
|
185
185
|
//Instantiating a Workbook object
|
|
186
186
|
var workbook = new Workbook();
|
|
187
187
|
//Adding a new worksheet to the Workbook object
|
|
188
|
-
var sheetIndex = workbook.
|
|
188
|
+
var sheetIndex = workbook.worksheets.add();
|
|
189
189
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
190
|
-
var worksheet = workbook.
|
|
190
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
191
191
|
//Adding a sample value to "A1" cell
|
|
192
|
-
worksheet.
|
|
192
|
+
worksheet.cells.get("A1").putValue(50);
|
|
193
193
|
//Adding a sample value to "A2" cell
|
|
194
|
-
worksheet.
|
|
194
|
+
worksheet.cells.get("A2").putValue(100);
|
|
195
195
|
//Adding a sample value to "A3" cell
|
|
196
|
-
worksheet.
|
|
196
|
+
worksheet.cells.get("A3").putValue(150);
|
|
197
197
|
//Adding a sample value to "B1" cell
|
|
198
|
-
worksheet.
|
|
198
|
+
worksheet.cells.get("B1").putValue(60);
|
|
199
199
|
//Adding a sample value to "B2" cell
|
|
200
|
-
worksheet.
|
|
200
|
+
worksheet.cells.get("B2").putValue(32);
|
|
201
201
|
//Adding a sample value to "B3" cell
|
|
202
|
-
worksheet.
|
|
202
|
+
worksheet.cells.get("B3").putValue(50);
|
|
203
203
|
//Adding a chart to the worksheet
|
|
204
|
-
var chartIndex = worksheet.
|
|
204
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
205
205
|
//Accessing the instance of the newly added chart
|
|
206
|
-
var chart = worksheet.
|
|
206
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
207
207
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
208
|
-
chart.
|
|
208
|
+
chart.nSeries.add("A1:B3", true);
|
|
209
209
|
//Setting the foreground color of the plot area
|
|
210
|
-
chart.
|
|
210
|
+
chart.plotArea.getArea().foregroundColor = Color.Blue;
|
|
211
211
|
//Setting the foreground color of the chart area
|
|
212
|
-
chart.
|
|
212
|
+
chart.chartArea.getArea().foregroundColor = Color.Yellow;
|
|
213
213
|
//Setting the foreground color of the 1st NSeries area
|
|
214
|
-
chart.
|
|
214
|
+
chart.nSeries.get(0).area.foregroundColor = Color.Red;
|
|
215
215
|
//Setting the foreground color of the area of the 1st NSeries point
|
|
216
|
-
chart.
|
|
216
|
+
chart.nSeries.get(0).points.get(0).area.foregroundColor = Color.Cyan;
|
|
217
217
|
//Saving the Excel file
|
|
218
218
|
workbook.save("output/DrawingArea.xls");
|
|
219
219
|
}
|
|
@@ -225,27 +225,27 @@ function sampleDrawingAreaInverseIfNegative() {
|
|
|
225
225
|
//Instantiating a Workbook object
|
|
226
226
|
var workbook = new Workbook();
|
|
227
227
|
//Adding a new worksheet to the Workbook object
|
|
228
|
-
var sheetIndex = workbook.
|
|
228
|
+
var sheetIndex = workbook.worksheets.add();
|
|
229
229
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
230
|
-
var worksheet = workbook.
|
|
230
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
231
231
|
//Adding a sample value to "A1" cell
|
|
232
|
-
worksheet.
|
|
232
|
+
worksheet.cells.get("A1").putValue(50);
|
|
233
233
|
//Adding a sample value to "A2" cell
|
|
234
|
-
worksheet.
|
|
234
|
+
worksheet.cells.get("A2").putValue(-100);
|
|
235
235
|
//Adding a sample value to "A3" cell
|
|
236
|
-
worksheet.
|
|
236
|
+
worksheet.cells.get("A3").putValue(150);
|
|
237
237
|
//Adding a chart to the worksheet
|
|
238
|
-
var chartIndex = worksheet.
|
|
238
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
239
239
|
//Accessing the instance of the newly added chart
|
|
240
|
-
var chart = worksheet.
|
|
240
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
241
241
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "A3"
|
|
242
|
-
chart.
|
|
243
|
-
chart.
|
|
242
|
+
chart.nSeries.add("A1:A3", true);
|
|
243
|
+
chart.nSeries.get(0).area.invertIfNegative = true;
|
|
244
244
|
//Setting the foreground color of the 1st NSeries area
|
|
245
|
-
chart.
|
|
245
|
+
chart.nSeries.get(0).area.foregroundColor = Color.Red;
|
|
246
246
|
//Setting the background color of the 1st NSeries area.
|
|
247
247
|
//The displayed area color of second chart point will be the background color.
|
|
248
|
-
chart.
|
|
248
|
+
chart.nSeries.get(0).area.backgroundColor = Color.Yellow;
|
|
249
249
|
//Saving the Excel file
|
|
250
250
|
workbook.save("output/DrawingAreaInverseIfNegative.xls");
|
|
251
251
|
}
|
|
@@ -258,9 +258,9 @@ function sampleExternlink() {
|
|
|
258
258
|
var workbook = new Workbook("input/Externlink.xls");
|
|
259
259
|
|
|
260
260
|
//Get External Link
|
|
261
|
-
var externalLink = workbook.
|
|
261
|
+
var externalLink = workbook.worksheets.externalLinks.get(0);
|
|
262
262
|
//Change External Link's Data Source
|
|
263
|
-
externalLink.
|
|
263
|
+
externalLink.dataSource = "input/Book1.xls";
|
|
264
264
|
}
|
|
265
265
|
sampleExternlink();
|
|
266
266
|
|
|
@@ -268,18 +268,18 @@ function sampleComment() {
|
|
|
268
268
|
const { Workbook } = require("aspose.cells.node");
|
|
269
269
|
|
|
270
270
|
var workbook = new Workbook();
|
|
271
|
-
var comments = workbook.
|
|
271
|
+
var comments = workbook.worksheets.get(0).comments;
|
|
272
272
|
|
|
273
273
|
//Add comment to cell A1
|
|
274
274
|
var commentIndex = comments.add(0, 0);
|
|
275
275
|
var comment = comments.get(commentIndex);
|
|
276
|
-
comment.
|
|
277
|
-
comment.
|
|
276
|
+
comment.note = "First note.";
|
|
277
|
+
comment.font.setName("Times New Roman");
|
|
278
278
|
|
|
279
279
|
//Add comment to cell B2
|
|
280
280
|
comments.add("B2");
|
|
281
281
|
comment = comments.get("B2");
|
|
282
|
-
comment.
|
|
282
|
+
comment.note = "Second note.";
|
|
283
283
|
}
|
|
284
284
|
sampleComment();
|
|
285
285
|
|
|
@@ -288,11 +288,11 @@ function sampleIconSet() {
|
|
|
288
288
|
|
|
289
289
|
//Instantiating a Workbook object
|
|
290
290
|
var workbook = new Workbook();
|
|
291
|
-
var sheet = workbook.
|
|
291
|
+
var sheet = workbook.worksheets.get(0);
|
|
292
292
|
|
|
293
293
|
//Adds an empty conditional formatting
|
|
294
|
-
var index = sheet.
|
|
295
|
-
var fcs = sheet.
|
|
294
|
+
var index = sheet.conditionalFormattings.add();
|
|
295
|
+
var fcs = sheet.conditionalFormattings.get(index);
|
|
296
296
|
//Sets the conditional format range.
|
|
297
297
|
var ca = new CellArea();
|
|
298
298
|
ca.startRow = 0;
|
|
@@ -307,16 +307,16 @@ function sampleIconSet() {
|
|
|
307
307
|
fcs.addArea(ca);
|
|
308
308
|
var cond = fcs.get(idx);
|
|
309
309
|
//Get Icon Set
|
|
310
|
-
var iconSet = cond.
|
|
310
|
+
var iconSet = cond.iconSet;
|
|
311
311
|
//Set Icon Type
|
|
312
|
-
iconSet.
|
|
312
|
+
iconSet.type = IconSetType.Arrows3;
|
|
313
313
|
|
|
314
314
|
//Put Cell Values
|
|
315
|
-
var cell1 = sheet.
|
|
315
|
+
var cell1 = sheet.cells.get("A1");
|
|
316
316
|
cell1.putValue(10);
|
|
317
|
-
var cell2 = sheet.
|
|
317
|
+
var cell2 = sheet.cells.get("A2");
|
|
318
318
|
cell2.putValue(120);
|
|
319
|
-
var cell3 = sheet.
|
|
319
|
+
var cell3 = sheet.cells.get("A3");
|
|
320
320
|
cell3.putValue(260);
|
|
321
321
|
|
|
322
322
|
//Saving the Excel file
|
|
@@ -328,10 +328,10 @@ function samplePageSetup() {
|
|
|
328
328
|
const { Workbook } = require("aspose.cells.node");
|
|
329
329
|
|
|
330
330
|
var workbook = new Workbook();
|
|
331
|
-
var sheet = workbook.
|
|
332
|
-
sheet.
|
|
333
|
-
sheet.
|
|
334
|
-
sheet.
|
|
331
|
+
var sheet = workbook.worksheets.get(0);
|
|
332
|
+
sheet.pageSetup.printArea = "D1:K13";
|
|
333
|
+
sheet.pageSetup.printTitleRows = "$5:$7";
|
|
334
|
+
sheet.pageSetup.printTitleColumns = "$A:$B";
|
|
335
335
|
}
|
|
336
336
|
samplePageSetup();
|
|
337
337
|
|
|
@@ -342,15 +342,15 @@ function sampleDrawingOleObject() {
|
|
|
342
342
|
//Instantiate a new Workbook.
|
|
343
343
|
var workbook = new Workbook();
|
|
344
344
|
//Get the first worksheet.
|
|
345
|
-
var sheet = workbook.
|
|
345
|
+
var sheet = workbook.worksheets.get(0);
|
|
346
346
|
|
|
347
347
|
//Obtain the picture into the array of bytes from a stream.
|
|
348
348
|
var imgBuf = new Uint8Array(fs.readFileSync("input/example.png"));
|
|
349
349
|
//Add an Ole object into the worksheet with the bytes
|
|
350
|
-
sheet.
|
|
350
|
+
sheet.oleObjects.add(14, 3, 200, 220, imgBuf);
|
|
351
351
|
//Set embedded ole object data from a stream.
|
|
352
352
|
var fileBuf = new Uint8Array(fs.readFileSync("input/Book1.xls"));
|
|
353
|
-
sheet.
|
|
353
|
+
sheet.oleObjects.get(0).objectData = fileBuf;
|
|
354
354
|
//Save the excel file
|
|
355
355
|
workbook.save("output/DrawingOleObject.xls");
|
|
356
356
|
}
|
|
@@ -361,9 +361,9 @@ function sampleTextEffectFormat() {
|
|
|
361
361
|
|
|
362
362
|
//Instantiating a Workbook object
|
|
363
363
|
var workbook = new Workbook();
|
|
364
|
-
var shapes = workbook.
|
|
364
|
+
var shapes = workbook.worksheets.get(0).shapes;
|
|
365
365
|
shapes.addTextEffect(MsoPresetTextEffect.TextEffect1, "Aspose", "Arial", 30, false, false, 0, 0, 0, 0, 100, 200);
|
|
366
|
-
var textEffectFormat = shapes.get(0).
|
|
366
|
+
var textEffectFormat = shapes.get(0).textEffect;
|
|
367
367
|
textEffectFormat.setTextEffect(MsoPresetTextEffect.TextEffect10);
|
|
368
368
|
workbook.save("output/TextEffectFormat.xls");
|
|
369
369
|
}
|
|
@@ -373,7 +373,7 @@ function sampleChartsErrorBar() {
|
|
|
373
373
|
const { Workbook, ChartType, ErrorBarDisplayType, ErrorBarType } = require("aspose.cells.node");
|
|
374
374
|
|
|
375
375
|
var workbook = new Workbook();
|
|
376
|
-
var cells = workbook.
|
|
376
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
377
377
|
cells.get("a1").putValue(2);
|
|
378
378
|
cells.get("a2").putValue(5);
|
|
379
379
|
cells.get("a3").putValue(3);
|
|
@@ -388,16 +388,16 @@ function sampleChartsErrorBar() {
|
|
|
388
388
|
cells.get("C3").putValue("Y1");
|
|
389
389
|
cells.get("C4").putValue("Y2");
|
|
390
390
|
|
|
391
|
-
var chartIndex = workbook.
|
|
392
|
-
var chart = workbook.
|
|
393
|
-
chart.
|
|
394
|
-
chart.
|
|
395
|
-
|
|
396
|
-
for (var i = 0; i < chart.
|
|
397
|
-
var aseries = chart.
|
|
398
|
-
aseries.
|
|
399
|
-
aseries.
|
|
400
|
-
aseries.
|
|
391
|
+
var chartIndex = workbook.worksheets.get(0).charts.add(ChartType.Column, 11, 0, 27, 10);
|
|
392
|
+
var chart = workbook.worksheets.get(0).charts.get(chartIndex);
|
|
393
|
+
chart.nSeries.add("A1:B4", true);
|
|
394
|
+
chart.nSeries.categoryData = "C1:C4";
|
|
395
|
+
|
|
396
|
+
for (var i = 0; i < chart.nSeries.count; i++) {
|
|
397
|
+
var aseries = chart.nSeries.get(i);
|
|
398
|
+
aseries.xErrorBar.displayType = ErrorBarDisplayType.Minus;
|
|
399
|
+
aseries.xErrorBar.type = ErrorBarType.FixedValue;
|
|
400
|
+
aseries.xErrorBar.amount = 5;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
sampleChartsErrorBar();
|
|
@@ -406,7 +406,7 @@ function sampleDrawingLine() {
|
|
|
406
406
|
const { Workbook, ChartType, LineType, ChartMarkerType, WeightType } = require("aspose.cells.node");
|
|
407
407
|
|
|
408
408
|
var workbook = new Workbook();
|
|
409
|
-
var cells = workbook.
|
|
409
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
410
410
|
cells.get("a1").putValue(2);
|
|
411
411
|
cells.get("a2").putValue(5);
|
|
412
412
|
cells.get("a3").putValue(3);
|
|
@@ -415,15 +415,15 @@ function sampleDrawingLine() {
|
|
|
415
415
|
cells.get("b2").putValue(3);
|
|
416
416
|
cells.get("b3").putValue(6);
|
|
417
417
|
cells.get("b4").putValue(7);
|
|
418
|
-
var chartIndex = workbook.
|
|
419
|
-
var chart = workbook.
|
|
420
|
-
chart.
|
|
418
|
+
var chartIndex = workbook.worksheets.get(0).charts.add(ChartType.Column, 11, 0, 27, 10);
|
|
419
|
+
var chart = workbook.worksheets.get(0).charts.get(chartIndex);
|
|
420
|
+
chart.nSeries.add("A1:B4", true);
|
|
421
421
|
//Applying a dotted line style on the lines of an NSeries
|
|
422
|
-
chart.
|
|
422
|
+
chart.nSeries.get(0).border.style = LineType.Dot;
|
|
423
423
|
//Applying a triangular marker style on the data markers of an NSeries
|
|
424
|
-
chart.
|
|
424
|
+
chart.nSeries.get(0).marker.markerStyle = ChartMarkerType.Triangle;
|
|
425
425
|
//Setting the weight of all lines in an NSeries to medium
|
|
426
|
-
chart.
|
|
426
|
+
chart.nSeries.get(0).border.weight = WeightType.MediumLine;
|
|
427
427
|
}
|
|
428
428
|
sampleDrawingLine();
|
|
429
429
|
|
|
@@ -431,7 +431,7 @@ function sampleChartsErrorBarType() {
|
|
|
431
431
|
const { Workbook, ChartType, ErrorBarType } = require("aspose.cells.node");
|
|
432
432
|
|
|
433
433
|
var workbook = new Workbook();
|
|
434
|
-
var cells = workbook.
|
|
434
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
435
435
|
cells.get("a1").putValue(2);
|
|
436
436
|
cells.get("a2").putValue(5);
|
|
437
437
|
cells.get("a3").putValue(3);
|
|
@@ -446,17 +446,17 @@ function sampleChartsErrorBarType() {
|
|
|
446
446
|
cells.get("C3").putValue("Y1");
|
|
447
447
|
cells.get("C4").putValue("Y2");
|
|
448
448
|
|
|
449
|
-
var chartIndex = workbook.
|
|
450
|
-
var chart = workbook.
|
|
451
|
-
chart.
|
|
452
|
-
chart.
|
|
449
|
+
var chartIndex = workbook.worksheets.get(0).charts.add(ChartType.Column, 11, 0, 27, 10);
|
|
450
|
+
var chart = workbook.worksheets.get(0).charts.get(chartIndex);
|
|
451
|
+
chart.nSeries.add("A1:B4", true);
|
|
452
|
+
chart.nSeries.categoryData = "C1:C4";
|
|
453
453
|
|
|
454
|
-
for (var i = 0; i < chart.
|
|
455
|
-
var aseries = chart.
|
|
454
|
+
for (var i = 0; i < chart.nSeries.count; i++) {
|
|
455
|
+
var aseries = chart.nSeries.get(i);
|
|
456
456
|
//Sets custom error bar type
|
|
457
|
-
aseries.
|
|
458
|
-
aseries.
|
|
459
|
-
aseries.
|
|
457
|
+
aseries.xErrorBar.type = ErrorBarType.Custom;
|
|
458
|
+
aseries.xErrorBar.plusValue = "=Sheet1!A1";
|
|
459
|
+
aseries.xErrorBar.minusValue = "=Sheet1!A2";
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
sampleChartsErrorBarType();
|
|
@@ -467,21 +467,21 @@ function sampleDrawingButton() {
|
|
|
467
467
|
//Create a new Workbook.
|
|
468
468
|
var workbook = new Workbook();
|
|
469
469
|
//Get the first worksheet in the workbook.
|
|
470
|
-
var sheet = workbook.
|
|
470
|
+
var sheet = workbook.worksheets.get(0);
|
|
471
471
|
|
|
472
472
|
//Add a new button to the worksheet.
|
|
473
|
-
var button = sheet.
|
|
473
|
+
var button = sheet.shapes.addShape(MsoDrawingType.Button, 2, 0, 2, 0, 28, 80);
|
|
474
474
|
//Set the caption of the button.
|
|
475
|
-
button.
|
|
475
|
+
button.text = "Aspose";
|
|
476
476
|
//Set the Placement Type, the way the
|
|
477
477
|
//button is attached to the cells.
|
|
478
|
-
button.
|
|
478
|
+
button.placement = PlacementType.FreeFloating;
|
|
479
479
|
//Set the font name.
|
|
480
|
-
button.
|
|
480
|
+
button.font.setName("Tahoma");
|
|
481
481
|
//Set the caption string bold.
|
|
482
|
-
button.
|
|
482
|
+
button.font.isBold = true;
|
|
483
483
|
//Set the color to blue.
|
|
484
|
-
button.
|
|
484
|
+
button.font.color = Color.Blue;
|
|
485
485
|
//Set the hyperlink for the button.
|
|
486
486
|
button.addHyperlink("http://www.aspose.com/");
|
|
487
487
|
|
|
@@ -494,11 +494,11 @@ function sampleValidation() {
|
|
|
494
494
|
const { Workbook, ValidationType, CellArea } = require("aspose.cells.node");
|
|
495
495
|
|
|
496
496
|
var workbook = new Workbook();
|
|
497
|
-
var validations = workbook.
|
|
497
|
+
var validations = workbook.worksheets.get(0).validations;
|
|
498
498
|
var area = CellArea.createCellArea(0, 0, 1, 1);
|
|
499
499
|
var validation = validations.get(validations.add(area));
|
|
500
|
-
validation.
|
|
501
|
-
validation.
|
|
500
|
+
validation.type = ValidationType.List;
|
|
501
|
+
validation.formula1 = "a,b,c,d";
|
|
502
502
|
}
|
|
503
503
|
sampleValidation();
|
|
504
504
|
|
|
@@ -508,41 +508,41 @@ function sampleChartsSeriesCollection() {
|
|
|
508
508
|
//Instantiating a Workbook object
|
|
509
509
|
var workbook = new Workbook();
|
|
510
510
|
//Adding a new worksheet to the Excel object
|
|
511
|
-
var sheetIndex = workbook.
|
|
511
|
+
var sheetIndex = workbook.worksheets.add();
|
|
512
512
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
513
|
-
var worksheet = workbook.
|
|
513
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
514
514
|
//Adding a sample value to "A1" cell
|
|
515
|
-
worksheet.
|
|
515
|
+
worksheet.cells.get("A1").putValue(50);
|
|
516
516
|
//Adding a sample value to "A2" cell
|
|
517
|
-
worksheet.
|
|
517
|
+
worksheet.cells.get("A2").putValue(100);
|
|
518
518
|
//Adding a sample value to "A3" cell
|
|
519
|
-
worksheet.
|
|
519
|
+
worksheet.cells.get("A3").putValue(150);
|
|
520
520
|
//Adding a sample value to "A4" cell
|
|
521
|
-
worksheet.
|
|
521
|
+
worksheet.cells.get("A4").putValue(200);
|
|
522
522
|
//Adding a sample value to "B1" cell
|
|
523
|
-
worksheet.
|
|
523
|
+
worksheet.cells.get("B1").putValue(60);
|
|
524
524
|
//Adding a sample value to "B2" cell
|
|
525
|
-
worksheet.
|
|
525
|
+
worksheet.cells.get("B2").putValue(32);
|
|
526
526
|
//Adding a sample value to "B3" cell
|
|
527
|
-
worksheet.
|
|
527
|
+
worksheet.cells.get("B3").putValue(50);
|
|
528
528
|
//Adding a sample value to "B4" cell
|
|
529
|
-
worksheet.
|
|
529
|
+
worksheet.cells.get("B4").putValue(40);
|
|
530
530
|
//Adding a sample value to "C1" cell as category data
|
|
531
|
-
worksheet.
|
|
531
|
+
worksheet.cells.get("C1").putValue("Q1");
|
|
532
532
|
//Adding a sample value to "C2" cell as category data
|
|
533
|
-
worksheet.
|
|
533
|
+
worksheet.cells.get("C2").putValue("Q2");
|
|
534
534
|
//Adding a sample value to "C3" cell as category data
|
|
535
|
-
worksheet.
|
|
535
|
+
worksheet.cells.get("C3").putValue("Y1");
|
|
536
536
|
//Adding a sample value to "C4" cell as category data
|
|
537
|
-
worksheet.
|
|
537
|
+
worksheet.cells.get("C4").putValue("Y2");
|
|
538
538
|
//Adding a chart to the worksheet
|
|
539
|
-
var chartIndex = worksheet.
|
|
539
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
540
540
|
//Accessing the instance of the newly added chart
|
|
541
|
-
var chart = worksheet.
|
|
541
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
542
542
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
|
|
543
|
-
chart.
|
|
543
|
+
chart.nSeries.add("A1:B4", true);
|
|
544
544
|
//Setting the data source for the category data of NSeries
|
|
545
|
-
chart.
|
|
545
|
+
chart.nSeries.categoryData = "C1:C4";
|
|
546
546
|
//Saving the Excel file
|
|
547
547
|
workbook.save("output/ChartsSeriesCollection.xls");
|
|
548
548
|
}
|
|
@@ -554,12 +554,12 @@ function sampleHyperlinkCollection() {
|
|
|
554
554
|
//Instantiating a Workbook object
|
|
555
555
|
var workbook = new Workbook();
|
|
556
556
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
557
|
-
var worksheet = workbook.
|
|
557
|
+
var worksheet = workbook.worksheets.get(0);
|
|
558
558
|
|
|
559
559
|
//Get Hyperlinks Collection
|
|
560
|
-
var hyperlinks = worksheet.
|
|
560
|
+
var hyperlinks = worksheet.hyperlinks;
|
|
561
561
|
//Adding a hyperlink to a URL at "A1" cell
|
|
562
|
-
hyperlinks.add("A1", 1, 1, "
|
|
562
|
+
hyperlinks.add("A1", 1, 1, "https://www.aspose.com");
|
|
563
563
|
|
|
564
564
|
//Saving the Excel file
|
|
565
565
|
workbook.save("output/HyperlinkCollection.xls");
|
|
@@ -570,9 +570,9 @@ function sampleHyperlinkCollectionAddIntIntIntIntString() {
|
|
|
570
570
|
const { Workbook } = require("aspose.cells.node");
|
|
571
571
|
|
|
572
572
|
var excel = new Workbook();
|
|
573
|
-
var worksheet = excel.
|
|
574
|
-
worksheet.
|
|
575
|
-
worksheet.
|
|
573
|
+
var worksheet = excel.worksheets.get(0);
|
|
574
|
+
worksheet.hyperlinks.add("A4", 1, 1, "https://www.aspose.com");
|
|
575
|
+
worksheet.hyperlinks.add("A5", 1, 1, "c:\\book1.xls");
|
|
576
576
|
}
|
|
577
577
|
sampleHyperlinkCollectionAddIntIntIntIntString();
|
|
578
578
|
|
|
@@ -582,11 +582,11 @@ function sampleDataSorter() {
|
|
|
582
582
|
//Instantiate a new Workbook object.
|
|
583
583
|
var workbook = new Workbook("input/DataSorter.xls");
|
|
584
584
|
//Get the workbook datasorter object.
|
|
585
|
-
var sorter = workbook.
|
|
585
|
+
var sorter = workbook.dataSorter;
|
|
586
586
|
//Set the first order for datasorter object.
|
|
587
|
-
sorter.
|
|
587
|
+
sorter.order1 = SortOrder.Descending;
|
|
588
588
|
//Define the first key.
|
|
589
|
-
sorter.
|
|
589
|
+
sorter.key1 = 0;
|
|
590
590
|
//Create a cells area (range).
|
|
591
591
|
var ca = new CellArea();
|
|
592
592
|
//Specify the start row index.
|
|
@@ -598,7 +598,7 @@ function sampleDataSorter() {
|
|
|
598
598
|
//Specify the last column index.
|
|
599
599
|
ca.endColumn = 1;
|
|
600
600
|
//Sort data in the specified data range (A1:B14)
|
|
601
|
-
sorter.sort(workbook.
|
|
601
|
+
sorter.sort(workbook.worksheets.get(0).cells, ca);
|
|
602
602
|
//Save the excel file.
|
|
603
603
|
workbook.save("output/DataSorter.xls");
|
|
604
604
|
}
|
|
@@ -610,23 +610,23 @@ function sampleColumn() {
|
|
|
610
610
|
//Instantiating a Workbook object
|
|
611
611
|
var workbook = new Workbook();
|
|
612
612
|
//Obtaining the reference of the first worksheet
|
|
613
|
-
var worksheet = workbook.
|
|
613
|
+
var worksheet = workbook.worksheets.get(0);
|
|
614
614
|
|
|
615
615
|
//Add new Style to Workbook
|
|
616
616
|
var style = workbook.createStyle();
|
|
617
617
|
//Setting the background color to Blue
|
|
618
|
-
style.
|
|
618
|
+
style.backgroundColor = Color.Blue;
|
|
619
619
|
//Setting the foreground color to Red
|
|
620
|
-
style.
|
|
620
|
+
style.foregroundColor = Color.Red;
|
|
621
621
|
//setting Background Pattern
|
|
622
|
-
style.
|
|
622
|
+
style.pattern = BackgroundType.DiagonalStripe;
|
|
623
623
|
//New Style Flag
|
|
624
624
|
var styleFlag = new StyleFlag();
|
|
625
625
|
//Set All Styles
|
|
626
|
-
styleFlag.
|
|
626
|
+
styleFlag.all = true;
|
|
627
627
|
|
|
628
628
|
//Get first Column
|
|
629
|
-
var column = worksheet.
|
|
629
|
+
var column = worksheet.cells.columns.get(0);
|
|
630
630
|
//Apply Style to first Column
|
|
631
631
|
column.applyStyle(style, styleFlag);
|
|
632
632
|
|
|
@@ -651,13 +651,13 @@ function sampleBorder() {
|
|
|
651
651
|
const { Workbook, BorderType, CellBorderType, Color } = require("aspose.cells.node");
|
|
652
652
|
|
|
653
653
|
var workbook = new Workbook();
|
|
654
|
-
var worksheet = workbook.
|
|
655
|
-
var cell = worksheet.
|
|
654
|
+
var worksheet = workbook.worksheets.get(0);
|
|
655
|
+
var cell = worksheet.cells.get(0, 0);
|
|
656
656
|
var style = workbook.createStyle();
|
|
657
657
|
//Set top border style and color
|
|
658
|
-
var border = style.
|
|
659
|
-
border.
|
|
660
|
-
border.
|
|
658
|
+
var border = style.borders.get(BorderType.TopBorder);
|
|
659
|
+
border.lineStyle = CellBorderType.Medium;
|
|
660
|
+
border.color = Color.Red;
|
|
661
661
|
cell.setStyle(style);
|
|
662
662
|
}
|
|
663
663
|
sampleBorder();
|
|
@@ -667,11 +667,11 @@ function sampleDataBar() {
|
|
|
667
667
|
|
|
668
668
|
//Instantiating a Workbook object
|
|
669
669
|
var workbook = new Workbook();
|
|
670
|
-
var sheet = workbook.
|
|
670
|
+
var sheet = workbook.worksheets.get(0);
|
|
671
671
|
|
|
672
672
|
//Adds an empty conditional formatting
|
|
673
|
-
var index = sheet.
|
|
674
|
-
var fcs = sheet.
|
|
673
|
+
var index = sheet.conditionalFormattings.add();
|
|
674
|
+
var fcs = sheet.conditionalFormattings.get(index);
|
|
675
675
|
|
|
676
676
|
//Sets the conditional format range.
|
|
677
677
|
var ca = new CellArea();
|
|
@@ -687,21 +687,21 @@ function sampleDataBar() {
|
|
|
687
687
|
var cond = fcs.get(idx);
|
|
688
688
|
|
|
689
689
|
//Get Databar
|
|
690
|
-
var dataBar = cond.
|
|
690
|
+
var dataBar = cond.dataBar;
|
|
691
691
|
var orange = Color.Orange;
|
|
692
|
-
dataBar.
|
|
692
|
+
dataBar.color = orange;
|
|
693
693
|
|
|
694
694
|
//Set Databar properties
|
|
695
|
-
dataBar.
|
|
696
|
-
dataBar.
|
|
697
|
-
dataBar.
|
|
695
|
+
dataBar.minCfvo.type = FormatConditionValueType.Percentile;
|
|
696
|
+
dataBar.minCfvo.value = 30;
|
|
697
|
+
dataBar.showValue = false;
|
|
698
698
|
|
|
699
699
|
//Put Cell Values
|
|
700
|
-
var cell1 = sheet.
|
|
700
|
+
var cell1 = sheet.cells.get("A1");
|
|
701
701
|
cell1.putValue(10);
|
|
702
|
-
var cell2 = sheet.
|
|
702
|
+
var cell2 = sheet.cells.get("A2");
|
|
703
703
|
cell2.putValue(120);
|
|
704
|
-
var cell3 = sheet.
|
|
704
|
+
var cell3 = sheet.cells.get("A3");
|
|
705
705
|
cell3.putValue(260);
|
|
706
706
|
|
|
707
707
|
//Saving the Excel file
|
|
@@ -716,8 +716,8 @@ function sampleWorkbook() {
|
|
|
716
716
|
var workbook = new Workbook("input/Book1.xls");
|
|
717
717
|
|
|
718
718
|
//Set scroll bars
|
|
719
|
-
workbook.
|
|
720
|
-
workbook.
|
|
719
|
+
workbook.settings.isHScrollBarVisible = false;
|
|
720
|
+
workbook.settings.isVScrollBarVisible = false;
|
|
721
721
|
|
|
722
722
|
//Replace the placeholder string with new values
|
|
723
723
|
workbook.replace("OldInt", 100);
|
|
@@ -747,8 +747,8 @@ function sampleWorkbookSaveFileFormatType() {
|
|
|
747
747
|
const { Workbook, SaveFormat } = require("aspose.cells.node");
|
|
748
748
|
|
|
749
749
|
var workbook = new Workbook();
|
|
750
|
-
var sheets = workbook.
|
|
751
|
-
var cells = sheets.get(0).
|
|
750
|
+
var sheets = workbook.worksheets;
|
|
751
|
+
var cells = sheets.get(0).cells;
|
|
752
752
|
cells.get("A1").putValue("Hello world!");
|
|
753
753
|
workbook.save("output/WorkbookSaveFileFormatType.xls", SaveFormat.Excel97To2003);
|
|
754
754
|
}
|
|
@@ -817,9 +817,9 @@ function sampleWorkbookDefaultStyle() {
|
|
|
817
817
|
const { Workbook } = require("aspose.cells.node");
|
|
818
818
|
|
|
819
819
|
var workbook = new Workbook();
|
|
820
|
-
var defaultStyle = workbook.
|
|
821
|
-
defaultStyle.
|
|
822
|
-
workbook.
|
|
820
|
+
var defaultStyle = workbook.defaultStyle;
|
|
821
|
+
defaultStyle.font.setName("Tahoma");
|
|
822
|
+
workbook.defaultStyle = defaultStyle;
|
|
823
823
|
}
|
|
824
824
|
sampleWorkbookDefaultStyle();
|
|
825
825
|
|
|
@@ -827,8 +827,8 @@ function sampleWorkbookBuildInDocumentProperties() {
|
|
|
827
827
|
const { Workbook } = require("aspose.cells.node");
|
|
828
828
|
|
|
829
829
|
var workbook = new Workbook();
|
|
830
|
-
var doc = workbook.
|
|
831
|
-
doc.
|
|
830
|
+
var doc = workbook.builtInDocumentProperties.get("Author");
|
|
831
|
+
doc.value = "John Smith";
|
|
832
832
|
}
|
|
833
833
|
sampleWorkbookBuildInDocumentProperties();
|
|
834
834
|
|
|
@@ -836,7 +836,7 @@ function sampleWorkbookCustomDocumentProperties() {
|
|
|
836
836
|
const { Workbook } = require("aspose.cells.node");
|
|
837
837
|
|
|
838
838
|
var excel = new Workbook();
|
|
839
|
-
excel.
|
|
839
|
+
excel.customDocumentProperties.add("Checked by", "Jane");
|
|
840
840
|
}
|
|
841
841
|
sampleWorkbookCustomDocumentProperties();
|
|
842
842
|
|
|
@@ -845,14 +845,14 @@ function sampleThemeColor() {
|
|
|
845
845
|
|
|
846
846
|
//Instantiating a Workbook object
|
|
847
847
|
var workbook = new Workbook();
|
|
848
|
-
var cells = workbook.
|
|
848
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
849
849
|
cells.get("A1").putValue("Hello World");
|
|
850
850
|
var style = cells.get("A1").getStyle();
|
|
851
851
|
//Set ThemeColorType.Text2 color type with 40% lighten as the font color.
|
|
852
|
-
style.
|
|
853
|
-
style.
|
|
852
|
+
style.font.themeColor = new ThemeColor(ThemeColorType.Text2, 0.4);
|
|
853
|
+
style.pattern = BackgroundType.Solid;
|
|
854
854
|
//Set ThemeColorType.Background2 color type with 75% darken as the foreground color
|
|
855
|
-
style.
|
|
855
|
+
style.foregroundThemeColor = new ThemeColor(ThemeColorType.Background2, -0.75);
|
|
856
856
|
cells.get("A1").setStyle(style);
|
|
857
857
|
//Saving the Excel file
|
|
858
858
|
workbook.save("output/ThemeColor.xlsx");
|
|
@@ -865,48 +865,48 @@ function sampleDrawingTextBox() {
|
|
|
865
865
|
//Instantiate a new Workbook.
|
|
866
866
|
var workbook = new Workbook();
|
|
867
867
|
//Get the first worksheet in the book.
|
|
868
|
-
var worksheet = workbook.
|
|
868
|
+
var worksheet = workbook.worksheets.get(0);
|
|
869
869
|
//Add a new textbox to the collection.
|
|
870
|
-
var textboxIndex = worksheet.
|
|
870
|
+
var textboxIndex = worksheet.textBoxes.add(2, 1, 160, 200);
|
|
871
871
|
//Get the textbox object.
|
|
872
|
-
var textbox0 = worksheet.
|
|
872
|
+
var textbox0 = worksheet.textBoxes.get(textboxIndex);
|
|
873
873
|
//Fill the text.
|
|
874
|
-
textbox0.
|
|
874
|
+
textbox0.text = "ASPOSE CELLS";
|
|
875
875
|
//Set the textbox to adjust it according to its contents.
|
|
876
|
-
textbox0.
|
|
876
|
+
textbox0.textBody.textAlignment.autoSize = true;
|
|
877
877
|
//Set the placement.
|
|
878
|
-
textbox0.
|
|
878
|
+
textbox0.placement = PlacementType.FreeFloating;
|
|
879
879
|
//Set the font color.
|
|
880
|
-
textbox0.
|
|
880
|
+
textbox0.font.color = Color.Blue;
|
|
881
881
|
//Set the font to bold.
|
|
882
|
-
textbox0.
|
|
882
|
+
textbox0.font.isBold = true;
|
|
883
883
|
//Set the font size.
|
|
884
|
-
textbox0.
|
|
884
|
+
textbox0.font.size = 14;
|
|
885
885
|
//Set font attribute to italic.
|
|
886
|
-
textbox0.
|
|
886
|
+
textbox0.font.isItalic = true;
|
|
887
887
|
//Add a hyperlink to the textbox.
|
|
888
|
-
textbox0.addHyperlink("
|
|
888
|
+
textbox0.addHyperlink("https://www.aspose.com/");
|
|
889
889
|
//Get the filformat of the textbox.
|
|
890
|
-
var fillformat = textbox0.
|
|
890
|
+
var fillformat = textbox0.fill;
|
|
891
891
|
//Set the fillcolor.
|
|
892
|
-
fillformat.
|
|
892
|
+
fillformat.solidFill.color = Color.Silver;
|
|
893
893
|
//Get the lineformat type of the textbox.
|
|
894
|
-
var lineformat = textbox0.
|
|
894
|
+
var lineformat = textbox0.line;
|
|
895
895
|
//Set the line style.
|
|
896
|
-
lineformat.
|
|
896
|
+
lineformat.compoundType = MsoLineStyle.ThinThick;
|
|
897
897
|
//Set the line weight.
|
|
898
|
-
lineformat.
|
|
898
|
+
lineformat.weight = 6;
|
|
899
899
|
//Set the dash style to squaredot.
|
|
900
|
-
lineformat.
|
|
900
|
+
lineformat.dashStyle = MsoLineDashStyle.SquareDot;
|
|
901
901
|
//Add another textbox.
|
|
902
|
-
textboxIndex = worksheet.
|
|
902
|
+
textboxIndex = worksheet.textBoxes.add(15, 4, 85, 120);
|
|
903
903
|
//Get the second textbox.
|
|
904
|
-
var textbox1 = worksheet.
|
|
904
|
+
var textbox1 = worksheet.textBoxes.get(textboxIndex);
|
|
905
905
|
//Input some text to it.
|
|
906
|
-
textbox1.
|
|
906
|
+
textbox1.text = "This is another simple text box";
|
|
907
907
|
//Set the placement type as the textbox will move and
|
|
908
908
|
//resize with cells.
|
|
909
|
-
textbox1.
|
|
909
|
+
textbox1.placement = PlacementType.MoveAndSize;
|
|
910
910
|
//Save the excel file.
|
|
911
911
|
workbook.save("output/DrawingTextBox.xlsx");
|
|
912
912
|
}
|
|
@@ -917,15 +917,15 @@ function sampleTablesTableStyle() {
|
|
|
917
917
|
|
|
918
918
|
var workbook = new Workbook();
|
|
919
919
|
var firstColumnStyle = workbook.createStyle();
|
|
920
|
-
firstColumnStyle.
|
|
921
|
-
firstColumnStyle.
|
|
920
|
+
firstColumnStyle.pattern = BackgroundType.Solid;
|
|
921
|
+
firstColumnStyle.backgroundColor = Color.Red;
|
|
922
922
|
|
|
923
923
|
var lastColumnStyle = workbook.createStyle();
|
|
924
|
-
lastColumnStyle.
|
|
925
|
-
lastColumnStyle.
|
|
926
|
-
lastColumnStyle.
|
|
924
|
+
lastColumnStyle.font.isBold = true;
|
|
925
|
+
lastColumnStyle.pattern = BackgroundType.Solid;
|
|
926
|
+
lastColumnStyle.backgroundColor = Color.Red;
|
|
927
927
|
var tableStyleName = "Custom1";
|
|
928
|
-
var tableStyles = workbook.
|
|
928
|
+
var tableStyles = workbook.worksheets.getTableStyles();
|
|
929
929
|
var index1 = tableStyles.addTableStyle(tableStyleName);
|
|
930
930
|
var tableStyle = tableStyles.get(index1);
|
|
931
931
|
var elements = tableStyle.getTableStyleElements();
|
|
@@ -935,7 +935,7 @@ function sampleTablesTableStyle() {
|
|
|
935
935
|
index1 = elements.add(TableStyleElementType.LastColumn);
|
|
936
936
|
element = elements.get(index1);
|
|
937
937
|
element.setElementStyle(lastColumnStyle);
|
|
938
|
-
var cells = workbook.
|
|
938
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
939
939
|
for (var i = 0; i < 5; i++) {
|
|
940
940
|
cells.get(0, i).putValue(CellsHelper.columnIndexToName(i));
|
|
941
941
|
}
|
|
@@ -944,12 +944,12 @@ function sampleTablesTableStyle() {
|
|
|
944
944
|
cells.get(row, column).putValue(row * column);
|
|
945
945
|
}
|
|
946
946
|
}
|
|
947
|
-
var tables = workbook.
|
|
947
|
+
var tables = workbook.worksheets.get(0).getListObjects();
|
|
948
948
|
var index = tables.add(0, 0, 9, 4, true);
|
|
949
949
|
var table = tables.get(0);
|
|
950
|
-
table.
|
|
951
|
-
table.
|
|
952
|
-
table.
|
|
950
|
+
table.showTableStyleFirstColumn = true;
|
|
951
|
+
table.showTableStyleLastColumn = true;
|
|
952
|
+
table.tableStyleName = tableStyleName;
|
|
953
953
|
workbook.save("output/TablesTableStyle.xlsx");
|
|
954
954
|
}
|
|
955
955
|
sampleTablesTableStyle();
|
|
@@ -968,11 +968,11 @@ function sampleHyperlink() {
|
|
|
968
968
|
//Instantiating a Workbook object
|
|
969
969
|
var workbook = new Workbook();
|
|
970
970
|
//Adding a new worksheet to the Workbook object
|
|
971
|
-
workbook.
|
|
971
|
+
workbook.worksheets.add();
|
|
972
972
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
973
|
-
var worksheet = workbook.
|
|
973
|
+
var worksheet = workbook.worksheets.get(0);
|
|
974
974
|
//Adding a hyperlink to a URL at "A1" cell
|
|
975
|
-
worksheet.
|
|
975
|
+
worksheet.hyperlinks.add("A1", 1, 1, "https://www.aspose.com");
|
|
976
976
|
//Saving the Excel file
|
|
977
977
|
workbook.save("output/Hyperlink.xls");
|
|
978
978
|
}
|
|
@@ -984,46 +984,46 @@ function sampleChartsDisplayUnitLabel() {
|
|
|
984
984
|
//Instantiating a Workbook object
|
|
985
985
|
var workbook = new Workbook();
|
|
986
986
|
//Adding a new worksheet to the Excel object
|
|
987
|
-
var sheetIndex = workbook.
|
|
987
|
+
var sheetIndex = workbook.worksheets.add();
|
|
988
988
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
989
|
-
var worksheet = workbook.
|
|
989
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
990
990
|
//Adding a sample value to "A1" cell
|
|
991
|
-
worksheet.
|
|
991
|
+
worksheet.cells.get("A1").putValue(50);
|
|
992
992
|
//Adding a sample value to "A2" cell
|
|
993
|
-
worksheet.
|
|
993
|
+
worksheet.cells.get("A2").putValue(100);
|
|
994
994
|
//Adding a sample value to "A3" cell
|
|
995
|
-
worksheet.
|
|
995
|
+
worksheet.cells.get("A3").putValue(150);
|
|
996
996
|
//Adding a sample value to "A4" cell
|
|
997
|
-
worksheet.
|
|
997
|
+
worksheet.cells.get("A4").putValue(200);
|
|
998
998
|
//Adding a sample value to "B1" cell
|
|
999
|
-
worksheet.
|
|
999
|
+
worksheet.cells.get("B1").putValue(60);
|
|
1000
1000
|
//Adding a sample value to "B2" cell
|
|
1001
|
-
worksheet.
|
|
1001
|
+
worksheet.cells.get("B2").putValue(32);
|
|
1002
1002
|
//Adding a sample value to "B3" cell
|
|
1003
|
-
worksheet.
|
|
1003
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1004
1004
|
//Adding a sample value to "B4" cell
|
|
1005
|
-
worksheet.
|
|
1005
|
+
worksheet.cells.get("B4").putValue(40);
|
|
1006
1006
|
//Adding a sample value to "C1" cell as category data
|
|
1007
|
-
worksheet.
|
|
1007
|
+
worksheet.cells.get("C1").putValue("Q1");
|
|
1008
1008
|
//Adding a sample value to "C2" cell as category data
|
|
1009
|
-
worksheet.
|
|
1009
|
+
worksheet.cells.get("C2").putValue("Q2");
|
|
1010
1010
|
//Adding a sample value to "C3" cell as category data
|
|
1011
|
-
worksheet.
|
|
1011
|
+
worksheet.cells.get("C3").putValue("Y1");
|
|
1012
1012
|
//Adding a sample value to "C4" cell as category data
|
|
1013
|
-
worksheet.
|
|
1013
|
+
worksheet.cells.get("C4").putValue("Y2");
|
|
1014
1014
|
//Adding a chart to the worksheet
|
|
1015
|
-
var chartIndex = worksheet.
|
|
1015
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
1016
1016
|
//Accessing the instance of the newly added chart
|
|
1017
|
-
var chart = worksheet.
|
|
1017
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1018
1018
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
|
|
1019
|
-
chart.
|
|
1019
|
+
chart.nSeries.add("A1:B4", true);
|
|
1020
1020
|
//Setting the data source for the category data of NSeries
|
|
1021
|
-
chart.
|
|
1021
|
+
chart.nSeries.categoryData = "C1:C4";
|
|
1022
1022
|
//Setting the display unit of value(Y) axis.
|
|
1023
|
-
chart.
|
|
1024
|
-
var displayUnitLabel = chart.
|
|
1023
|
+
chart.valueAxis.sisplayUnit = DisplayUnitType.Hundreds;
|
|
1024
|
+
var displayUnitLabel = chart.valueAxis.displayUnitLabel;
|
|
1025
1025
|
//Setting the custom display unit label
|
|
1026
|
-
displayUnitLabel.
|
|
1026
|
+
displayUnitLabel.text = "100";
|
|
1027
1027
|
//Saving the Excel file
|
|
1028
1028
|
workbook.save("output/ChartsDisplayUnitLabel.xls");
|
|
1029
1029
|
}
|
|
@@ -1034,7 +1034,7 @@ function sampleWorkbookSettingShowTabs() {
|
|
|
1034
1034
|
|
|
1035
1035
|
var workbook = new Workbook();
|
|
1036
1036
|
// Hide the spreadsheet tabs.
|
|
1037
|
-
workbook.
|
|
1037
|
+
workbook.settings.showTabs = false;
|
|
1038
1038
|
}
|
|
1039
1039
|
sampleWorkbookSettingShowTabs();
|
|
1040
1040
|
|
|
@@ -1043,7 +1043,7 @@ function sampleWorkbookSettingIsHScrollBarVisible() {
|
|
|
1043
1043
|
|
|
1044
1044
|
var workbook = new Workbook();
|
|
1045
1045
|
// Hide the horizontal scroll bar of the Excel file.
|
|
1046
|
-
workbook.
|
|
1046
|
+
workbook.settings.isHScrollBarVisible = false;
|
|
1047
1047
|
}
|
|
1048
1048
|
sampleWorkbookSettingIsHScrollBarVisible();
|
|
1049
1049
|
|
|
@@ -1052,7 +1052,7 @@ function sampleWorkbookSettingIsVScrollBarVisible() {
|
|
|
1052
1052
|
|
|
1053
1053
|
var workbook = new Workbook();
|
|
1054
1054
|
// Hide the vertical scroll bar of the Excel file.
|
|
1055
|
-
workbook.
|
|
1055
|
+
workbook.settings.isVScrollBarVisible = false;
|
|
1056
1056
|
}
|
|
1057
1057
|
sampleWorkbookSettingIsVScrollBarVisible();
|
|
1058
1058
|
|
|
@@ -1060,12 +1060,12 @@ function sampleProtection() {
|
|
|
1060
1060
|
const { Workbook } = require("aspose.cells.node");
|
|
1061
1061
|
|
|
1062
1062
|
var workbook = new Workbook();
|
|
1063
|
-
var sheetIndex = workbook.
|
|
1064
|
-
var worksheet = workbook.
|
|
1063
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1064
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1065
1065
|
//Allowing users to select locked cells of the worksheet
|
|
1066
|
-
worksheet.
|
|
1066
|
+
worksheet.protection.allowSelectingLockedCell = true;
|
|
1067
1067
|
//Allowing users to select unlocked cells of the worksheet
|
|
1068
|
-
worksheet.
|
|
1068
|
+
worksheet.protection.allowSelectingUnlockedCell = true;
|
|
1069
1069
|
}
|
|
1070
1070
|
sampleProtection();
|
|
1071
1071
|
|
|
@@ -1075,14 +1075,14 @@ function sampleDrawingListBox() {
|
|
|
1075
1075
|
//Create a new Workbook.
|
|
1076
1076
|
var workbook = new Workbook();
|
|
1077
1077
|
//Get the first worksheet.
|
|
1078
|
-
var sheet = workbook.
|
|
1078
|
+
var sheet = workbook.worksheets.get(0);
|
|
1079
1079
|
//Get the worksheet cells collection.
|
|
1080
|
-
var cells = sheet.
|
|
1080
|
+
var cells = sheet.cells;
|
|
1081
1081
|
|
|
1082
1082
|
//Input a value.
|
|
1083
1083
|
cells.get("B3").putValue("Choose Dept:");
|
|
1084
1084
|
//Set it bold.
|
|
1085
|
-
cells.get("B3").getStyle().
|
|
1085
|
+
cells.get("B3").getStyle().font.isBold = true;
|
|
1086
1086
|
//Input some values that denote the input range
|
|
1087
1087
|
//for the list box.
|
|
1088
1088
|
cells.get("A2").putValue("Sales");
|
|
@@ -1093,17 +1093,17 @@ function sampleDrawingListBox() {
|
|
|
1093
1093
|
cells.get("A7").putValue("HRA");
|
|
1094
1094
|
|
|
1095
1095
|
//Add a new list box.
|
|
1096
|
-
var listBox = sheet.
|
|
1096
|
+
var listBox = sheet.shapes.addListBox(2, 0, 3, 0, 122, 100);
|
|
1097
1097
|
//Set the placement type.
|
|
1098
|
-
listBox.
|
|
1098
|
+
listBox.placement = PlacementType.FreeFloating;
|
|
1099
1099
|
//Set the linked cell.
|
|
1100
|
-
listBox.
|
|
1100
|
+
listBox.linkedCell = "A1";
|
|
1101
1101
|
//Set the input range.
|
|
1102
|
-
listBox.
|
|
1102
|
+
listBox.inputRange = "A2:A7";
|
|
1103
1103
|
//Set the selection tyle.
|
|
1104
|
-
listBox.
|
|
1104
|
+
listBox.selectionType = SelectionType.Single;
|
|
1105
1105
|
//Set the list box with 3-D shading.
|
|
1106
|
-
listBox.
|
|
1106
|
+
listBox.shadow = true;
|
|
1107
1107
|
|
|
1108
1108
|
//Saves the file.
|
|
1109
1109
|
workbook.save("output/DrawingListBox.xls");
|
|
@@ -1115,9 +1115,9 @@ function sampleChartsLegend() {
|
|
|
1115
1115
|
|
|
1116
1116
|
//Set Legend's width and height
|
|
1117
1117
|
var workbook = new Workbook();
|
|
1118
|
-
var sheetIndex = workbook.
|
|
1119
|
-
var worksheet = workbook.
|
|
1120
|
-
var charts = worksheet.
|
|
1118
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1119
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1120
|
+
var charts = worksheet.charts;
|
|
1121
1121
|
//Create a chart
|
|
1122
1122
|
var chart = charts.get(charts.add(ChartType.Column, 1, 1, 10, 10));
|
|
1123
1123
|
var legend = chart.getLegend();
|
|
@@ -1125,11 +1125,11 @@ function sampleChartsLegend() {
|
|
|
1125
1125
|
//Legend is at right side of chart by default.
|
|
1126
1126
|
//If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
|
|
1127
1127
|
//If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
|
|
1128
|
-
legend.
|
|
1129
|
-
legend.
|
|
1130
|
-
legend.
|
|
1128
|
+
legend.y = 1500;
|
|
1129
|
+
legend.width = 50;
|
|
1130
|
+
legend.height = 50;
|
|
1131
1131
|
//Set legend's position
|
|
1132
|
-
legend.
|
|
1132
|
+
legend.position = LegendPositionType.Left;
|
|
1133
1133
|
}
|
|
1134
1134
|
sampleChartsLegend();
|
|
1135
1135
|
|
|
@@ -1139,36 +1139,36 @@ function sampleChartsChartPoint() {
|
|
|
1139
1139
|
//Instantiating a Workbook object
|
|
1140
1140
|
var workbook = new Workbook();
|
|
1141
1141
|
//Obtaining the reference of the first worksheet
|
|
1142
|
-
var worksheet = workbook.
|
|
1142
|
+
var worksheet = workbook.worksheets.get(0);
|
|
1143
1143
|
|
|
1144
1144
|
//Adding a sample value to "A1" cell
|
|
1145
|
-
worksheet.
|
|
1145
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1146
1146
|
//Adding a sample value to "A2" cell
|
|
1147
|
-
worksheet.
|
|
1147
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1148
1148
|
//Adding a sample value to "A3" cell
|
|
1149
|
-
worksheet.
|
|
1149
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1150
1150
|
//Adding a sample value to "B1" cell
|
|
1151
|
-
worksheet.
|
|
1151
|
+
worksheet.cells.get("B1").putValue(60);
|
|
1152
1152
|
//Adding a sample value to "B2" cell
|
|
1153
|
-
worksheet.
|
|
1153
|
+
worksheet.cells.get("B2").putValue(32);
|
|
1154
1154
|
//Adding a sample value to "B3" cell
|
|
1155
|
-
worksheet.
|
|
1155
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1156
1156
|
|
|
1157
1157
|
//Adding a chart to the worksheet
|
|
1158
|
-
var chartIndex = worksheet.
|
|
1158
|
+
var chartIndex = worksheet.charts.add(ChartType.PieExploded, 5, 0, 25, 10);
|
|
1159
1159
|
//Accessing the instance of the newly added chart
|
|
1160
|
-
var chart = worksheet.
|
|
1160
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1161
1161
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
1162
|
-
chart.
|
|
1162
|
+
chart.nSeries.add("A1:B3", true);
|
|
1163
1163
|
//Show Data Labels
|
|
1164
|
-
chart.
|
|
1165
|
-
for (var i = 0; i < chart.
|
|
1164
|
+
chart.nSeries.get(0).dataLabels.showValue = true;
|
|
1165
|
+
for (var i = 0; i < chart.nSeries.get(0).points.count; i++) {
|
|
1166
1166
|
//Get Data Point
|
|
1167
|
-
var point = chart.
|
|
1167
|
+
var point = chart.nSeries.get(0).points.get(i);
|
|
1168
1168
|
//Set Pir Explosion
|
|
1169
|
-
point.
|
|
1169
|
+
point.explosion = 15;
|
|
1170
1170
|
//Set Border Color
|
|
1171
|
-
point.
|
|
1171
|
+
point.border.color = Color.Red;
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
1174
1174
|
//Saving the Excel file
|
|
@@ -1182,34 +1182,34 @@ function sampleDrawingArcShape() {
|
|
|
1182
1182
|
//Instantiate a new Workbook.
|
|
1183
1183
|
var excelbook = new Workbook();
|
|
1184
1184
|
//Add an arc shape.
|
|
1185
|
-
var arc1 = excelbook.
|
|
1185
|
+
var arc1 = excelbook.worksheets.get(0).shapes.addArc(2, 0, 2, 0, 130, 130);
|
|
1186
1186
|
//Set the placement of the arc.
|
|
1187
|
-
arc1.
|
|
1187
|
+
arc1.placement = PlacementType.FreeFloating;
|
|
1188
1188
|
//Set the fill format.
|
|
1189
|
-
arc1.
|
|
1190
|
-
arc1.
|
|
1189
|
+
arc1.fill.fillType = FillType.Solid;
|
|
1190
|
+
arc1.fill.solidFill.color = Color.Blue;
|
|
1191
1191
|
//Set the line style.
|
|
1192
|
-
arc1.
|
|
1192
|
+
arc1.line.compoundType = MsoLineStyle.Single;
|
|
1193
1193
|
//Set the line weight.
|
|
1194
|
-
arc1.
|
|
1194
|
+
arc1.line.weight = 2;
|
|
1195
1195
|
//Set the color of the arc line.
|
|
1196
|
-
arc1.
|
|
1197
|
-
arc1.
|
|
1196
|
+
arc1.line.fillType = FillType.Solid;
|
|
1197
|
+
arc1.line.solidFill.color = Color.Red;
|
|
1198
1198
|
//Set the dash style of the arc.
|
|
1199
|
-
arc1.
|
|
1199
|
+
arc1.line.dashStyle = MsoLineDashStyle.Solid;
|
|
1200
1200
|
//Add another arc shape.
|
|
1201
|
-
var arc2 = excelbook.
|
|
1201
|
+
var arc2 = excelbook.worksheets.get(0).shapes.addArc(9, 0, 2, 0, 130, 130);
|
|
1202
1202
|
//Set the placement of the arc.
|
|
1203
|
-
arc2.
|
|
1203
|
+
arc2.placement = PlacementType.FreeFloating;
|
|
1204
1204
|
//Set the line style.
|
|
1205
|
-
arc2.
|
|
1205
|
+
arc2.line.compoundType = MsoLineStyle.Single;
|
|
1206
1206
|
//Set the line weight.
|
|
1207
|
-
arc2.
|
|
1207
|
+
arc2.line.weight = 1;
|
|
1208
1208
|
//Set the color of the arc line.
|
|
1209
|
-
arc2.
|
|
1210
|
-
arc2.
|
|
1209
|
+
arc2.line.fillType = FillType.Solid;
|
|
1210
|
+
arc2.line.solidFill.color = Color.Blue;
|
|
1211
1211
|
//Set the dash style of the arc.
|
|
1212
|
-
arc2.
|
|
1212
|
+
arc2.line.dashStyle = MsoLineDashStyle.Solid;
|
|
1213
1213
|
//Save the excel file.
|
|
1214
1214
|
excelbook.save("output/DrawingArcShape.xls");
|
|
1215
1215
|
}
|
|
@@ -1220,9 +1220,9 @@ function sampleFormatConditionCollection() {
|
|
|
1220
1220
|
|
|
1221
1221
|
//Adds an empty conditional formatting
|
|
1222
1222
|
var workbook = new Workbook();
|
|
1223
|
-
var sheet = workbook.
|
|
1224
|
-
var index = sheet.
|
|
1225
|
-
var fcs = sheet.
|
|
1223
|
+
var sheet = workbook.worksheets.get(0);
|
|
1224
|
+
var index = sheet.conditionalFormattings.add();
|
|
1225
|
+
var fcs = sheet.conditionalFormattings.get(index);
|
|
1226
1226
|
//Sets the conditional format range.
|
|
1227
1227
|
var ca = new CellArea();
|
|
1228
1228
|
ca.startRow = 0;
|
|
@@ -1242,7 +1242,7 @@ function sampleFormatConditionCollection() {
|
|
|
1242
1242
|
var conditionIndex2 = fcs.addCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");
|
|
1243
1243
|
//Sets the background color.
|
|
1244
1244
|
var fc = fcs.get(conditionIndex);
|
|
1245
|
-
fc.
|
|
1245
|
+
fc.style.backgroundColor = Color.Red;
|
|
1246
1246
|
//Saving the Excel file
|
|
1247
1247
|
workbook.save("output/FormatConditionCollection.xls");
|
|
1248
1248
|
}
|
|
@@ -1252,7 +1252,7 @@ function sampleCommentCollection() {
|
|
|
1252
1252
|
const { Workbook } = require("aspose.cells.node");
|
|
1253
1253
|
|
|
1254
1254
|
var workbook = new Workbook();
|
|
1255
|
-
var comments = workbook.
|
|
1255
|
+
var comments = workbook.worksheets.get(0).comments;
|
|
1256
1256
|
}
|
|
1257
1257
|
sampleCommentCollection();
|
|
1258
1258
|
|
|
@@ -1262,29 +1262,29 @@ function sampleBorderCollection() {
|
|
|
1262
1262
|
//Instantiating a Workbook object
|
|
1263
1263
|
var workbook = new Workbook();
|
|
1264
1264
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
1265
|
-
var worksheet = workbook.
|
|
1265
|
+
var worksheet = workbook.worksheets.get(0);
|
|
1266
1266
|
//Accessing the "A1" cell from the worksheet
|
|
1267
|
-
var cell = worksheet.
|
|
1267
|
+
var cell = worksheet.cells.get("A1");
|
|
1268
1268
|
//Adding some value to the "A1" cell
|
|
1269
1269
|
cell.putValue("Visit Aspose!");
|
|
1270
1270
|
//Get style object from cell
|
|
1271
1271
|
var style = cell.getStyle();
|
|
1272
1272
|
//Setting the line style of the top border
|
|
1273
|
-
style.
|
|
1273
|
+
style.borders.get(BorderType.TopBorder).lineStyle = CellBorderType.Thick;
|
|
1274
1274
|
//Setting the color of the top border
|
|
1275
|
-
style.
|
|
1275
|
+
style.borders.get(BorderType.TopBorder).color = Color.Black;
|
|
1276
1276
|
//Setting the line style of the bottom border
|
|
1277
|
-
style.
|
|
1277
|
+
style.borders.get(BorderType.BottomBorder).lineStyle = CellBorderType.Thick;
|
|
1278
1278
|
//Setting the color of the bottom border
|
|
1279
|
-
style.
|
|
1279
|
+
style.borders.get(BorderType.BottomBorder).color = Color.Black;
|
|
1280
1280
|
//Setting the line style of the left border
|
|
1281
|
-
style.
|
|
1281
|
+
style.borders.get(BorderType.LeftBorder).lineStyle = CellBorderType.Thick;
|
|
1282
1282
|
//Setting the color of the left border
|
|
1283
|
-
style.
|
|
1283
|
+
style.borders.get(BorderType.LeftBorder).color = Color.Black;
|
|
1284
1284
|
//Setting the line style of the right border
|
|
1285
|
-
style.
|
|
1285
|
+
style.borders.get(BorderType.RightBorder).lineStyle = CellBorderType.Thick;
|
|
1286
1286
|
//Setting the color of the right border
|
|
1287
|
-
style.
|
|
1287
|
+
style.borders.get(BorderType.RightBorder).color = Color.Black;
|
|
1288
1288
|
//Set style object to cell
|
|
1289
1289
|
cell.setStyle(style);
|
|
1290
1290
|
|
|
@@ -1299,37 +1299,37 @@ function sampleChartsAxis() {
|
|
|
1299
1299
|
//Instantiating a Workbook object
|
|
1300
1300
|
var workbook = new Workbook();
|
|
1301
1301
|
//Adding a new worksheet to the Excel object
|
|
1302
|
-
var sheetIndex = workbook.
|
|
1302
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1303
1303
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
1304
|
-
var worksheet = workbook.
|
|
1304
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1305
1305
|
//Adding a sample value to "A1" cell
|
|
1306
|
-
worksheet.
|
|
1306
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1307
1307
|
//Adding a sample value to "A2" cell
|
|
1308
|
-
worksheet.
|
|
1308
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1309
1309
|
//Adding a sample value to "A3" cell
|
|
1310
|
-
worksheet.
|
|
1310
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1311
1311
|
//Adding a sample value to "B1" cell
|
|
1312
|
-
worksheet.
|
|
1312
|
+
worksheet.cells.get("B1").putValue(4);
|
|
1313
1313
|
//Adding a sample value to "B2" cell
|
|
1314
|
-
worksheet.
|
|
1314
|
+
worksheet.cells.get("B2").putValue(20);
|
|
1315
1315
|
//Adding a sample value to "B3" cell
|
|
1316
|
-
worksheet.
|
|
1316
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1317
1317
|
//Adding a chart to the worksheet
|
|
1318
|
-
var chartIndex = worksheet.
|
|
1318
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 25, 5);
|
|
1319
1319
|
//Accessing the instance of the newly added chart
|
|
1320
|
-
var chart = worksheet.
|
|
1320
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1321
1321
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
1322
|
-
chart.
|
|
1322
|
+
chart.nSeries.add("A1:B3", true);
|
|
1323
1323
|
//Set the max value of value axis
|
|
1324
|
-
chart.
|
|
1324
|
+
chart.valueAxis.maxValue = 200;
|
|
1325
1325
|
//Set the min value of value axis
|
|
1326
|
-
chart.
|
|
1326
|
+
chart.valueAxis.minValue = 0;
|
|
1327
1327
|
//Set the major unit
|
|
1328
|
-
chart.
|
|
1328
|
+
chart.valueAxis.majorUnit = 25;
|
|
1329
1329
|
//Category(X) axis crosses at the maxinum value.
|
|
1330
|
-
chart.
|
|
1330
|
+
chart.valueAxis.crossType = CrossType.Maximum;
|
|
1331
1331
|
//Set he number of categories or series between tick-mark labels.
|
|
1332
|
-
chart.
|
|
1332
|
+
chart.categoryAxis.tickLabelSpacing = 2;
|
|
1333
1333
|
//Saving the Excel file
|
|
1334
1334
|
workbook.save("output/ChartsAxis.xlsx");
|
|
1335
1335
|
}
|
|
@@ -1340,29 +1340,29 @@ function sampleChartsAxisMajorUnitScale() {
|
|
|
1340
1340
|
|
|
1341
1341
|
var workbook = new Workbook();
|
|
1342
1342
|
//Adding a new worksheet to the Excel object
|
|
1343
|
-
var sheetIndex = workbook.
|
|
1343
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1344
1344
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
1345
|
-
var worksheet = workbook.
|
|
1345
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1346
1346
|
//Adding a sample value to "A1" cell
|
|
1347
|
-
worksheet.
|
|
1347
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1348
1348
|
//Adding a sample value to "A2" cell
|
|
1349
|
-
worksheet.
|
|
1349
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1350
1350
|
//Adding a sample value to "A3" cell
|
|
1351
|
-
worksheet.
|
|
1351
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1352
1352
|
//Adding a sample value to "B1" cell
|
|
1353
|
-
worksheet.
|
|
1353
|
+
worksheet.cells.get("B1").putValue(4);
|
|
1354
1354
|
//Adding a sample value to "B2" cell
|
|
1355
|
-
worksheet.
|
|
1355
|
+
worksheet.cells.get("B2").putValue(20);
|
|
1356
1356
|
//Adding a sample value to "B3" cell
|
|
1357
|
-
worksheet.
|
|
1357
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1358
1358
|
|
|
1359
1359
|
//Adding a chart to the worksheet
|
|
1360
|
-
var chartIndex = worksheet.
|
|
1360
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 25, 5);
|
|
1361
1361
|
//Accessing the instance of the newly added chart
|
|
1362
|
-
var chart = worksheet.
|
|
1363
|
-
chart.
|
|
1364
|
-
chart.
|
|
1365
|
-
chart.
|
|
1362
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1363
|
+
chart.categoryAxis.categoryType = CategoryType.TimeScale;
|
|
1364
|
+
chart.categoryAxis.majorUnitScale = TimeUnit.Months;
|
|
1365
|
+
chart.categoryAxis.majorUnit = 2;
|
|
1366
1366
|
}
|
|
1367
1367
|
sampleChartsAxisMajorUnitScale();
|
|
1368
1368
|
|
|
@@ -1371,29 +1371,29 @@ function sampleChartsAxisMinorUnitScale() {
|
|
|
1371
1371
|
|
|
1372
1372
|
var workbook = new Workbook();
|
|
1373
1373
|
//Adding a new worksheet to the Excel object
|
|
1374
|
-
var sheetIndex = workbook.
|
|
1374
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1375
1375
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
1376
|
-
var worksheet = workbook.
|
|
1376
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1377
1377
|
//Adding a sample value to "A1" cell
|
|
1378
|
-
worksheet.
|
|
1378
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1379
1379
|
//Adding a sample value to "A2" cell
|
|
1380
|
-
worksheet.
|
|
1380
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1381
1381
|
//Adding a sample value to "A3" cell
|
|
1382
|
-
worksheet.
|
|
1382
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1383
1383
|
//Adding a sample value to "B1" cell
|
|
1384
|
-
worksheet.
|
|
1384
|
+
worksheet.cells.get("B1").putValue(4);
|
|
1385
1385
|
//Adding a sample value to "B2" cell
|
|
1386
|
-
worksheet.
|
|
1386
|
+
worksheet.cells.get("B2").putValue(20);
|
|
1387
1387
|
//Adding a sample value to "B3" cell
|
|
1388
|
-
worksheet.
|
|
1388
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1389
1389
|
|
|
1390
1390
|
//Adding a chart to the worksheet
|
|
1391
|
-
var chartIndex = worksheet.
|
|
1391
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 25, 5);
|
|
1392
1392
|
//Accessing the instance of the newly added chart
|
|
1393
|
-
var chart = worksheet.
|
|
1394
|
-
chart.
|
|
1395
|
-
chart.
|
|
1396
|
-
chart.
|
|
1393
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1394
|
+
chart.categoryAxis.categoryType = CategoryType.TimeScale;
|
|
1395
|
+
chart.categoryAxis.minorUnitScale = TimeUnit.Months;
|
|
1396
|
+
chart.categoryAxis.minorUnit = 2;
|
|
1397
1397
|
}
|
|
1398
1398
|
sampleChartsAxisMinorUnitScale();
|
|
1399
1399
|
|
|
@@ -1402,28 +1402,28 @@ function sampleChartsAxisMajorGridLines() {
|
|
|
1402
1402
|
|
|
1403
1403
|
var workbook = new Workbook();
|
|
1404
1404
|
//Adding a new worksheet to the Excel object
|
|
1405
|
-
var sheetIndex = workbook.
|
|
1405
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1406
1406
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
1407
|
-
var worksheet = workbook.
|
|
1407
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1408
1408
|
//Adding a sample value to "A1" cell
|
|
1409
|
-
worksheet.
|
|
1409
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1410
1410
|
//Adding a sample value to "A2" cell
|
|
1411
|
-
worksheet.
|
|
1411
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1412
1412
|
//Adding a sample value to "A3" cell
|
|
1413
|
-
worksheet.
|
|
1413
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1414
1414
|
//Adding a sample value to "B1" cell
|
|
1415
|
-
worksheet.
|
|
1415
|
+
worksheet.cells.get("B1").putValue(4);
|
|
1416
1416
|
//Adding a sample value to "B2" cell
|
|
1417
|
-
worksheet.
|
|
1417
|
+
worksheet.cells.get("B2").putValue(20);
|
|
1418
1418
|
//Adding a sample value to "B3" cell
|
|
1419
|
-
worksheet.
|
|
1419
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1420
1420
|
|
|
1421
1421
|
//Adding a chart to the worksheet
|
|
1422
|
-
var chartIndex = worksheet.
|
|
1422
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 25, 5);
|
|
1423
1423
|
//Accessing the instance of the newly added chart
|
|
1424
|
-
var chart = worksheet.
|
|
1425
|
-
chart.
|
|
1426
|
-
chart.
|
|
1424
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1425
|
+
chart.valueAxis.majorGridLines.isVisible = false;
|
|
1426
|
+
chart.categoryAxis.majorGridLines.isVisible = true;
|
|
1427
1427
|
}
|
|
1428
1428
|
sampleChartsAxisMajorGridLines();
|
|
1429
1429
|
|
|
@@ -1470,11 +1470,11 @@ function sampleFormatCondition() {
|
|
|
1470
1470
|
|
|
1471
1471
|
//Instantiating a Workbook object
|
|
1472
1472
|
var workbook = new Workbook();
|
|
1473
|
-
var sheet = workbook.
|
|
1473
|
+
var sheet = workbook.worksheets.get(0);
|
|
1474
1474
|
|
|
1475
1475
|
//Adds an empty conditional formatting
|
|
1476
|
-
var index = sheet.
|
|
1477
|
-
var fcs = sheet.
|
|
1476
|
+
var index = sheet.conditionalFormattings.add();
|
|
1477
|
+
var fcs = sheet.conditionalFormattings.get(index);
|
|
1478
1478
|
|
|
1479
1479
|
//Sets the conditional format range.
|
|
1480
1480
|
var ca = new CellArea();
|
|
@@ -1498,7 +1498,7 @@ function sampleFormatCondition() {
|
|
|
1498
1498
|
|
|
1499
1499
|
//Sets the background color.
|
|
1500
1500
|
var fc = fcs.get(conditionIndex);
|
|
1501
|
-
fc.
|
|
1501
|
+
fc.style.backgroundColor = Color.Red;
|
|
1502
1502
|
|
|
1503
1503
|
//Saving the Excel file
|
|
1504
1504
|
workbook.save("output/FormatCondition.xls");
|
|
@@ -1510,36 +1510,36 @@ function sampleChartsDataLabels() {
|
|
|
1510
1510
|
|
|
1511
1511
|
var workbook = new Workbook();
|
|
1512
1512
|
//Adding a new worksheet to the Excel object
|
|
1513
|
-
var sheetIndex = workbook.
|
|
1513
|
+
var sheetIndex = workbook.worksheets.add();
|
|
1514
1514
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
1515
|
-
var worksheet = workbook.
|
|
1515
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
1516
1516
|
//Adding a sample value to "A1" cell
|
|
1517
|
-
worksheet.
|
|
1517
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1518
1518
|
//Adding a sample value to "A2" cell
|
|
1519
|
-
worksheet.
|
|
1519
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1520
1520
|
//Adding a sample value to "A3" cell
|
|
1521
|
-
worksheet.
|
|
1521
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1522
1522
|
//Adding a sample value to "B1" cell
|
|
1523
|
-
worksheet.
|
|
1523
|
+
worksheet.cells.get("B1").putValue(4);
|
|
1524
1524
|
//Adding a sample value to "B2" cell
|
|
1525
|
-
worksheet.
|
|
1525
|
+
worksheet.cells.get("B2").putValue(20);
|
|
1526
1526
|
//Adding a sample value to "B3" cell
|
|
1527
|
-
worksheet.
|
|
1527
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1528
1528
|
|
|
1529
1529
|
//Adding a chart to the worksheet
|
|
1530
|
-
var chartIndex = worksheet.
|
|
1530
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 25, 5);
|
|
1531
1531
|
//Accessing the instance of the newly added chart
|
|
1532
|
-
var chart = worksheet.
|
|
1532
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1533
1533
|
//Set the DataLabels in the chart
|
|
1534
1534
|
var datalabels;
|
|
1535
|
-
for (var i = 0; i < chart.
|
|
1536
|
-
datalabels = chart.
|
|
1535
|
+
for (var i = 0; i < chart.nSeries.count; i++) {
|
|
1536
|
+
datalabels = chart.nSeries.get(i).dataLabels;
|
|
1537
1537
|
//Set the position of DataLabels
|
|
1538
|
-
datalabels.
|
|
1538
|
+
datalabels.position = LabelPositionType.InsideBase;
|
|
1539
1539
|
//Show the category name in the DataLabels
|
|
1540
1540
|
datalabels.setCategoryNameShown(true);
|
|
1541
1541
|
//Show the value in the DataLabels
|
|
1542
|
-
datalabels.
|
|
1542
|
+
datalabels.showValue = true;
|
|
1543
1543
|
//Not show the percentage in the DataLabels
|
|
1544
1544
|
datalabels.setPercentageShown(false);
|
|
1545
1545
|
//Not show the legend key.
|
|
@@ -1552,11 +1552,11 @@ function sampleWorksheet() {
|
|
|
1552
1552
|
const { Workbook } = require("aspose.cells.node");
|
|
1553
1553
|
|
|
1554
1554
|
var workbook = new Workbook();
|
|
1555
|
-
var sheet = workbook.
|
|
1555
|
+
var sheet = workbook.worksheets.get(0);
|
|
1556
1556
|
//Freeze panes at "AS40" with 10 rows and 10 columns
|
|
1557
1557
|
sheet.freezePanes("AS40", 10, 10);
|
|
1558
1558
|
//Add a hyperlink in Cell A1
|
|
1559
|
-
sheet.
|
|
1559
|
+
sheet.hyperlinks.add("A1", 1, 1, "https://www.aspose.com");
|
|
1560
1560
|
}
|
|
1561
1561
|
sampleWorksheet();
|
|
1562
1562
|
|
|
@@ -1566,7 +1566,7 @@ function sampleWorksheetProtectTypeStringString() {
|
|
|
1566
1566
|
//Instantiating a Workbook object
|
|
1567
1567
|
var excel = new Workbook("input/Book1.xls");
|
|
1568
1568
|
//Accessing the first worksheet in the Excel file
|
|
1569
|
-
var worksheet = excel.
|
|
1569
|
+
var worksheet = excel.worksheets.get(0);
|
|
1570
1570
|
//Protecting the worksheet with a password
|
|
1571
1571
|
worksheet.protect(ProtectionType.All, "aspose", null);
|
|
1572
1572
|
//Saving the modified Excel file in default (that is Excel 20003) format
|
|
@@ -1579,8 +1579,8 @@ function sampleHorizontalPageBreakCollection() {
|
|
|
1579
1579
|
|
|
1580
1580
|
var excel = new Workbook();
|
|
1581
1581
|
//Add a pagebreak at G5
|
|
1582
|
-
excel.
|
|
1583
|
-
excel.
|
|
1582
|
+
excel.worksheets.get(0).horizontalPageBreaks.add("G5");
|
|
1583
|
+
excel.worksheets.get(0).verticalPageBreaks.add("G5");
|
|
1584
1584
|
}
|
|
1585
1585
|
sampleHorizontalPageBreakCollection();
|
|
1586
1586
|
|
|
@@ -1588,9 +1588,9 @@ function sampleDrawingCheckbox() {
|
|
|
1588
1588
|
const { Workbook } = require("aspose.cells.node");
|
|
1589
1589
|
|
|
1590
1590
|
var excel = new Workbook();
|
|
1591
|
-
var index = excel.
|
|
1592
|
-
var checkBox = excel.
|
|
1593
|
-
checkBox.
|
|
1591
|
+
var index = excel.worksheets.get(0).checkBoxes.add(15, 15, 20, 100);
|
|
1592
|
+
var checkBox = excel.worksheets.get(0).checkBoxes.get(index);
|
|
1593
|
+
checkBox.text = "Check Box 1";
|
|
1594
1594
|
}
|
|
1595
1595
|
sampleDrawingCheckbox();
|
|
1596
1596
|
|
|
@@ -1598,34 +1598,34 @@ function sampleCell() {
|
|
|
1598
1598
|
const { Workbook, Color, TextAlignmentType } = require("aspose.cells.node");
|
|
1599
1599
|
|
|
1600
1600
|
var excel = new Workbook();
|
|
1601
|
-
var cells = excel.
|
|
1601
|
+
var cells = excel.worksheets.get(0).cells;
|
|
1602
1602
|
|
|
1603
1603
|
//Put a string into a cell
|
|
1604
1604
|
var cell = cells.get(0, 0);
|
|
1605
1605
|
cell.putValue("Hello");
|
|
1606
|
-
var first = cell.
|
|
1606
|
+
var first = cell.stringValue;
|
|
1607
1607
|
//Put an integer into a cell
|
|
1608
1608
|
cell = cells.get("B1");
|
|
1609
1609
|
cell.putValue(12);
|
|
1610
|
-
var second = cell.
|
|
1610
|
+
var second = cell.intValue;
|
|
1611
1611
|
//Put a double into a cell
|
|
1612
1612
|
cell = cells.get(0, 2);
|
|
1613
1613
|
cell.putValue(-1.234);
|
|
1614
|
-
var third = cell.
|
|
1614
|
+
var third = cell.doubleValue;
|
|
1615
1615
|
//Put a formula into a cell
|
|
1616
1616
|
cell = cells.get("D1");
|
|
1617
|
-
cell.
|
|
1617
|
+
cell.formula = "=B1 + C1";
|
|
1618
1618
|
//Put a combined formula: "sum(average(b1,c1), b1)" to cell at b2
|
|
1619
1619
|
cell = cells.get("b2");
|
|
1620
|
-
cell.
|
|
1620
|
+
cell.formula = "=sum(average(b1,c1), b1)";
|
|
1621
1621
|
|
|
1622
1622
|
//Set style of a cell
|
|
1623
1623
|
var style = cell.getStyle();
|
|
1624
1624
|
//Set background color
|
|
1625
|
-
style.
|
|
1625
|
+
style.backgroundColor = Color.Yellow;
|
|
1626
1626
|
//Set format of a cell
|
|
1627
|
-
style.
|
|
1628
|
-
style.
|
|
1627
|
+
style.font.setName("Courier New");
|
|
1628
|
+
style.verticalAlignment = TextAlignmentType.Top;
|
|
1629
1629
|
cell.setStyle(style);
|
|
1630
1630
|
}
|
|
1631
1631
|
sampleCell();
|
|
@@ -1634,23 +1634,23 @@ function sampleCellGetPrecedents() {
|
|
|
1634
1634
|
const { Workbook, CellsHelper } = require("aspose.cells.node");
|
|
1635
1635
|
|
|
1636
1636
|
var workbook = new Workbook();
|
|
1637
|
-
var cells = workbook.
|
|
1638
|
-
cells.get("A1").
|
|
1637
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
1638
|
+
cells.get("A1").formula = "= B1 + SUM(B1:B10)";
|
|
1639
1639
|
var areas = cells.get("A1").getPrecedents();
|
|
1640
|
-
for (var i = 0; i < areas.
|
|
1640
|
+
for (var i = 0; i < areas.count; i++) {
|
|
1641
1641
|
var area = areas.get(i);
|
|
1642
1642
|
var stringBuilder = "";
|
|
1643
|
-
if (area.isExternalLink
|
|
1643
|
+
if (area.isExternalLink) {
|
|
1644
1644
|
stringBuilder += "[";
|
|
1645
|
-
stringBuilder += area.
|
|
1645
|
+
stringBuilder += area.externalFileName;
|
|
1646
1646
|
stringBuilder += "]";
|
|
1647
1647
|
}
|
|
1648
|
-
stringBuilder += area.
|
|
1648
|
+
stringBuilder += area.sheetName;
|
|
1649
1649
|
stringBuilder += "!";
|
|
1650
|
-
stringBuilder += CellsHelper.cellIndexToName(area.
|
|
1651
|
-
if (area.isArea
|
|
1650
|
+
stringBuilder += CellsHelper.cellIndexToName(area.startRow, area.startColumn);
|
|
1651
|
+
if (area.isArea) {
|
|
1652
1652
|
stringBuilder += ":";
|
|
1653
|
-
stringBuilder += CellsHelper.cellIndexToName(area.
|
|
1653
|
+
stringBuilder += CellsHelper.cellIndexToName(area.endRow, area.endColumn);
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
1656
|
workbook.save("output/CellGetPrecedents.xls");
|
|
@@ -1661,9 +1661,9 @@ function sampleCellCharactersIntInt() {
|
|
|
1661
1661
|
const { Workbook, Color } = require("aspose.cells.node");
|
|
1662
1662
|
|
|
1663
1663
|
var excel = new Workbook();
|
|
1664
|
-
excel.
|
|
1665
|
-
excel.
|
|
1666
|
-
excel.
|
|
1664
|
+
excel.worksheets.get(0).cells.get("A1").putValue("Helloworld");
|
|
1665
|
+
excel.worksheets.get(0).cells.get("A1").characters(5, 5).font.isBold = true;
|
|
1666
|
+
excel.worksheets.get(0).cells.get("A1").characters(5, 5).font.color = Color.Blue;
|
|
1667
1667
|
}
|
|
1668
1668
|
sampleCellCharactersIntInt();
|
|
1669
1669
|
|
|
@@ -1671,8 +1671,8 @@ function sampleCellFormula() {
|
|
|
1671
1671
|
const { Workbook } = require("aspose.cells.node");
|
|
1672
1672
|
|
|
1673
1673
|
var excel = new Workbook();
|
|
1674
|
-
var cells = excel.
|
|
1675
|
-
cells.get("B6").
|
|
1674
|
+
var cells = excel.worksheets.get(0).cells;
|
|
1675
|
+
cells.get("B6").formula = "=SUM(B2:B5, E1) + sheet2!A1";
|
|
1676
1676
|
}
|
|
1677
1677
|
sampleCellFormula();
|
|
1678
1678
|
|
|
@@ -1682,17 +1682,17 @@ function sampleDrawingLabel() {
|
|
|
1682
1682
|
//Create a new Workbook.
|
|
1683
1683
|
var workbook = new Workbook();
|
|
1684
1684
|
//Get the first worksheet in the workbook.
|
|
1685
|
-
var sheet = workbook.
|
|
1685
|
+
var sheet = workbook.worksheets.get(0);
|
|
1686
1686
|
//Add a new label to the worksheet.
|
|
1687
|
-
var label = sheet.
|
|
1687
|
+
var label = sheet.shapes.addShape(MsoDrawingType.Label, 2, 0, 2, 0, 60, 120);
|
|
1688
1688
|
//Set the caption of the label.
|
|
1689
|
-
label.
|
|
1689
|
+
label.text = "This is a Label";
|
|
1690
1690
|
//Set the Placement Type, the way the
|
|
1691
1691
|
//label is attached to the cells.
|
|
1692
|
-
label.
|
|
1692
|
+
label.placement = PlacementType.FreeFloating;
|
|
1693
1693
|
//Set the fill color of the label.
|
|
1694
|
-
label.
|
|
1695
|
-
label.
|
|
1694
|
+
label.fill.fillType = FillType.Solid;
|
|
1695
|
+
label.fill.solidFill.color = Color.Yellow;
|
|
1696
1696
|
//Saves the file.
|
|
1697
1697
|
workbook.save("output/DrawingLabel.xls");
|
|
1698
1698
|
}
|
|
@@ -1704,77 +1704,77 @@ function sampleDrawingGroupShape() {
|
|
|
1704
1704
|
//Instantiate a new Workbook.
|
|
1705
1705
|
var excelbook = new Workbook();
|
|
1706
1706
|
//Add a group box to the first worksheet.
|
|
1707
|
-
var box = excelbook.
|
|
1707
|
+
var box = excelbook.worksheets.get(0).shapes.addGroupBox(1, 0, 1, 0, 300, 250);
|
|
1708
1708
|
//Set the caption of the group box.
|
|
1709
|
-
box.
|
|
1710
|
-
box.
|
|
1709
|
+
box.text = "Age Groups";
|
|
1710
|
+
box.placement = PlacementType.FreeFloating;
|
|
1711
1711
|
//Make it 2-D box.
|
|
1712
|
-
box.
|
|
1712
|
+
box.shadow = false;
|
|
1713
1713
|
//Add a radio button.
|
|
1714
|
-
var radio1 = excelbook.
|
|
1714
|
+
var radio1 = excelbook.worksheets.get(0).shapes.addRadioButton(3, 0, 2, 0, 30, 110);
|
|
1715
1715
|
//Set its text string.
|
|
1716
|
-
radio1.
|
|
1716
|
+
radio1.text = "20-29";
|
|
1717
1717
|
//Set A1 cell as a linked cell for the radio button.
|
|
1718
|
-
radio1.
|
|
1718
|
+
radio1.linkedCell = "A1";
|
|
1719
1719
|
//Make the radio button 3-D.
|
|
1720
|
-
radio1.
|
|
1720
|
+
radio1.shadow = true;
|
|
1721
1721
|
//Set the foreground color of the radio button.
|
|
1722
|
-
radio1.
|
|
1723
|
-
radio1.
|
|
1722
|
+
radio1.fill.fillType = FillType.Solid;
|
|
1723
|
+
radio1.fill.solidFill.color = Color.LightGreen;
|
|
1724
1724
|
//Set the line style of the radio button.
|
|
1725
|
-
radio1.
|
|
1725
|
+
radio1.line.compoundType = MsoLineStyle.ThickThin;
|
|
1726
1726
|
//Set the weight of the radio button.
|
|
1727
|
-
radio1.
|
|
1727
|
+
radio1.line.weight = 4;
|
|
1728
1728
|
//Set the line color of the radio button.
|
|
1729
|
-
radio1.
|
|
1730
|
-
radio1.
|
|
1729
|
+
radio1.line.fillType = FillType.Solid;
|
|
1730
|
+
radio1.line.solidFill.color = Color.Blue;
|
|
1731
1731
|
//Set the dash style of the radio button.
|
|
1732
|
-
radio1.
|
|
1732
|
+
radio1.line.dashStyle = MsoLineDashStyle.Solid;
|
|
1733
1733
|
//Add another radio button.
|
|
1734
|
-
var radio2 = excelbook.
|
|
1734
|
+
var radio2 = excelbook.worksheets.get(0).shapes.addRadioButton(6, 0, 2, 0, 30, 110);
|
|
1735
1735
|
//Set its text string.
|
|
1736
|
-
radio2.
|
|
1736
|
+
radio2.text = "30-39";
|
|
1737
1737
|
//Set A1 cell as a linked cell for the radio button.
|
|
1738
|
-
radio2.
|
|
1738
|
+
radio2.linkedCell = "A1";
|
|
1739
1739
|
//Make the radio button 3-D.
|
|
1740
|
-
radio2.
|
|
1740
|
+
radio2.shadow = true;
|
|
1741
1741
|
//Set the foreground color of the radio button.
|
|
1742
|
-
radio2.
|
|
1743
|
-
radio2.
|
|
1742
|
+
radio2.fill.fillType = FillType.Solid;
|
|
1743
|
+
radio2.fill.solidFill.color = Color.LightGreen;
|
|
1744
1744
|
//Set the line style of the radio button.
|
|
1745
|
-
radio2.
|
|
1745
|
+
radio2.line.compoundType = MsoLineStyle.ThickThin;
|
|
1746
1746
|
//Set the weight of the radio button.
|
|
1747
|
-
radio2.
|
|
1747
|
+
radio2.line.weight = 4;
|
|
1748
1748
|
//Set the line color of the radio button.
|
|
1749
|
-
radio2.
|
|
1750
|
-
radio2.
|
|
1749
|
+
radio2.line.fillType = FillType.Solid;
|
|
1750
|
+
radio2.line.solidFill.color = Color.Blue;
|
|
1751
1751
|
//Set the dash style of the radio button.
|
|
1752
|
-
radio2.
|
|
1752
|
+
radio2.line.dashStyle = MsoLineDashStyle.Solid;
|
|
1753
1753
|
//Add another radio button.
|
|
1754
|
-
var radio3 = excelbook.
|
|
1754
|
+
var radio3 = excelbook.worksheets.get(0).shapes.addRadioButton(9, 0, 2, 0, 30, 110);
|
|
1755
1755
|
//Set its text string.
|
|
1756
|
-
radio3.
|
|
1756
|
+
radio3.text = "40-49";
|
|
1757
1757
|
//Set A1 cell as a linked cell for the radio button.
|
|
1758
|
-
radio3.
|
|
1758
|
+
radio3.linkedCell = "A1";
|
|
1759
1759
|
//Make the radio button 3-D.
|
|
1760
|
-
radio3.
|
|
1760
|
+
radio3.shadow = true;
|
|
1761
1761
|
//Set the foreground color of the radio button.
|
|
1762
|
-
radio3.
|
|
1763
|
-
radio3.
|
|
1762
|
+
radio3.fill.fillType = FillType.Solid;
|
|
1763
|
+
radio3.fill.solidFill.color = Color.LightGreen;
|
|
1764
1764
|
//Set the line style of the radio button.
|
|
1765
|
-
radio3.
|
|
1765
|
+
radio3.line.compoundType = MsoLineStyle.ThickThin;
|
|
1766
1766
|
//Set the weight of the radio button.
|
|
1767
|
-
radio3.
|
|
1767
|
+
radio3.line.weight = 4;
|
|
1768
1768
|
//Set the line color of the radio button.
|
|
1769
|
-
radio3.
|
|
1770
|
-
radio3.
|
|
1769
|
+
radio3.line.fillType = FillType.Solid;
|
|
1770
|
+
radio3.line.solidFill.color = Color.Blue;
|
|
1771
1771
|
//Set the dash style of the radio button.
|
|
1772
|
-
radio3.
|
|
1772
|
+
radio3.line.dashStyle = MsoLineDashStyle.Solid;
|
|
1773
1773
|
|
|
1774
1774
|
//Get the shapes.
|
|
1775
1775
|
var shapeobjects = [ box, radio1, radio2, radio3 ];
|
|
1776
1776
|
//Group the shapes.
|
|
1777
|
-
var group = excelbook.
|
|
1777
|
+
var group = excelbook.worksheets.get(0).shapes.group(shapeobjects);
|
|
1778
1778
|
|
|
1779
1779
|
//Save the excel file.
|
|
1780
1780
|
excelbook.save("output/DrawingGroupShape.xls");
|
|
@@ -1785,13 +1785,13 @@ function sampleCells() {
|
|
|
1785
1785
|
const { Workbook } = require("aspose.cells.node");
|
|
1786
1786
|
|
|
1787
1787
|
var excel = new Workbook();
|
|
1788
|
-
var cells = excel.
|
|
1788
|
+
var cells = excel.worksheets.get(0).cells;
|
|
1789
1789
|
//Set default row height
|
|
1790
|
-
cells.
|
|
1790
|
+
cells.standardHeight = 20;
|
|
1791
1791
|
//Set row height
|
|
1792
1792
|
cells.setRowHeight(2, 20.5);
|
|
1793
1793
|
//Set default colum width
|
|
1794
|
-
cells.
|
|
1794
|
+
cells.standardWidth = 15;
|
|
1795
1795
|
//Set column width
|
|
1796
1796
|
cells.setColumnWidth(3, 12.57);
|
|
1797
1797
|
//Merge cells
|
|
@@ -1803,7 +1803,7 @@ function sampleCellsItemIntInt() {
|
|
|
1803
1803
|
const { Workbook } = require("aspose.cells.node");
|
|
1804
1804
|
|
|
1805
1805
|
var excel = new Workbook();
|
|
1806
|
-
var cells = excel.
|
|
1806
|
+
var cells = excel.worksheets.get(0).cells;
|
|
1807
1807
|
var cell = cells.get(0, 0); //Gets the cell at "A1"
|
|
1808
1808
|
}
|
|
1809
1809
|
sampleCellsItemIntInt();
|
|
@@ -1812,7 +1812,7 @@ function sampleCellsItemString() {
|
|
|
1812
1812
|
const { Workbook } = require("aspose.cells.node");
|
|
1813
1813
|
|
|
1814
1814
|
var excel = new Workbook();
|
|
1815
|
-
var cells = excel.
|
|
1815
|
+
var cells = excel.worksheets.get(0).cells;
|
|
1816
1816
|
var cell = cells.get("A1"); //Gets the cell at "A1"
|
|
1817
1817
|
}
|
|
1818
1818
|
sampleCellsItemString();
|
|
@@ -1821,13 +1821,13 @@ function sampleWorksheetCollection() {
|
|
|
1821
1821
|
const { Workbook } = require("aspose.cells.node");
|
|
1822
1822
|
|
|
1823
1823
|
var workbook = new Workbook();
|
|
1824
|
-
var sheets = workbook.
|
|
1824
|
+
var sheets = workbook.worksheets;
|
|
1825
1825
|
//Add a worksheet
|
|
1826
1826
|
sheets.add();
|
|
1827
1827
|
//Change the name of a worksheet
|
|
1828
|
-
sheets.get(0).
|
|
1828
|
+
sheets.get(0).name = "First Sheet";
|
|
1829
1829
|
//Set the active sheet to the second worksheet
|
|
1830
|
-
sheets.
|
|
1830
|
+
sheets.activeSheetIndex = 1;
|
|
1831
1831
|
}
|
|
1832
1832
|
sampleWorksheetCollection();
|
|
1833
1833
|
|
|
@@ -1835,17 +1835,17 @@ function sampleWorksheetCollectionAddSheetType() {
|
|
|
1835
1835
|
const { Workbook, SheetType, ChartType } = require("aspose.cells.node");
|
|
1836
1836
|
|
|
1837
1837
|
var workbook = new Workbook();
|
|
1838
|
-
workbook.
|
|
1839
|
-
var cells = workbook.
|
|
1838
|
+
workbook.worksheets.add(SheetType.Chart);
|
|
1839
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
1840
1840
|
cells.get("c2").putValue(5000);
|
|
1841
1841
|
cells.get("c3").putValue(3000);
|
|
1842
1842
|
cells.get("c4").putValue(4000);
|
|
1843
1843
|
cells.get("c5").putValue(5000);
|
|
1844
1844
|
cells.get("c6").putValue(6000);
|
|
1845
|
-
var charts = workbook.
|
|
1845
|
+
var charts = workbook.worksheets.get(1).charts;
|
|
1846
1846
|
var chartIndex = charts.add(ChartType.Column, 10, 10, 20, 20);
|
|
1847
1847
|
var chart = charts.get(chartIndex);
|
|
1848
|
-
chart.
|
|
1848
|
+
chart.nSeries.add("Sheet1!C2:C6", true);
|
|
1849
1849
|
}
|
|
1850
1850
|
sampleWorksheetCollectionAddSheetType();
|
|
1851
1851
|
|
|
@@ -1853,8 +1853,8 @@ function sampleWorksheetCollectionBuiltInDocumentProperties() {
|
|
|
1853
1853
|
const { Workbook } = require("aspose.cells.node");
|
|
1854
1854
|
|
|
1855
1855
|
var workbook = new Workbook();
|
|
1856
|
-
var doc = workbook.
|
|
1857
|
-
doc.
|
|
1856
|
+
var doc = workbook.worksheets.builtInDocumentProperties.get("Author");
|
|
1857
|
+
doc.value = "John Smith";
|
|
1858
1858
|
}
|
|
1859
1859
|
sampleWorksheetCollectionBuiltInDocumentProperties();
|
|
1860
1860
|
|
|
@@ -1862,7 +1862,7 @@ function sampleWorksheetCollectionCustomDocumentProperties() {
|
|
|
1862
1862
|
const { Workbook } = require("aspose.cells.node");
|
|
1863
1863
|
|
|
1864
1864
|
var excel = new Workbook();
|
|
1865
|
-
excel.
|
|
1865
|
+
excel.worksheets.customDocumentProperties.add("Checked by", "Jane");
|
|
1866
1866
|
}
|
|
1867
1867
|
sampleWorksheetCollectionCustomDocumentProperties();
|
|
1868
1868
|
|
|
@@ -1871,8 +1871,8 @@ function sampleVerticalPageBreak() {
|
|
|
1871
1871
|
|
|
1872
1872
|
var excel = new Workbook();
|
|
1873
1873
|
//Add a pagebreak at G5
|
|
1874
|
-
excel.
|
|
1875
|
-
excel.
|
|
1874
|
+
excel.worksheets.get(0).horizontalPageBreaks.add("G5");
|
|
1875
|
+
excel.worksheets.get(0).verticalPageBreaks.add("G5");
|
|
1876
1876
|
}
|
|
1877
1877
|
sampleVerticalPageBreak();
|
|
1878
1878
|
|
|
@@ -1882,7 +1882,7 @@ function sampleExternalLinkCollection() {
|
|
|
1882
1882
|
//Open a file with external links
|
|
1883
1883
|
var workbook = new Workbook("input/Externlink.xls");
|
|
1884
1884
|
//Change external link data source
|
|
1885
|
-
workbook.
|
|
1885
|
+
workbook.worksheets.externalLinks.get(0).dataSource = "input/Book1.xls";
|
|
1886
1886
|
}
|
|
1887
1887
|
sampleExternalLinkCollection();
|
|
1888
1888
|
|
|
@@ -1892,33 +1892,33 @@ function sampleDrawingChartShape() {
|
|
|
1892
1892
|
//Instantiating a Workbook object
|
|
1893
1893
|
var workbook = new Workbook();
|
|
1894
1894
|
//Obtaining the reference of the first worksheet
|
|
1895
|
-
var worksheet = workbook.
|
|
1895
|
+
var worksheet = workbook.worksheets.get(0);
|
|
1896
1896
|
//Adding a sample value to "A1" cell
|
|
1897
|
-
worksheet.
|
|
1897
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1898
1898
|
//Adding a sample value to "A2" cell
|
|
1899
|
-
worksheet.
|
|
1899
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1900
1900
|
//Adding a sample value to "A3" cell
|
|
1901
|
-
worksheet.
|
|
1901
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1902
1902
|
//Adding a sample value to "B1" cell
|
|
1903
|
-
worksheet.
|
|
1903
|
+
worksheet.cells.get("B1").putValue(60);
|
|
1904
1904
|
//Adding a sample value to "B2" cell
|
|
1905
|
-
worksheet.
|
|
1905
|
+
worksheet.cells.get("B2").putValue(32);
|
|
1906
1906
|
//Adding a sample value to "B3" cell
|
|
1907
|
-
worksheet.
|
|
1907
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1908
1908
|
//Adding a chart to the worksheet
|
|
1909
|
-
var chartIndex = worksheet.
|
|
1909
|
+
var chartIndex = worksheet.charts.add(ChartType.PieExploded, 5, 0, 25, 10);
|
|
1910
1910
|
//Accessing the instance of the newly added chart
|
|
1911
|
-
var chart = worksheet.
|
|
1911
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1912
1912
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
1913
|
-
chart.
|
|
1913
|
+
chart.nSeries.add("A1:B3", true);
|
|
1914
1914
|
//Show Data Labels
|
|
1915
|
-
chart.
|
|
1915
|
+
chart.nSeries.get(0).dataLabels.showValue = true;
|
|
1916
1916
|
//Getting Chart Shape
|
|
1917
|
-
var chartShape = chart.
|
|
1917
|
+
var chartShape = chart.chartObject;
|
|
1918
1918
|
//Set Lower Right Column
|
|
1919
|
-
chartShape.
|
|
1919
|
+
chartShape.lowerRightColumn = 10;
|
|
1920
1920
|
//Set LowerDeltaX
|
|
1921
|
-
chartShape.
|
|
1921
|
+
chartShape.lowerDeltaX = 1024;
|
|
1922
1922
|
//Saving the Excel file
|
|
1923
1923
|
workbook.save("output/DrawingChartShape.xls");
|
|
1924
1924
|
}
|
|
@@ -1930,32 +1930,32 @@ function sampleChartsChartDataTable() {
|
|
|
1930
1930
|
//Instantiating a Workbook object
|
|
1931
1931
|
var workbook = new Workbook();
|
|
1932
1932
|
//Obtaining the reference of the first worksheet
|
|
1933
|
-
var worksheet = workbook.
|
|
1933
|
+
var worksheet = workbook.worksheets.get(0);
|
|
1934
1934
|
//Adding a sample value to "A1" cell
|
|
1935
|
-
worksheet.
|
|
1935
|
+
worksheet.cells.get("A1").putValue(50);
|
|
1936
1936
|
//Adding a sample value to "A2" cell
|
|
1937
|
-
worksheet.
|
|
1937
|
+
worksheet.cells.get("A2").putValue(100);
|
|
1938
1938
|
//Adding a sample value to "A3" cell
|
|
1939
|
-
worksheet.
|
|
1939
|
+
worksheet.cells.get("A3").putValue(150);
|
|
1940
1940
|
//Adding a sample value to "B1" cell
|
|
1941
|
-
worksheet.
|
|
1941
|
+
worksheet.cells.get("B1").putValue(60);
|
|
1942
1942
|
//Adding a sample value to "B2" cell
|
|
1943
|
-
worksheet.
|
|
1943
|
+
worksheet.cells.get("B2").putValue(32);
|
|
1944
1944
|
//Adding a sample value to "B3" cell
|
|
1945
|
-
worksheet.
|
|
1945
|
+
worksheet.cells.get("B3").putValue(50);
|
|
1946
1946
|
//Adding a chart to the worksheet
|
|
1947
|
-
var chartIndex = worksheet.
|
|
1947
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 25, 10);
|
|
1948
1948
|
//Accessing the instance of the newly added chart
|
|
1949
|
-
var chart = worksheet.
|
|
1949
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
1950
1950
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
1951
|
-
chart.
|
|
1952
|
-
chart.
|
|
1951
|
+
chart.nSeries.add("A1:B3", true);
|
|
1952
|
+
chart.showDataTable = true;
|
|
1953
1953
|
//Getting Chart Table
|
|
1954
1954
|
var chartTable = chart.getChartDataTable();
|
|
1955
1955
|
//Setting Chart Table Font Color
|
|
1956
|
-
chartTable.
|
|
1956
|
+
chartTable.font.color = Color.Red;
|
|
1957
1957
|
//Setting Legend Key Visibility
|
|
1958
|
-
chartTable.
|
|
1958
|
+
chartTable.showLegendKey = false;
|
|
1959
1959
|
//Saving the Excel file
|
|
1960
1960
|
workbook.save("output/ChartsChartDataTable.xls");
|
|
1961
1961
|
}
|
|
@@ -1967,14 +1967,14 @@ function sampleRenderingImageOrPrintOptions() {
|
|
|
1967
1967
|
//Set Image Or Print Options
|
|
1968
1968
|
var options = new ImageOrPrintOptions();
|
|
1969
1969
|
//set Horizontal resolution
|
|
1970
|
-
options.
|
|
1970
|
+
options.horizontalResolution = 200;
|
|
1971
1971
|
//set Vertica; Resolution
|
|
1972
|
-
options.
|
|
1972
|
+
options.verticalResolution = 300;
|
|
1973
1973
|
|
|
1974
1974
|
//Instantiate Workbook
|
|
1975
1975
|
var book = new Workbook("input/Chart.xls");
|
|
1976
1976
|
//Save chart as Image using ImageOrPrint Options
|
|
1977
|
-
book.
|
|
1977
|
+
book.worksheets.get(0).charts.get(0).toImage("output/chart.png", options);
|
|
1978
1978
|
}
|
|
1979
1979
|
sampleRenderingImageOrPrintOptions();
|
|
1980
1980
|
|
|
@@ -1984,9 +1984,9 @@ function sampleName() {
|
|
|
1984
1984
|
//Instantiating a Workbook object
|
|
1985
1985
|
var workbook = new Workbook();
|
|
1986
1986
|
//Accessing the first worksheet in the Excel file
|
|
1987
|
-
var worksheet = workbook.
|
|
1987
|
+
var worksheet = workbook.worksheets.get(0);
|
|
1988
1988
|
//Creating a named range
|
|
1989
|
-
var range = worksheet.
|
|
1989
|
+
var range = worksheet.cells.createRange("B4", "G14");
|
|
1990
1990
|
//Setting the name of the named range
|
|
1991
1991
|
range.setName("TestRange");
|
|
1992
1992
|
//Saving the modified Excel file in default (that is Excel 2000) format
|
|
@@ -2000,31 +2000,31 @@ function sampleChartsChartArea() {
|
|
|
2000
2000
|
//Instantiating a Workbook object
|
|
2001
2001
|
var workbook = new Workbook();
|
|
2002
2002
|
//Obtaining the reference of the first worksheet
|
|
2003
|
-
var worksheet = workbook.
|
|
2003
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2004
2004
|
//Adding a sample value to "A1" cell
|
|
2005
|
-
worksheet.
|
|
2005
|
+
worksheet.cells.get("A1").putValue(50);
|
|
2006
2006
|
//Adding a sample value to "A2" cell
|
|
2007
|
-
worksheet.
|
|
2007
|
+
worksheet.cells.get("A2").putValue(100);
|
|
2008
2008
|
//Adding a sample value to "A3" cell
|
|
2009
|
-
worksheet.
|
|
2009
|
+
worksheet.cells.get("A3").putValue(150);
|
|
2010
2010
|
//Adding a sample value to "B1" cell
|
|
2011
|
-
worksheet.
|
|
2011
|
+
worksheet.cells.get("B1").putValue(60);
|
|
2012
2012
|
//Adding a sample value to "B2" cell
|
|
2013
|
-
worksheet.
|
|
2013
|
+
worksheet.cells.get("B2").putValue(32);
|
|
2014
2014
|
//Adding a sample value to "B3" cell
|
|
2015
|
-
worksheet.
|
|
2015
|
+
worksheet.cells.get("B3").putValue(50);
|
|
2016
2016
|
//Adding a chart to the worksheet
|
|
2017
|
-
var chartIndex = worksheet.
|
|
2017
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
2018
2018
|
//Accessing the instance of the newly added chart
|
|
2019
|
-
var chart = worksheet.
|
|
2019
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
2020
2020
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
2021
|
-
chart.
|
|
2021
|
+
chart.nSeries.add("A1:B3", true);
|
|
2022
2022
|
//Getting Chart Area
|
|
2023
|
-
var chartArea = chart.
|
|
2023
|
+
var chartArea = chart.chartArea;
|
|
2024
2024
|
//Setting the foreground color of the chart area
|
|
2025
|
-
chartArea.getArea().
|
|
2025
|
+
chartArea.getArea().foregroundColor = Color.Yellow;
|
|
2026
2026
|
//Setting Chart Area Shadow
|
|
2027
|
-
chartArea.
|
|
2027
|
+
chartArea.shadow = true;
|
|
2028
2028
|
//Saving the Excel file
|
|
2029
2029
|
workbook.save("output/ChartsChartArea.xls");
|
|
2030
2030
|
}
|
|
@@ -2034,8 +2034,8 @@ function sampleChartsChart() {
|
|
|
2034
2034
|
const { Workbook, ChartType } = require("aspose.cells.node");
|
|
2035
2035
|
|
|
2036
2036
|
var workbook = new Workbook();
|
|
2037
|
-
var sheet = workbook.
|
|
2038
|
-
var cells = sheet.
|
|
2037
|
+
var sheet = workbook.worksheets.get(0);
|
|
2038
|
+
var cells = sheet.cells;
|
|
2039
2039
|
cells.get(0, 1).putValue("Income");
|
|
2040
2040
|
cells.get(1, 0).putValue("Company A");
|
|
2041
2041
|
cells.get(2, 0).putValue("Company B");
|
|
@@ -2043,14 +2043,14 @@ function sampleChartsChart() {
|
|
|
2043
2043
|
cells.get(1, 1).putValue(10000);
|
|
2044
2044
|
cells.get(2, 1).putValue(20000);
|
|
2045
2045
|
cells.get(3, 1).putValue(30000);
|
|
2046
|
-
var chartIndex = sheet.
|
|
2047
|
-
var chart = sheet.
|
|
2048
|
-
chart.
|
|
2049
|
-
chart.
|
|
2050
|
-
var aSeries = chart.
|
|
2051
|
-
aSeries.
|
|
2052
|
-
chart.
|
|
2053
|
-
chart.
|
|
2046
|
+
var chartIndex = sheet.charts.add(ChartType.Column, 9, 9, 21, 15);
|
|
2047
|
+
var chart = sheet.charts.get(chartIndex);
|
|
2048
|
+
chart.nSeries.add("B2:B4", true);
|
|
2049
|
+
chart.nSeries.categoryData = "A2:A4";
|
|
2050
|
+
var aSeries = chart.nSeries.get(0);
|
|
2051
|
+
aSeries.name = "=B1";
|
|
2052
|
+
chart.showLegend = true;
|
|
2053
|
+
chart.title.text = "Income Analysis";
|
|
2054
2054
|
}
|
|
2055
2055
|
sampleChartsChart();
|
|
2056
2056
|
|
|
@@ -2060,11 +2060,11 @@ function sampleChartsChartToImageImageOrPrintOptions() {
|
|
|
2060
2060
|
|
|
2061
2061
|
var options = new ImageOrPrintOptions();
|
|
2062
2062
|
options.setImageType(ImageType.Jpeg);
|
|
2063
|
-
options.
|
|
2064
|
-
options.
|
|
2063
|
+
options.horizontalResolution = 400;
|
|
2064
|
+
options.verticalResolution = 300;
|
|
2065
2065
|
|
|
2066
2066
|
var book = new Workbook("input/Chart.xls");
|
|
2067
|
-
var uint8Array = book.
|
|
2067
|
+
var uint8Array = book.worksheets.get(0).charts.get(0).toImage(options);
|
|
2068
2068
|
const buffer = Buffer.from(uint8Array);
|
|
2069
2069
|
fs.writeFileSync("output/chart-stream.jpg", buffer);
|
|
2070
2070
|
}
|
|
@@ -2074,12 +2074,12 @@ function sampleChartsChartToImageStringImageOrPrintOptions() {
|
|
|
2074
2074
|
const { Workbook, ImageOrPrintOptions } = require("aspose.cells.node");
|
|
2075
2075
|
|
|
2076
2076
|
var options = new ImageOrPrintOptions();
|
|
2077
|
-
options.
|
|
2078
|
-
options.
|
|
2079
|
-
options.
|
|
2077
|
+
options.horizontalResolution = 400;
|
|
2078
|
+
options.verticalResolution = 300;
|
|
2079
|
+
options.quality = 80;
|
|
2080
2080
|
|
|
2081
2081
|
var book = new Workbook("input/Chart.xls");
|
|
2082
|
-
book.
|
|
2082
|
+
book.worksheets.get(0).charts.get(0).toImage("output/chart-r-400x300.png", options);
|
|
2083
2083
|
}
|
|
2084
2084
|
sampleChartsChartToImageStringImageOrPrintOptions();
|
|
2085
2085
|
|
|
@@ -2089,19 +2089,19 @@ function sampleFontSetting() {
|
|
|
2089
2089
|
//Instantiating a Workbook object
|
|
2090
2090
|
var workbook = new Workbook();
|
|
2091
2091
|
//Adding a new worksheet to the Excel object
|
|
2092
|
-
workbook.
|
|
2092
|
+
workbook.worksheets.add();
|
|
2093
2093
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
2094
|
-
var worksheet = workbook.
|
|
2094
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2095
2095
|
//Accessing the "A1" cell from the worksheet
|
|
2096
|
-
var cell = worksheet.
|
|
2096
|
+
var cell = worksheet.cells.get("A1");
|
|
2097
2097
|
//Adding some value to the "A1" cell
|
|
2098
2098
|
cell.putValue("Visit Aspose!");
|
|
2099
2099
|
//getting charactor
|
|
2100
2100
|
var charactor = cell.characters(6, 7);
|
|
2101
2101
|
//Setting the font of selected characters to bold
|
|
2102
|
-
charactor.
|
|
2102
|
+
charactor.font.isBold = true;
|
|
2103
2103
|
//Setting the font color of selected characters to blue
|
|
2104
|
-
charactor.
|
|
2104
|
+
charactor.font.color = Color.Blue;
|
|
2105
2105
|
//Saving the Excel file
|
|
2106
2106
|
workbook.save("output/FontSetting.xls");
|
|
2107
2107
|
}
|
|
@@ -2113,29 +2113,29 @@ function sampleDrawingLineShape() {
|
|
|
2113
2113
|
//Instantiate a new Workbook.
|
|
2114
2114
|
var workbook = new Workbook();
|
|
2115
2115
|
//Get the first worksheet in the book.
|
|
2116
|
-
var worksheet = workbook.
|
|
2116
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2117
2117
|
//Add a new line to the worksheet.
|
|
2118
|
-
var line1 = worksheet.
|
|
2118
|
+
var line1 = worksheet.shapes.addLine(5, 0, 1, 0, 0, 250);
|
|
2119
2119
|
//Set the line dash style
|
|
2120
|
-
line1.
|
|
2120
|
+
line1.line.dashStyle = MsoLineDashStyle.Solid;
|
|
2121
2121
|
//Set the placement.
|
|
2122
|
-
line1.
|
|
2122
|
+
line1.placement = PlacementType.FreeFloating;
|
|
2123
2123
|
//Add another line to the worksheet.
|
|
2124
|
-
var line2 = worksheet.
|
|
2124
|
+
var line2 = worksheet.shapes.addLine(7, 0, 1, 0, 85, 250);
|
|
2125
2125
|
//Set the line dash style.
|
|
2126
|
-
line2.
|
|
2126
|
+
line2.line.dashStyle = MsoLineDashStyle.DashLongDash;
|
|
2127
2127
|
//Set the weight of the line.
|
|
2128
|
-
line2.
|
|
2128
|
+
line2.line.weight = 4;
|
|
2129
2129
|
//Set the placement.
|
|
2130
|
-
line2.
|
|
2130
|
+
line2.placement = PlacementType.FreeFloating;
|
|
2131
2131
|
//Add the third line to the worksheet.
|
|
2132
|
-
var line3 = worksheet.
|
|
2132
|
+
var line3 = worksheet.shapes.addShape(MsoDrawingType.Line, 13, 0, 1, 0, 0, 250);
|
|
2133
2133
|
//Set the line dash style
|
|
2134
|
-
line3.
|
|
2134
|
+
line3.line.dashStyle = MsoLineDashStyle.Solid;
|
|
2135
2135
|
//Set the placement.
|
|
2136
|
-
line3.
|
|
2136
|
+
line3.placement = PlacementType.FreeFloating;
|
|
2137
2137
|
//Make the gridlines invisible in the first worksheet.
|
|
2138
|
-
workbook.
|
|
2138
|
+
workbook.worksheets.get(0).isGridlinesVisible = false;
|
|
2139
2139
|
//Save the excel file.
|
|
2140
2140
|
workbook.save("output/DrawingLineShape.xls");
|
|
2141
2141
|
}
|
|
@@ -2147,76 +2147,76 @@ function sampleDrawingGroupBox() {
|
|
|
2147
2147
|
//Instantiate a new Workbook.
|
|
2148
2148
|
var excelbook = new Workbook();
|
|
2149
2149
|
//Add a group box to the first worksheet.
|
|
2150
|
-
var box = excelbook.
|
|
2150
|
+
var box = excelbook.worksheets.get(0).shapes.addGroupBox(1, 0, 1, 0, 300, 250);
|
|
2151
2151
|
//Set the caption of the group box.
|
|
2152
|
-
box.
|
|
2153
|
-
box.
|
|
2152
|
+
box.text = "Age Groups";
|
|
2153
|
+
box.placement = PlacementType.FreeFloating;
|
|
2154
2154
|
//Make it 2-D box.
|
|
2155
|
-
box.
|
|
2155
|
+
box.shadow = false;
|
|
2156
2156
|
//Add a radio button.
|
|
2157
|
-
var radio1 = excelbook.
|
|
2157
|
+
var radio1 = excelbook.worksheets.get(0).shapes.addRadioButton(3, 0, 2, 0, 30, 110);
|
|
2158
2158
|
//Set its text string.
|
|
2159
|
-
radio1.
|
|
2159
|
+
radio1.text = "20-29";
|
|
2160
2160
|
//Set A1 cell as a linked cell for the radio button.
|
|
2161
|
-
radio1.
|
|
2161
|
+
radio1.linkedCell = "A1";
|
|
2162
2162
|
//Make the radio button 3-D.
|
|
2163
|
-
radio1.
|
|
2163
|
+
radio1.shadow = true;
|
|
2164
2164
|
//Set the foreground color of the radio button.
|
|
2165
|
-
radio1.
|
|
2166
|
-
radio1.
|
|
2165
|
+
radio1.fill.fillType = FillType.Solid;
|
|
2166
|
+
radio1.fill.solidFill.color = Color.LightGreen;
|
|
2167
2167
|
//Set the line style of the radio button.
|
|
2168
|
-
radio1.
|
|
2168
|
+
radio1.line.compoundType = MsoLineStyle.ThickThin;
|
|
2169
2169
|
//Set the weight of the radio button.
|
|
2170
|
-
radio1.
|
|
2170
|
+
radio1.line.weight = 4;
|
|
2171
2171
|
//Set the line color of the radio button.
|
|
2172
|
-
radio1.
|
|
2173
|
-
radio1.
|
|
2172
|
+
radio1.line.fillType = FillType.Solid;
|
|
2173
|
+
radio1.line.solidFill.color = Color.Blue;
|
|
2174
2174
|
//Set the dash style of the radio button.
|
|
2175
|
-
radio1.
|
|
2175
|
+
radio1.line.dashStyle = MsoLineDashStyle.Solid;
|
|
2176
2176
|
//Add another radio button.
|
|
2177
|
-
var radio2 = excelbook.
|
|
2177
|
+
var radio2 = excelbook.worksheets.get(0).shapes.addRadioButton(6, 0, 2, 0, 30, 110);
|
|
2178
2178
|
//Set its text string.
|
|
2179
|
-
radio2.
|
|
2179
|
+
radio2.text = "30-39";
|
|
2180
2180
|
//Set A1 cell as a linked cell for the radio button.
|
|
2181
|
-
radio2.
|
|
2181
|
+
radio2.linkedCell = "A1";
|
|
2182
2182
|
//Make the radio button 3-D.
|
|
2183
|
-
radio2.
|
|
2183
|
+
radio2.shadow = true;
|
|
2184
2184
|
//Set the foreground color of the radio button.
|
|
2185
|
-
radio2.
|
|
2186
|
-
radio2.
|
|
2185
|
+
radio2.fill.fillType = FillType.Solid;
|
|
2186
|
+
radio2.fill.solidFill.color = Color.LightGreen;
|
|
2187
2187
|
//Set the line style of the radio button.
|
|
2188
|
-
radio2.
|
|
2188
|
+
radio2.line.compoundType = MsoLineStyle.ThickThin;
|
|
2189
2189
|
//Set the weight of the radio button.
|
|
2190
|
-
radio2.
|
|
2190
|
+
radio2.line.weight = 4;
|
|
2191
2191
|
//Set the line color of the radio button.
|
|
2192
|
-
radio2.
|
|
2193
|
-
radio2.
|
|
2192
|
+
radio2.line.fillType = FillType.Solid;
|
|
2193
|
+
radio2.line.solidFill.color = Color.Blue;
|
|
2194
2194
|
//Set the dash style of the radio button.
|
|
2195
|
-
radio2.
|
|
2195
|
+
radio2.line.dashStyle = MsoLineDashStyle.Solid;
|
|
2196
2196
|
//Add another radio button.
|
|
2197
|
-
var radio3 = excelbook.
|
|
2197
|
+
var radio3 = excelbook.worksheets.get(0).shapes.addRadioButton(9, 0, 2, 0, 30, 110);
|
|
2198
2198
|
//Set its text string.
|
|
2199
|
-
radio3.
|
|
2199
|
+
radio3.text = "40-49";
|
|
2200
2200
|
//Set A1 cell as a linked cell for the radio button.
|
|
2201
|
-
radio3.
|
|
2201
|
+
radio3.linkedCell = "A1";
|
|
2202
2202
|
//Make the radio button 3-D.
|
|
2203
|
-
radio3.
|
|
2203
|
+
radio3.shadow = true;
|
|
2204
2204
|
//Set the foreground color of the radio button.
|
|
2205
|
-
radio3.
|
|
2206
|
-
radio3.
|
|
2205
|
+
radio3.fill.fillType = FillType.Solid;
|
|
2206
|
+
radio3.fill.solidFill.color = Color.LightGreen;
|
|
2207
2207
|
//Set the line style of the radio button.
|
|
2208
|
-
radio3.
|
|
2208
|
+
radio3.line.compoundType = MsoLineStyle.ThickThin;
|
|
2209
2209
|
//Set the weight of the radio button.
|
|
2210
|
-
radio3.
|
|
2210
|
+
radio3.line.weight = 4;
|
|
2211
2211
|
//Set the line color of the radio button.
|
|
2212
|
-
radio3.
|
|
2213
|
-
radio3.
|
|
2212
|
+
radio3.line.fillType = FillType.Solid;
|
|
2213
|
+
radio3.line.solidFill.color = Color.Blue;
|
|
2214
2214
|
//Set the dash style of the radio button.
|
|
2215
|
-
radio3.
|
|
2215
|
+
radio3.line.dashStyle = MsoLineDashStyle.Solid;
|
|
2216
2216
|
//Get the shapes.
|
|
2217
2217
|
var shapeobjects = [ box, radio1, radio2, radio3 ];
|
|
2218
2218
|
//Group the shapes.
|
|
2219
|
-
var group = excelbook.
|
|
2219
|
+
var group = excelbook.worksheets.get(0).shapes.group(shapeobjects);
|
|
2220
2220
|
|
|
2221
2221
|
//Save the excel file.
|
|
2222
2222
|
excelbook.save("output/DrawingGroupBox.xls");
|
|
@@ -2229,19 +2229,19 @@ function sampleFont() {
|
|
|
2229
2229
|
//Instantiating a Workbook object
|
|
2230
2230
|
var workbook = new Workbook();
|
|
2231
2231
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
2232
|
-
var worksheet = workbook.
|
|
2232
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2233
2233
|
//Accessing the "A1" cell from the worksheet
|
|
2234
|
-
var cell = worksheet.
|
|
2234
|
+
var cell = worksheet.cells.get("A1");
|
|
2235
2235
|
//Adding some value to the "A1" cell
|
|
2236
2236
|
cell.putValue("Hello Aspose!");
|
|
2237
2237
|
var style = cell.getStyle();
|
|
2238
|
-
var font = style.
|
|
2238
|
+
var font = style.font;
|
|
2239
2239
|
//Setting the font name to "Times New Roman"
|
|
2240
2240
|
font.setName("Times New Roman");
|
|
2241
2241
|
//Setting font size to 14
|
|
2242
2242
|
font.setSize(14);
|
|
2243
2243
|
//setting font color as Red
|
|
2244
|
-
font.
|
|
2244
|
+
font.color = Color.Red;
|
|
2245
2245
|
cell.setStyle(style);
|
|
2246
2246
|
//Saving the Excel file
|
|
2247
2247
|
workbook.save("output/Font.xls");
|
|
@@ -2253,13 +2253,13 @@ function sampleFontName() {
|
|
|
2253
2253
|
|
|
2254
2254
|
var workbook = new Workbook();
|
|
2255
2255
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
2256
|
-
var worksheet = workbook.
|
|
2256
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2257
2257
|
//Accessing the "A1" cell from the worksheet
|
|
2258
|
-
var cell = worksheet.
|
|
2258
|
+
var cell = worksheet.cells.get("A1");
|
|
2259
2259
|
//Adding some value to the "A1" cell
|
|
2260
2260
|
cell.putValue("Hello Aspose!");
|
|
2261
2261
|
var style = cell.getStyle();
|
|
2262
|
-
var font = style.
|
|
2262
|
+
var font = style.font;
|
|
2263
2263
|
font.setName("Times New Roman");
|
|
2264
2264
|
cell.setStyle(style);
|
|
2265
2265
|
}
|
|
@@ -2270,9 +2270,9 @@ function sampleConditionalFormattingCollection() {
|
|
|
2270
2270
|
|
|
2271
2271
|
//Instantiating a Workbook object
|
|
2272
2272
|
var workbook = new Workbook();
|
|
2273
|
-
var sheet = workbook.
|
|
2273
|
+
var sheet = workbook.worksheets.get(0);
|
|
2274
2274
|
//Get Conditional Formattings
|
|
2275
|
-
var cformattings = sheet.
|
|
2275
|
+
var cformattings = sheet.conditionalFormattings;
|
|
2276
2276
|
//Adds an empty conditional formatting
|
|
2277
2277
|
var index = cformattings.add();
|
|
2278
2278
|
//Get newly added Conditional formatting
|
|
@@ -2296,7 +2296,7 @@ function sampleConditionalFormattingCollection() {
|
|
|
2296
2296
|
var conditionIndex2 = fcs.addCondition(FormatConditionType.CellValue, OperatorType.Between, "50", "100");
|
|
2297
2297
|
//Sets the background color.
|
|
2298
2298
|
var fc = fcs.get(conditionIndex);
|
|
2299
|
-
fc.
|
|
2299
|
+
fc.style.backgroundColor = Color.Red;
|
|
2300
2300
|
//Saving the Excel file
|
|
2301
2301
|
workbook.save("output/ConditionalFormattingCollection.xls");
|
|
2302
2302
|
}
|
|
@@ -2308,13 +2308,13 @@ function sampleDrawingComboBox() {
|
|
|
2308
2308
|
//Create a new Workbook.
|
|
2309
2309
|
var workbook = new Workbook();
|
|
2310
2310
|
//Get the first worksheet.
|
|
2311
|
-
var sheet = workbook.
|
|
2311
|
+
var sheet = workbook.worksheets.get(0);
|
|
2312
2312
|
//Get the worksheet cells collection.
|
|
2313
|
-
var cells = sheet.
|
|
2313
|
+
var cells = sheet.cells;
|
|
2314
2314
|
//Input a value.
|
|
2315
2315
|
cells.get("B3").putValue("Employee:");
|
|
2316
2316
|
//Set it bold.
|
|
2317
|
-
cells.get("B3").getStyle().
|
|
2317
|
+
cells.get("B3").getStyle().font.isBold = true;
|
|
2318
2318
|
//Input some values that denote the input range
|
|
2319
2319
|
//for the combo box.
|
|
2320
2320
|
cells.get("A2").putValue("Emp001");
|
|
@@ -2325,16 +2325,16 @@ function sampleDrawingComboBox() {
|
|
|
2325
2325
|
cells.get("A7").putValue("Emp006");
|
|
2326
2326
|
|
|
2327
2327
|
//Add a new combo box.
|
|
2328
|
-
var comboBox = sheet.
|
|
2328
|
+
var comboBox = sheet.shapes.addComboBox(2, 0, 2, 0, 22, 100);
|
|
2329
2329
|
//Set the linked cell;
|
|
2330
|
-
comboBox.
|
|
2330
|
+
comboBox.linkedCell = "A1";
|
|
2331
2331
|
//Set the input range.
|
|
2332
|
-
comboBox.
|
|
2332
|
+
comboBox.inputRange = "A2:A7";
|
|
2333
2333
|
//Set no. of list lines displayed in the combo
|
|
2334
2334
|
//box's list portion.
|
|
2335
|
-
comboBox.
|
|
2335
|
+
comboBox.dropDownLines = 5;
|
|
2336
2336
|
//Set the combo box with 3-D shading.
|
|
2337
|
-
comboBox.
|
|
2337
|
+
comboBox.shadow = true;
|
|
2338
2338
|
//AutoFit Columns
|
|
2339
2339
|
sheet.autoFitColumns();
|
|
2340
2340
|
//Saves the file.
|
|
@@ -2348,26 +2348,26 @@ function sampleColumnCollection() {
|
|
|
2348
2348
|
//Instantiating a Workbook object
|
|
2349
2349
|
var workbook = new Workbook();
|
|
2350
2350
|
//Obtaining the reference of the first worksheet
|
|
2351
|
-
var worksheet = workbook.
|
|
2351
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2352
2352
|
//Add new Style to Workbook
|
|
2353
2353
|
var style = workbook.createStyle();
|
|
2354
2354
|
//Setting the background color to Blue
|
|
2355
|
-
style.
|
|
2355
|
+
style.foregroundColor = Color.Blue;
|
|
2356
2356
|
//setting Background Pattern
|
|
2357
|
-
style.
|
|
2357
|
+
style.pattern = BackgroundType.Solid;
|
|
2358
2358
|
//New Style Flag
|
|
2359
2359
|
var styleFlag = new StyleFlag();
|
|
2360
2360
|
//Set All Styles
|
|
2361
|
-
styleFlag.
|
|
2361
|
+
styleFlag.all = true;
|
|
2362
2362
|
|
|
2363
2363
|
//Change the default width of first ten columns
|
|
2364
2364
|
for (var i = 0; i < 10; i++) {
|
|
2365
|
-
worksheet.
|
|
2365
|
+
worksheet.cells.columns.get(i).width = 20;
|
|
2366
2366
|
}
|
|
2367
2367
|
|
|
2368
2368
|
//Get the Column with non default formatting
|
|
2369
|
-
var columns = worksheet.
|
|
2370
|
-
var count = columns.
|
|
2369
|
+
var columns = worksheet.cells.columns;
|
|
2370
|
+
var count = columns.count;
|
|
2371
2371
|
for (var i = 0; i < count; i++) {
|
|
2372
2372
|
var column = columns.getColumnByIndex(i);
|
|
2373
2373
|
//Apply Style to first ten Columns
|
|
@@ -2385,7 +2385,7 @@ function sampleFindOptions() {
|
|
|
2385
2385
|
//Instantiate the workbook object
|
|
2386
2386
|
var workbook = new Workbook("input/Book1.xls");
|
|
2387
2387
|
//Get Cells collection
|
|
2388
|
-
var cells = workbook.
|
|
2388
|
+
var cells = workbook.worksheets.get(0).cells;
|
|
2389
2389
|
//Instantiate FindOptions Object
|
|
2390
2390
|
var findOptions = new FindOptions();
|
|
2391
2391
|
//Create a Cells Area
|
|
@@ -2398,9 +2398,9 @@ function sampleFindOptions() {
|
|
|
2398
2398
|
//Set cells area for find options
|
|
2399
2399
|
findOptions.setRange(ca);
|
|
2400
2400
|
//Set searching properties
|
|
2401
|
-
findOptions.
|
|
2402
|
-
findOptions.
|
|
2403
|
-
findOptions.
|
|
2401
|
+
findOptions.searchBackward = false;
|
|
2402
|
+
findOptions.searchOrderByRows = true;
|
|
2403
|
+
findOptions.lookInType = LookInType.Values;
|
|
2404
2404
|
//Find the cell with 0 value
|
|
2405
2405
|
var cell = cells.find(0, null, findOptions);
|
|
2406
2406
|
}
|
|
@@ -2412,51 +2412,51 @@ function sampleChartsSeries() {
|
|
|
2412
2412
|
//Instantiating a Workbook object
|
|
2413
2413
|
var workbook = new Workbook();
|
|
2414
2414
|
//Adding a new worksheet to the Excel object
|
|
2415
|
-
var sheetIndex = workbook.
|
|
2415
|
+
var sheetIndex = workbook.worksheets.add();
|
|
2416
2416
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
2417
|
-
var worksheet = workbook.
|
|
2417
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
2418
2418
|
//Adding a sample value to "A1" cell
|
|
2419
|
-
worksheet.
|
|
2419
|
+
worksheet.cells.get("A1").putValue(50);
|
|
2420
2420
|
//Adding a sample value to "A2" cell
|
|
2421
|
-
worksheet.
|
|
2421
|
+
worksheet.cells.get("A2").putValue(100);
|
|
2422
2422
|
//Adding a sample value to "A3" cell
|
|
2423
|
-
worksheet.
|
|
2423
|
+
worksheet.cells.get("A3").putValue(150);
|
|
2424
2424
|
//Adding a sample value to "A4" cell
|
|
2425
|
-
worksheet.
|
|
2425
|
+
worksheet.cells.get("A4").putValue(200);
|
|
2426
2426
|
//Adding a sample value to "B1" cell
|
|
2427
|
-
worksheet.
|
|
2427
|
+
worksheet.cells.get("B1").putValue(60);
|
|
2428
2428
|
//Adding a sample value to "B2" cell
|
|
2429
|
-
worksheet.
|
|
2429
|
+
worksheet.cells.get("B2").putValue(32);
|
|
2430
2430
|
//Adding a sample value to "B3" cell
|
|
2431
|
-
worksheet.
|
|
2431
|
+
worksheet.cells.get("B3").putValue(50);
|
|
2432
2432
|
//Adding a sample value to "B4" cell
|
|
2433
|
-
worksheet.
|
|
2433
|
+
worksheet.cells.get("B4").putValue(40);
|
|
2434
2434
|
//Adding a sample value to "C1" cell as category data
|
|
2435
|
-
worksheet.
|
|
2435
|
+
worksheet.cells.get("C1").putValue("Q1");
|
|
2436
2436
|
//Adding a sample value to "C2" cell as category data
|
|
2437
|
-
worksheet.
|
|
2437
|
+
worksheet.cells.get("C2").putValue("Q2");
|
|
2438
2438
|
//Adding a sample value to "C3" cell as category data
|
|
2439
|
-
worksheet.
|
|
2439
|
+
worksheet.cells.get("C3").putValue("Y1");
|
|
2440
2440
|
//Adding a sample value to "C4" cell as category data
|
|
2441
|
-
worksheet.
|
|
2441
|
+
worksheet.cells.get("C4").putValue("Y2");
|
|
2442
2442
|
//Adding a chart to the worksheet
|
|
2443
|
-
var chartIndex = worksheet.
|
|
2443
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
2444
2444
|
//Accessing the instance of the newly added chart
|
|
2445
|
-
var chart = worksheet.
|
|
2445
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
2446
2446
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
|
|
2447
|
-
chart.
|
|
2447
|
+
chart.nSeries.add("A1:B4", true);
|
|
2448
2448
|
//Setting the data source for the category data of NSeries
|
|
2449
|
-
chart.
|
|
2450
|
-
var series = chart.
|
|
2449
|
+
chart.nSeries.categoryData = "C1:C4";
|
|
2450
|
+
var series = chart.nSeries.get(1);
|
|
2451
2451
|
//Setting the values of the series.
|
|
2452
|
-
series.
|
|
2452
|
+
series.values = "=B1:B4";
|
|
2453
2453
|
//Changing the chart type of the series.
|
|
2454
|
-
series.
|
|
2454
|
+
series.type = ChartType.Line;
|
|
2455
2455
|
//Setting marker properties.
|
|
2456
|
-
series.
|
|
2457
|
-
series.
|
|
2458
|
-
series.
|
|
2459
|
-
series.
|
|
2456
|
+
series.marker.markerStyle = ChartMarkerType.Circle;
|
|
2457
|
+
series.marker.foregroundColorSetType = FormattingType.Automatic;
|
|
2458
|
+
series.marker.foregroundColor = Color.Black;
|
|
2459
|
+
series.marker.backgroundColorSetType = FormattingType.Automatic;
|
|
2460
2460
|
//Saving the Excel file
|
|
2461
2461
|
workbook.save("output/ChartsSeries.xls");
|
|
2462
2462
|
}
|
|
@@ -2467,17 +2467,17 @@ function sampleChartsSeriesName() {
|
|
|
2467
2467
|
|
|
2468
2468
|
var workbook = new Workbook();
|
|
2469
2469
|
//Get the first worksheet.
|
|
2470
|
-
var worksheet = workbook.
|
|
2470
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2471
2471
|
//Adding a chart to the worksheet
|
|
2472
|
-
var chartIndex = worksheet.
|
|
2472
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
2473
2473
|
//Accessing the instance of the newly added chart
|
|
2474
|
-
var chart = worksheet.
|
|
2474
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
2475
2475
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
|
|
2476
|
-
chart.
|
|
2476
|
+
chart.nSeries.add("A1:B4", true);
|
|
2477
2477
|
//Reference name to a cell
|
|
2478
|
-
chart.
|
|
2478
|
+
chart.nSeries.get(0).name = "=A1";
|
|
2479
2479
|
//Set a string to name
|
|
2480
|
-
chart.
|
|
2480
|
+
chart.nSeries.get(0).name = "First Series";
|
|
2481
2481
|
}
|
|
2482
2482
|
sampleChartsSeriesName();
|
|
2483
2483
|
|
|
@@ -2485,14 +2485,14 @@ function sampleChartsTrendlineCollection() {
|
|
|
2485
2485
|
const { Workbook, ChartType, TrendlineType, Color } = require("aspose.cells.node");
|
|
2486
2486
|
|
|
2487
2487
|
var excel = new Workbook();
|
|
2488
|
-
var chartIndex = excel.
|
|
2489
|
-
var chart = excel.
|
|
2490
|
-
chart.
|
|
2491
|
-
chart.
|
|
2492
|
-
var line = chart.
|
|
2493
|
-
line.
|
|
2494
|
-
line.
|
|
2495
|
-
line.
|
|
2488
|
+
var chartIndex = excel.worksheets.get(0).charts.add(ChartType.Column, 3, 3, 15, 10);
|
|
2489
|
+
var chart = excel.worksheets.get(0).charts.get(chartIndex);
|
|
2490
|
+
chart.nSeries.add("A1:a3", true);
|
|
2491
|
+
chart.nSeries.get(0).trendLines.add(TrendlineType.Linear, "MyTrendLine");
|
|
2492
|
+
var line = chart.nSeries.get(0).trendLines.get(0);
|
|
2493
|
+
line.displayEquation = true;
|
|
2494
|
+
line.displayRSquared = true;
|
|
2495
|
+
line.color = Color.Red;
|
|
2496
2496
|
}
|
|
2497
2497
|
sampleChartsTrendlineCollection();
|
|
2498
2498
|
|
|
@@ -2502,50 +2502,50 @@ function sampleChartsTrendline() {
|
|
|
2502
2502
|
//Instantiating a Workbook object
|
|
2503
2503
|
var workbook = new Workbook();
|
|
2504
2504
|
//Adding a new worksheet to the Excel object
|
|
2505
|
-
var sheetIndex = workbook.
|
|
2505
|
+
var sheetIndex = workbook.worksheets.add();
|
|
2506
2506
|
//Obtaining the reference of the newly added worksheet by passing its sheet index
|
|
2507
|
-
var worksheet = workbook.
|
|
2507
|
+
var worksheet = workbook.worksheets.get(sheetIndex);
|
|
2508
2508
|
//Adding a sample value to "A1" cell
|
|
2509
|
-
worksheet.
|
|
2509
|
+
worksheet.cells.get("A1").putValue(50);
|
|
2510
2510
|
//Adding a sample value to "A2" cell
|
|
2511
|
-
worksheet.
|
|
2511
|
+
worksheet.cells.get("A2").putValue(100);
|
|
2512
2512
|
//Adding a sample value to "A3" cell
|
|
2513
|
-
worksheet.
|
|
2513
|
+
worksheet.cells.get("A3").putValue(150);
|
|
2514
2514
|
//Adding a sample value to "A4" cell
|
|
2515
|
-
worksheet.
|
|
2515
|
+
worksheet.cells.get("A4").putValue(200);
|
|
2516
2516
|
//Adding a sample value to "B1" cell
|
|
2517
|
-
worksheet.
|
|
2517
|
+
worksheet.cells.get("B1").putValue(60);
|
|
2518
2518
|
//Adding a sample value to "B2" cell
|
|
2519
|
-
worksheet.
|
|
2519
|
+
worksheet.cells.get("B2").putValue(32);
|
|
2520
2520
|
//Adding a sample value to "B3" cell
|
|
2521
|
-
worksheet.
|
|
2521
|
+
worksheet.cells.get("B3").putValue(50);
|
|
2522
2522
|
//Adding a sample value to "B4" cell
|
|
2523
|
-
worksheet.
|
|
2523
|
+
worksheet.cells.get("B4").putValue(40);
|
|
2524
2524
|
//Adding a sample value to "C1" cell as category data
|
|
2525
|
-
worksheet.
|
|
2525
|
+
worksheet.cells.get("C1").putValue("Q1");
|
|
2526
2526
|
//Adding a sample value to "C2" cell as category data
|
|
2527
|
-
worksheet.
|
|
2527
|
+
worksheet.cells.get("C2").putValue("Q2");
|
|
2528
2528
|
//Adding a sample value to "C3" cell as category data
|
|
2529
|
-
worksheet.
|
|
2529
|
+
worksheet.cells.get("C3").putValue("Y1");
|
|
2530
2530
|
//Adding a sample value to "C4" cell as category data
|
|
2531
|
-
worksheet.
|
|
2531
|
+
worksheet.cells.get("C4").putValue("Y2");
|
|
2532
2532
|
//Adding a chart to the worksheet
|
|
2533
|
-
var chartIndex = worksheet.
|
|
2533
|
+
var chartIndex = worksheet.charts.add(ChartType.Column, 5, 0, 15, 5);
|
|
2534
2534
|
//Accessing the instance of the newly added chart
|
|
2535
|
-
var chart = worksheet.
|
|
2535
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
2536
2536
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4"
|
|
2537
|
-
chart.
|
|
2537
|
+
chart.nSeries.add("A1:B4", true);
|
|
2538
2538
|
//Setting the data source for the category data of NSeries
|
|
2539
|
-
chart.
|
|
2539
|
+
chart.nSeries.categoryData = "C1:C4";
|
|
2540
2540
|
//adding a linear trendline
|
|
2541
|
-
var index = chart.
|
|
2542
|
-
var trendline = chart.
|
|
2541
|
+
var index = chart.nSeries.get(0).trendLines.add(TrendlineType.Linear);
|
|
2542
|
+
var trendline = chart.nSeries.get(0).trendLines.get(index);
|
|
2543
2543
|
//Setting the custom name of the trendline.
|
|
2544
|
-
trendline.
|
|
2544
|
+
trendline.name = "Linear";
|
|
2545
2545
|
//Displaying the equation on chart
|
|
2546
|
-
trendline.
|
|
2546
|
+
trendline.displayEquation = true;
|
|
2547
2547
|
//Displaying the R-Squared value on chart
|
|
2548
|
-
trendline.
|
|
2548
|
+
trendline.displayRSquared = true;
|
|
2549
2549
|
//Saving the Excel file
|
|
2550
2550
|
workbook.save("output/ChartsTrendline.xls");
|
|
2551
2551
|
}
|
|
@@ -2555,9 +2555,9 @@ function sampleCommentCollection() {
|
|
|
2555
2555
|
const { Workbook } = require("aspose.cells.node");
|
|
2556
2556
|
|
|
2557
2557
|
var excel = new Workbook();
|
|
2558
|
-
var index = excel.
|
|
2559
|
-
var checkBox = excel.
|
|
2560
|
-
checkBox.
|
|
2558
|
+
var index = excel.worksheets.get(0).getCheckBoxes().add(15, 15, 20, 100);
|
|
2559
|
+
var checkBox = excel.worksheets.get(0).getCheckBoxes().get(index);
|
|
2560
|
+
checkBox.text = "Check Box 1";
|
|
2561
2561
|
}
|
|
2562
2562
|
sampleCommentCollection();
|
|
2563
2563
|
|
|
@@ -2567,13 +2567,13 @@ function sampleAutoFilter() {
|
|
|
2567
2567
|
//Instantiating a Workbook object
|
|
2568
2568
|
var workbook = new Workbook("input/AutoFilter.xlsx");
|
|
2569
2569
|
//Accessing the first worksheet in the Excel file
|
|
2570
|
-
var worksheet = workbook.
|
|
2570
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2571
2571
|
//Creating AutoFilter by giving the cells range of the heading row
|
|
2572
|
-
worksheet.
|
|
2572
|
+
worksheet.autoFilter.range = "A1:C1";
|
|
2573
2573
|
//Filtering columns with specified values
|
|
2574
|
-
worksheet.
|
|
2574
|
+
worksheet.autoFilter.filter(2, "present");
|
|
2575
2575
|
// Refreshing auto filters to hide or unhide the rows.
|
|
2576
|
-
worksheet.
|
|
2576
|
+
worksheet.autoFilter.refresh();
|
|
2577
2577
|
//Saving the modified Excel file.
|
|
2578
2578
|
workbook.save("output/AutoFilter.xlsx");
|
|
2579
2579
|
}
|
|
@@ -2585,7 +2585,7 @@ function samplePropertiesDocumentProperty() {
|
|
|
2585
2585
|
//Instantiate a Workbook object
|
|
2586
2586
|
var workbook = new Workbook("input/CustomProperties.xlsx");
|
|
2587
2587
|
//Retrieve a list of all custom document properties of the Excel file
|
|
2588
|
-
var customProperties = workbook.
|
|
2588
|
+
var customProperties = workbook.worksheets.customDocumentProperties;
|
|
2589
2589
|
//Accessng a custom document property by using the property index
|
|
2590
2590
|
var customProperty1 = customProperties.get(3);
|
|
2591
2591
|
//Accessng a custom document property by using the property name
|
|
@@ -2597,7 +2597,7 @@ function sampleChartsChartCollection() {
|
|
|
2597
2597
|
const { Workbook } = require("aspose.cells.node");
|
|
2598
2598
|
|
|
2599
2599
|
var workbook = new Workbook();
|
|
2600
|
-
var charts = workbook.
|
|
2600
|
+
var charts = workbook.worksheets.get(0).charts;
|
|
2601
2601
|
}
|
|
2602
2602
|
sampleChartsChartCollection();
|
|
2603
2603
|
|
|
@@ -2607,36 +2607,36 @@ function sampleChartsChartPointCollection() {
|
|
|
2607
2607
|
//Instantiating a Workbook object
|
|
2608
2608
|
var workbook = new Workbook();
|
|
2609
2609
|
//Obtaining the reference of the first worksheet
|
|
2610
|
-
var worksheet = workbook.
|
|
2610
|
+
var worksheet = workbook.worksheets.get(0);
|
|
2611
2611
|
//Adding a sample value to "A1" cell
|
|
2612
|
-
worksheet.
|
|
2612
|
+
worksheet.cells.get("A1").putValue(50);
|
|
2613
2613
|
//Adding a sample value to "A2" cell
|
|
2614
|
-
worksheet.
|
|
2614
|
+
worksheet.cells.get("A2").putValue(100);
|
|
2615
2615
|
//Adding a sample value to "A3" cell
|
|
2616
|
-
worksheet.
|
|
2616
|
+
worksheet.cells.get("A3").putValue(150);
|
|
2617
2617
|
//Adding a sample value to "B1" cell
|
|
2618
|
-
worksheet.
|
|
2618
|
+
worksheet.cells.get("B1").putValue(60);
|
|
2619
2619
|
//Adding a sample value to "B2" cell
|
|
2620
|
-
worksheet.
|
|
2620
|
+
worksheet.cells.get("B2").putValue(32);
|
|
2621
2621
|
//Adding a sample value to "B3" cell
|
|
2622
|
-
worksheet.
|
|
2622
|
+
worksheet.cells.get("B3").putValue(50);
|
|
2623
2623
|
//Adding a chart to the worksheet
|
|
2624
|
-
var chartIndex = worksheet.
|
|
2624
|
+
var chartIndex = worksheet.charts.add(ChartType.PieExploded, 5, 0, 25, 10);
|
|
2625
2625
|
//Accessing the instance of the newly added chart
|
|
2626
|
-
var chart = worksheet.
|
|
2626
|
+
var chart = worksheet.charts.get(chartIndex);
|
|
2627
2627
|
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
|
|
2628
|
-
chart.
|
|
2628
|
+
chart.nSeries.add("A1:B3", true);
|
|
2629
2629
|
//Show Data Labels
|
|
2630
|
-
chart.
|
|
2631
|
-
var points = chart.
|
|
2630
|
+
chart.nSeries.get(0).dataLabels.showValue = true;
|
|
2631
|
+
var points = chart.nSeries.get(0).points;
|
|
2632
2632
|
var red = Color.Red;
|
|
2633
|
-
for (var i = 0; i < points.
|
|
2633
|
+
for (var i = 0; i < points.count; i++) {
|
|
2634
2634
|
//Get Data Point
|
|
2635
2635
|
var point = points.get(i);
|
|
2636
2636
|
//Set Pir Explosion
|
|
2637
|
-
point.
|
|
2637
|
+
point.explosion = 15;
|
|
2638
2638
|
//Set Border Color
|
|
2639
|
-
point.
|
|
2639
|
+
point.border.color = red;
|
|
2640
2640
|
}
|
|
2641
2641
|
|
|
2642
2642
|
//Saving the Excel file
|