Skip to content

This content is for v4.x (Alpha). Switch to the Stable version.

Adding, Modifying a sheet from spreadsheet is handled by this class object

MethodParameter/ReturnFunction
GetSheetId/stringReturn current sheet id
GetSheetName/stringReturn current sheet name
SetColumncilumn,ColumnPropertySet column property
SetRowcellid,cellData,RowPropertySet row property and data
AddPicturefilePath,PictureSetting/PictureAdd Picture to current slide
AddChartDataRange,chartSetting/ChartAdd Chart to current slide
GetMergeCellList/List<MergeCellRange>Get existing merge range from current sheet
SetMergeCellMergeCellRange/boolSet new merge range if not affecting existing
RemoveMergeCellMergeCellRange/boolRemove any existing range within the caller range

To add, remove and get sheet from excel

let mut file = crate::spreadsheet_2007::Excel::new(
None,
crate::spreadsheet_2007::ExcelPropertiesModel::default(),
)
.expect("Create New File Failed");
// Add Sheet with custom name
file.add_sheet_mut(Some("Test".to_string()))
.expect("Failed to add static Sheet");
// Add Sheet with default name
file.add_sheet_mut(None)
.expect("Failed to add static Sheet");
// Save the result file
file.save_as(&get_save_file(None))
.expect("File Save Failed");
Worksheet worksheet = excel.AddSheet();
// Set Column property
worksheet.SetColumn("A1", new ColumnProperties()
{
width = 30
});
PropertyTypeDetails
bestFitboolAuto bit column width based on content.
hiddenboolHide the column
widthdouble?Set manual column width.
Worksheet worksheet = excel.AddSheet();
// Set Row data and setting starting from A1 Cell and move right
worksheet.SetRow("A1",
new DataCell[6]{
new DataCell(){
cellValue = "test1",
dataType = CellDataType.STRING
},
new DataCell(){
cellValue = "test2",
dataType = CellDataType.STRING
},
new DataCell(){
cellValue = "test3",
dataType = CellDataType.STRING
},
new DataCell(){
cellValue = "test4",
dataType = CellDataType.STRING,
styleSetting = new(){
fontSize = 20
}
},
new DataCell(){
cellValue = "2.51",
dataType = CellDataType.NUMBER,
styleSetting = new(){
numberFormat = "00.000",
}
},new(){
cellValue = "5.51",
dataType = CellDataType.NUMBER,
styleSetting = new(){
numberFormat = "₹ #,##0.00;₹ -#,##0.00",
}
}
}, new RowProperties()
{
height = 20
});
PropertyTypeDetails
cellValuestring?Can be any value or null. Will be parsed based on dataType
dataTypeCellDataTypeRefer to the data type present in cellValue property
styleSettingCellStyleSetting?AVOID USING THIS. Used to set specific cell style. For optimised performance refer Style Component
styleIduint?Insert the style Id returened from Style Componenet
hyperlinkPropertiesHyperlinkPropertiesSet hyperlink property for the current cell
PropertyTypeDetails
heightdouble?Set row height property
hiddenboolHide the row