We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ImportDataTable overwriting data

I apologise if this has been asked before. When importing a dataset using ImportDataTable, for some reason the cells to the right of where the data is placed are overwritten with a blank.

For instance, if a dataset consisting of two columns is imported at position A1 (therefore columns 1 and 2 are populated), cells 3+ are being overwritten with blanks.

Is anyone aware of a way to stop this?


Thanks for considering Aspose.

Kindly use Cells.ImportDataTable (dataTable, isFieldNameShown, firstRow, firstColumn, insertRows) overloaded version of the method and specify false to the last parameter.

Sample code:

OleDbConnection con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=d:\\test\\Northwind.mdb");
OleDbCommand cmd = new OleDbCommand("Select CustomerID, City from Customers where city='London'",con);
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();

Workbook wb = new Workbook();
Worksheet sheet1 = wb.Worksheets[0];
Cells cells = sheet1.Cells;
//Import the datatable

Attached are the input and output files for your reference.

Thank you.