Syncfusion.XlsIO.Base
Example 


IEnumerable objects with desired data.
First row from where the data should be imported.
First column from where the data should be imported.
TRUE if class properties names must be imported. FALSE otherwise.

ImportData Method (IWorksheet)

Imports data from class objects into a worksheet with specified row and column.
Syntax
'Declaration
 
Function ImportData( _
   ByVal arrObject As IEnumerable, _
   ByVal firstRow As Integer, _
   ByVal firstColumn As Integer, _
   ByVal includeHeader As Boolean _
) As Integer
'Usage
 
Dim instance As IWorksheet
Dim arrObject As IEnumerable
Dim firstRow As Integer
Dim firstColumn As Integer
Dim includeHeader As Boolean
Dim value As Integer
 
value = instance.ImportData(arrObject, firstRow, firstColumn, includeHeader)

Parameters

arrObject
IEnumerable objects with desired data.
firstRow
First row from where the data should be imported.
firstColumn
First column from where the data should be imported.
includeHeader
TRUE if class properties names must be imported. FALSE otherwise.

Return Value

Number of imported rows.
Remarks
To know more about ImportData refer this link
Example
The following code illustrates how to Imports data from class objects into a worksheet with the specified row and column.
using Syncfusion.XlsIO;
using System.Collections.Generic;
             
class Example
{
  static void Main()
  {
    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    application.DefaultVersion = ExcelVersion.Excel2013;
    IWorkbook workbook = application.Workbooks.Create(1);
    IWorksheet worksheet = workbook.Worksheets[0];
    
    //The list of data is get from GetSalesReports method. Here GetSalesReports and Report are sample method and sample class.
    IList<Report> reports = GetSalesReports();
            
    //Import the data to worksheet
    worksheet.ImportData(reports, 2, 1, false);
            
    workbook.SaveAs("ImportFromDT.xlsx");
    workbook.Close();
    excelEngine.Dispose();
  }
  
  public static List<Report> GetSalesReports()
  {
   List<Report> reports = new List<Report>();
   reports.Add(new Report("Andy Bernard", "45000", "58000"));
   reports.Add(new Report("Jim Halpert", "34000", "65000"));
   reports.Add(new Report("Karen Fillippelli", "75000", "64000"));
   reports.Add(new Report("Phyllis Lapin", "56500", "33600" ));
   reports.Add(new Report("Stanley Hudson", "46500", "52000"));
   return reports;
  }
}
public class Report   
{
  public string SalesPerson { get; set; }
  public string SalesJanJun { get; set; }
  public string SalesJulDec { get; set; }
            
  public Report(string name, string janToJun, string julToDec)
  {
    SalesPerson = name;
    SalesJanJun = janToJun;
    SalesJulDec = julToDec;
  }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 16.4460.0.40

See Also