ApiWorksheet
Class representing a sheet.
Methods
Name |
Description |
AddChart |
Create a chart of the set type from the selected data range of the current sheet. |
AddImage |
Adds the image to the current sheet with the parameters specified. |
AddShape |
Adds the shape to the current sheet with the parameters specified. |
FormatAsTable |
Format the selected range of cells from the current sheet as a table (with the first row formatted as a header). |
GetRange |
Returns an object that represents the selected range of the current sheet. Can be a single cell - A1, or cells from a single row - A1:E1, or cells from a single column - A1:A10, or cells from several rows and columns - A1:E10. |
GetRangeByNumber |
Returns an object that represents the selected range of the current sheet using the row/column coordinates for the cell selection. |
SetColumnWidth |
Set the width to the selected column of the current active sheet. The width is equal to the set number multiplied by 7 pixels - so if you set the width to 10 it will be equal to 70 pixels. |
SetDisplayGridlines |
Specifies whether the current sheet gridlines must be displayed or not. |
SetDisplayHeadings |
Specifies whether the current sheet row/column headers must be displayed or not. |
SetName |
Set a name to the current active sheet. |
Example
Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.SetName("sheet 1");
oWorksheet.GetRange("B1").SetValue("Row 1");
oWorksheet.GetRange("C1").SetValue("Row 2");
oWorksheet.GetRange("D1").SetValue("Row 3");
oWorksheet.GetRange("A2").SetValue("Category 1");
oWorksheet.GetRange("A3").SetValue("Category 2");
oWorksheet.GetRange("A4").SetValue("Category 3");
oWorksheet.GetRange("A5").SetValue("Category 4");
oWorksheet.GetRange("B2").SetValue("4.3");
oWorksheet.GetRange("B3").SetValue("2.5");
oWorksheet.GetRange("B4").SetValue("3.5");
oWorksheet.GetRange("B5").SetValue("4.5");
oWorksheet.GetRange("C2").SetValue("2.4");
oWorksheet.GetRange("C3").SetValue("4.4");
oWorksheet.GetRange("C4").SetValue("1.8");
oWorksheet.GetRange("C5").SetValue("2.8");
oWorksheet.GetRange("D2").SetValue("2");
oWorksheet.GetRange("D3").SetValue("2");
oWorksheet.GetRange("D4").SetValue("3");
oWorksheet.GetRange("D5").SetValue("5");
var oChart = oWorksheet.AddChart("'sheet 1'!$A$1:$D$5", true, "bar", 2, 5, 0, 12, 12);
oChart.SetVerAxisTitle("Vertical Title", 10);
oChart.SetHorAxisTitle("Horizontal Title", 11);
oChart.SetLegendPos("right");
oChart.SetShowDataLabels(false, false, true, false);
oChart.SetTitle("Main Chart Title", 13);
builder.SaveFile("xlsx", "AddChart.xlsx");
builder.CloseFile();
Resulting document