Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Feb 27, 2020 9:07 pm

Hello
I'am new with spire.xls. I have a excel file that contains 10k or more record. He has columns from 1- 18 and i need read only 5-12 and add it to my database. Can someone hepl me and tell how can i do that?

Ashymonth
 
Posts: 1
Joined: Thu Feb 27, 2020 9:00 pm

Fri Feb 28, 2020 3:37 am

Hello,

Thanks for your inquiry.
The following code demonstrates how to export the data of specified cells to a datatable. If there is any question, please get it back to us.
Code: Select all
    Workbook wb = new Workbook();
    wb.LoadFromFile("test.xlsx");
    Worksheet sheet =  wb.Worksheets[0];
    int startIdx = 5;
    int endIdx = 12;
    //Get the row count
    int rowCount = sheet.LastRow;
    //Get the column count
    int columnCount = endIdx - startIdx + 1;
    //Export the data of specified cells to datatable
    DataTable data = sheet.ExportDataTable(1, startIdx, rowCount, columnCount, false);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Mar 04, 2020 10:08 am

Hello,

Greetings from E-iceblue!
Did you test my code? Could you please give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.XLS