Class WorksheetDataExtensions
Extension methods for data import and export operations on worksheets.
public static class WorksheetDataExtensions
- Inheritance
-
WorksheetDataExtensions
- Inherited Members
Methods
ExportToCsv(Worksheet, string, string, CsvOptions)
Exports worksheet data to a CSV file.
public static int ExportToCsv(this Worksheet worksheet, string filePath, string range = null, CsvOptions options = null)
Parameters
worksheetWorksheetThe worksheet to export data from.
filePathstringPath where the CSV file will be saved.
rangestringRange to export (e.g., "A1:E10"). If null, exports all used range.
optionsCsvOptionsCSV export options. If null, default options will be used.
Returns
- int
The number of rows exported.
ExportToCsvString(Worksheet, string, CsvOptions)
Exports worksheet data to a CSV string.
public static string ExportToCsvString(this Worksheet worksheet, string range = null, CsvOptions options = null)
Parameters
worksheetWorksheetThe worksheet to export data from.
rangestringRange to export (e.g., "A1:E10"). If null, exports all used range.
optionsCsvOptionsCSV export options. If null, default options will be used.
Returns
- string
The CSV string containing the exported data.
ExportToJson(Worksheet, string, string, JsonOptions)
Exports worksheet data to a JSON file.
public static int ExportToJson(this Worksheet worksheet, string filePath, string range = null, JsonOptions options = null)
Parameters
worksheetWorksheetThe worksheet to export data from.
filePathstringPath where the JSON file will be saved.
rangestringRange to export (e.g., "A1:E10"). If null, exports all used range.
optionsJsonOptionsJSON export options. If null, default options will be used.
Returns
- int
The number of records exported.
ExportToJsonString(Worksheet, string, JsonOptions)
Exports worksheet data to a JSON string.
public static string ExportToJsonString(this Worksheet worksheet, string range = null, JsonOptions options = null)
Parameters
worksheetWorksheetThe worksheet to export data from.
rangestringRange to export (e.g., "A1:E10"). If null, exports all used range.
optionsJsonOptionsJSON export options. If null, default options will be used.
Returns
- string
The JSON string containing the exported data.
ImportFromCsv(Worksheet, string, string, CsvOptions)
Imports data from a CSV file into the worksheet starting at the specified cell.
public static int ImportFromCsv(this Worksheet worksheet, string filePath, string startCellReference = "A1", CsvOptions options = null)
Parameters
worksheetWorksheetThe worksheet to import data into.
filePathstringPath to the CSV file.
startCellReferencestringStarting cell reference (e.g., "A1").
optionsCsvOptionsCSV import options. If null, default options will be used.
Returns
- int
The number of rows imported.
Exceptions
- FileNotFoundException
Thrown when the CSV file is not found.
- ArgumentException
Thrown when parameters are invalid.
ImportFromJson(Worksheet, string, string, JsonOptions)
Imports data from a JSON file into the worksheet starting at the specified cell. Supports both JSON arrays and single JSON objects.
public static int ImportFromJson(this Worksheet worksheet, string filePath, string startCellReference = "A1", JsonOptions options = null)
Parameters
worksheetWorksheetThe worksheet to import data into.
filePathstringPath to the JSON file.
startCellReferencestringStarting cell reference (e.g., "A1").
optionsJsonOptionsJSON import options. If null, default options will be used.
Returns
- int
The number of rows imported.
Exceptions
- FileNotFoundException
Thrown when the JSON file is not found.
- ArgumentException
Thrown when parameters are invalid.
- JsonException
Thrown when JSON parsing fails.
ImportFromJsonString(Worksheet, string, string, JsonOptions)
Imports data from a JSON string into the worksheet starting at the specified cell.
public static int ImportFromJsonString(this Worksheet worksheet, string jsonString, string startCellReference = "A1", JsonOptions options = null)
Parameters
worksheetWorksheetThe worksheet to import data into.
jsonStringstringThe JSON string containing the data.
startCellReferencestringStarting cell reference (e.g., "A1").
optionsJsonOptionsJSON import options. If null, default options will be used.
Returns
- int
The number of rows imported.