Class Excel
Inheritance
Inherited Members
Namespace: Simplic.Framework.Office
Assembly: Simplic.Framework.Office.dll
Syntax
public static class Excel
Methods
| Improve this Doc View SourceAddBasicStyles(SpreadsheetDocument)
Adds the basic styles to the workbook
Declaration
public static bool AddBasicStyles(SpreadsheetDocument spreadsheet)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
AddPredefinedStyles(SpreadsheetDocument, String)
Adds a predefined style from the given xml
Declaration
public static bool AddPredefinedStyles(SpreadsheetDocument spreadsheet, string xml)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
System.String | xml | Style definition as xml |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
AddSharedString(SpreadsheetDocument, String, Boolean)
Add a single string to shared strings table. Shared string table is created if it doesn't exist.
Declaration
public static bool AddSharedString(SpreadsheetDocument spreadsheet, string stringItem, bool save = true)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
System.String | stringItem | string to add |
System.Boolean | save | Save the shared string table |
Returns
Type | Description |
---|---|
System.Boolean |
AddSharedStrings(SpreadsheetDocument, List<String>)
Adds a list of strings to the shared strings table.
Declaration
public static bool AddSharedStrings(SpreadsheetDocument spreadsheet, List<string> stringList)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | The spreadsheet |
System.Collections.Generic.List<System.String> | stringList | Strings to add |
Returns
Type | Description |
---|---|
System.Boolean |
AddWorksheet(SpreadsheetDocument, String)
Adds a new worksheet to the workbook
Declaration
public static bool AddWorksheet(SpreadsheetDocument spreadsheet, string name)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
System.String | name | Name of the worksheet |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
ColumnNameFromIndex(UInt32)
Converts a column number to column name (i.e. A, B, C..., AA, AB...)
Declaration
public static string ColumnNameFromIndex(uint columnIndex)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | columnIndex | Index of the column |
Returns
Type | Description |
---|---|
System.String | Column name |
CreateWorkbook(String)
Creates the workbook
Declaration
public static SpreadsheetDocument CreateWorkbook(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName |
Returns
Type | Description |
---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | Spreadsheet created |
IndexOfSharedString(SpreadsheetDocument, String)
Returns the index of a shared string.
Declaration
public static int IndexOfSharedString(SpreadsheetDocument spreadsheet, string stringItem)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
System.String | stringItem | String to search for |
Returns
Type | Description |
---|---|
System.Int32 | Index of a shared string. -1 if not found |
SetCellValue(SpreadsheetDocument, Worksheet, UInt32, UInt32, Boolean, Nullable<UInt32>, Boolean)
Sets a cell value with boolean value
Declaration
public static bool SetCellValue(SpreadsheetDocument spreadsheet, Worksheet worksheet, uint columnIndex, uint rowIndex, bool boolValue, uint? styleIndex, bool save = true)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
DocumentFormat.OpenXml.Spreadsheet.Worksheet | worksheet | Worksheet to use |
System.UInt32 | columnIndex | Index of the column |
System.UInt32 | rowIndex | Index of the row |
System.Boolean | boolValue | Boolean value |
System.Nullable<System.UInt32> | styleIndex | Style to use |
System.Boolean | save | Save the worksheet |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
SetCellValue(SpreadsheetDocument, Worksheet, UInt32, UInt32, DateTime, Nullable<UInt32>, Boolean)
Sets a cell value with a date
Declaration
public static bool SetCellValue(SpreadsheetDocument spreadsheet, Worksheet worksheet, uint columnIndex, uint rowIndex, DateTime datetimeValue, uint? styleIndex, bool save = true)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
DocumentFormat.OpenXml.Spreadsheet.Worksheet | worksheet | Worksheet to use |
System.UInt32 | columnIndex | Index of the column |
System.UInt32 | rowIndex | Index of the row |
System.DateTime | datetimeValue | DateTime value |
System.Nullable<System.UInt32> | styleIndex | Style to use |
System.Boolean | save | Save the worksheet |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
SetCellValue(SpreadsheetDocument, Worksheet, UInt32, UInt32, Double, Nullable<UInt32>, Boolean)
Sets a cell value with double number
Declaration
public static bool SetCellValue(SpreadsheetDocument spreadsheet, Worksheet worksheet, uint columnIndex, uint rowIndex, double doubleValue, uint? styleIndex, bool save = true)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
DocumentFormat.OpenXml.Spreadsheet.Worksheet | worksheet | Worksheet to use |
System.UInt32 | columnIndex | Index of the column |
System.UInt32 | rowIndex | Index of the row |
System.Double | doubleValue | Double value |
System.Nullable<System.UInt32> | styleIndex | Style to use |
System.Boolean | save | Save the worksheet |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
SetCellValue(SpreadsheetDocument, Worksheet, UInt32, UInt32, String, Boolean, Boolean)
Sets a string value to a cell
Declaration
public static bool SetCellValue(SpreadsheetDocument spreadsheet, Worksheet worksheet, uint columnIndex, uint rowIndex, string stringValue, bool useSharedString, bool save = true)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Packaging.SpreadsheetDocument | spreadsheet | Spreadsheet to use |
DocumentFormat.OpenXml.Spreadsheet.Worksheet | worksheet | Worksheet to use |
System.UInt32 | columnIndex | Index of the column |
System.UInt32 | rowIndex | Index of the row |
System.String | stringValue | String value to set |
System.Boolean | useSharedString | Use shared strings? If true and the string isn't found in shared strings, it will be added |
System.Boolean | save | Save the worksheet |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |
SetColumnWidth(Worksheet, Int32, Int32)
Sets the column width
Declaration
public static bool SetColumnWidth(Worksheet worksheet, int columnIndex, int width)
Parameters
Type | Name | Description |
---|---|---|
DocumentFormat.OpenXml.Spreadsheet.Worksheet | worksheet | Worksheet to use |
System.Int32 | columnIndex | Index of the column |
System.Int32 | width | Width to set |
Returns
Type | Description |
---|---|
System.Boolean | True if succesful |