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.

Tue Nov 17, 2015 5:33 pm

My small tool is kind of complicated to explain. But it is better to get to the point.

How can I insert a single row, cell or column from a DataTable? I am not refering in DataColumn or DataRow, but single data from a DataTable.

Can it be possible?

aomcastor
 
Posts: 10
Joined: Sun Nov 01, 2015 4:05 am

Wed Nov 18, 2015 2:07 am

Hi,

Thanks for your inquiry.
Sorry that I don't understand your problem well. Do you want to insert a single row, cell or column from a DataTable into an excel file?
I am not refering in DataColumn or DataRow, but single data from a DataTable.

Sorry that I am not clear that, please provide me an example.

Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Wed Nov 18, 2015 3:08 am

Sorry, I meant to use InsertDataTable instead of InsertDataColumn for the same porpuse.
Also, if that works to insert rows, cells and ranges. Can it be possible?

aomcastor
 
Posts: 10
Joined: Sun Nov 01, 2015 4:05 am

Wed Nov 18, 2015 8:10 am

Hi,

The method
Code: Select all
InsertDataTable(DataTable dataTable, bool columnHeaders, int firstRow, int firstColumn, int maxRows, int maxColumns); 
can do it, please try it.
Examples:
//Add the first row of dataTable to sheet
sheet.InsertDataTable(dataTable, false, 1, 1, 1,dataTable.Columns.Count);
//Add the first cell of dataTable to sheet
sheet.InsertDataTable(dataTable, false, 1, 1, 1,1);
//Add the data from row1column1 to row1column3 of dataTable to sheet
sheet.InsertDataTable(dataTable, false, 1, 1, 1,3);

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Thu Nov 19, 2015 8:10 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Sun Nov 22, 2015 3:01 am

Well, honestly I solved the problem of my code by myself with another method. My problem happened on the iteration over the datatable and a Mysql connection, which it had duplicated the data I was asking for.

Sorry, thanks for the quick response but I did not use it... yet.

Although I congrats you for your service.

aomcastor
 
Posts: 10
Joined: Sun Nov 01, 2015 4:05 am

Mon Nov 23, 2015 1:38 am

Hi,

Thanks for your feedback.
I am glad that your issue has been resolved.
Welcome to feel free to write to us again for further problems. We are here to help you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS