[]
Import all the data of the specified source of the file.
public static object[,] ImportData(string fileName, string sourceName)
Public Shared Function ImportData(fileName As String, sourceName As String) As Object(,)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path and name for the file. |
| string | sourceName | The name of the data source. The source name could be: |
| Type | Description |
|---|---|
| object[,] | An array for the data. |
Import the data of a specified range from a file.
public static object[,] ImportData(string fileName, string worksheetName, int row, int column, int rowCount, int columnCount)
Public Shared Function ImportData(fileName As String, worksheetName As String, row As Integer, column As Integer, rowCount As Integer, columnCount As Integer) As Object(,)
| Type | Name | Description |
|---|---|---|
| string | fileName | The path and name for the file. |
| string | worksheetName | The name of the worksheet. |
| int | row | The first row of the range. |
| int | column | The first column of the range. |
| int | rowCount | The count of the rows. |
| int | columnCount | The count of the columns. |
| Type | Description |
|---|---|
| object[,] | An array for the data. |
Import all the data of the specified source of the file.
public static object[,] ImportData(Stream fileStream, string sourceName)
Public Shared Function ImportData(fileStream As Stream, sourceName As String) As Object(,)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The fileStream of a workbook. |
| string | sourceName | The name of the data source. The source name could be: |
| Type | Description |
|---|---|
| object[,] | An array for the data. |
Imports data from a specified range in a workbook stream.
This method reads the range identified by worksheetName, row,
column, rowCount, and columnCount from the workbook data
in fileStream.
If the imported range contains a single cell value, the result is still returned as a two-dimensional array with one row and one column.
public static object[,] ImportData(Stream fileStream, string worksheetName, int row, int column, int rowCount, int columnCount)
Public Shared Function ImportData(fileStream As Stream, worksheetName As String, row As Integer, column As Integer, rowCount As Integer, columnCount As Integer) As Object(,)
| Type | Name | Description |
|---|---|---|
| Stream | fileStream | The input stream that contains workbook data. Must not be |
| string | worksheetName | The name of the worksheet that contains the range to import. |
| int | row | The zero-based row index of the first row in the range. |
| int | column | The zero-based column index of the first column in the range. |
| int | rowCount | The number of rows to import. |
| int | columnCount | The number of columns to import. |
| Type | Description |
|---|---|
| object[,] | A two-dimensional array that contains the imported range data. |
worksheet.Range["A1:B3"].Value = new object[,] {
{"Name", "Value"},
{"Test", 100},
{"Hello", 200}
};
MemoryStream outputStream = new MemoryStream();
workbook.Save(outputStream, SaveFileFormat.Xlsx);
object[,] data = Workbook.ImportData(
new MemoryStream(outputStream.ToArray()), "Sheet1", 0, 0, 3, 2);
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the specified worksheet does not exist. |