Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Description

Excerpt

Imports data from a two-dimensional array of objects to the specified Area . The new data will overwrite values and formulas in the target worksheet cells, but existing formatting will be preserved.

Signature
C#C#
Wiki Markup
{description}
{excerpt}Imports data from a two\-dimensional array of objects to the specified [Area|Area] . The new data will  +overwrite+  values and formulas in the target worksheet cells, but existing formatting will be preserved.{excerpt}
{signature:C#}
 public Area ImportData(System.Object[][] data, System.String[] columnNames, DataImportProperties properties)
Signature
{signature}{signature:vb.net
vb.net
}
Public Function ImportData(ByVal data As Object()(), ByVal columnNames As String(), ByVal properties As DataImportProperties) As Area
Parameters
Param
datadataA two-dimensional array of values to import to the worksheet. By default, the first dimension corresponds to row and the second to column (that is, Object[row][column]).
Thus, an array of data {
{signature}
{parameters}
{param:data}A two\-dimensional array of values to import to the worksheet. By default, the first dimension corresponds to row and the second to column \(that is, Object\[row\]\[column\]\).
Thus, an array of data  \{ \{"A","X"\},\{"B","Y"\},\{"C","Z"\} \}  would be inserted into the worksheet as:

|A
|X
|
|B
|Y
|
|C
|Z
|

If you enable [DataImportProperties.Transpose|DataImportProperties.Transpose] , the format will be \[row\]\[column\], so:


\{ \{"A","B","C"\},\{"X","Y","Z"\} \}  would be inserted into the worksheet as:\|A|X|

|B
|Y
|
|C
|Z
Param
columnNamescolumnNames

An array of column names for the imported data. columnNames and the column dimension of data must contain the same number of elements.

Param
propertiesproperties

A DataImportProperties object that contains a set of properties to use when importing data to the area.

Returns

An Area object representing the set of cells populated with the imported values.

|
{param}
{param:columnNames}An array of column names for the imported data. {{columnNames}} and the column dimension of {{data}} must contain the same number of elements.{param}
{param:properties}A [DataImportProperties|DataImportProperties] object that contains a set of properties to use when importing data to the area.{param}
{returns}An {{Area}} object representing the set of cells populated with the imported values.{returns}
{example}{code:csharp|title=C#}

DataImportProperties importProps = oWorkbook.CreateDataImportProperties();
importProps.Truncate = true;
Area importedArea = a.ImportData(dataArray, fieldNames, importProps);
{code}
{code:vbnet|title=vb.net
}

Dim importProps As DataImportProperties = wb.CreateDataImportProperties()
importProps.Truncate = True
Dim importedArea As Area = a.ImportData(dataArray, fieldNames, importProps)
Example
Code Block
csharpcsharp
titleC#
Code Block
vbnetvbnettitle

...

{code}

{example}
{scrollbar}