Table of Contents

Class WorksheetDataExtensions

Namespace
Openize.Cells
Assembly
Openize.OpenXMLSDK.dll

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

worksheet Worksheet

The worksheet to export data from.

filePath string

Path where the CSV file will be saved.

range string

Range to export (e.g., "A1:E10"). If null, exports all used range.

options CsvOptions

CSV 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

worksheet Worksheet

The worksheet to export data from.

range string

Range to export (e.g., "A1:E10"). If null, exports all used range.

options CsvOptions

CSV 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

worksheet Worksheet

The worksheet to export data from.

filePath string

Path where the JSON file will be saved.

range string

Range to export (e.g., "A1:E10"). If null, exports all used range.

options JsonOptions

JSON 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

worksheet Worksheet

The worksheet to export data from.

range string

Range to export (e.g., "A1:E10"). If null, exports all used range.

options JsonOptions

JSON 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

worksheet Worksheet

The worksheet to import data into.

filePath string

Path to the CSV file.

startCellReference string

Starting cell reference (e.g., "A1").

options CsvOptions

CSV 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

worksheet Worksheet

The worksheet to import data into.

filePath string

Path to the JSON file.

startCellReference string

Starting cell reference (e.g., "A1").

options JsonOptions

JSON 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

worksheet Worksheet

The worksheet to import data into.

jsonString string

The JSON string containing the data.

startCellReference string

Starting cell reference (e.g., "A1").

options JsonOptions

JSON import options. If null, default options will be used.

Returns

int

The number of rows imported.