Free Support Forum - aspose.com

ImportFromDataReader not inserting rows

Aspose,

I am trying to use the ImportFromDataReader function. It does import the data, but is not inserting a row for each new line of data in my template.

I am using the code as follows:

intTest = cells1.ImportFromDataReader(rs, 13, 1, True)

Thanks.

When using ImportFromDataReader function, extra rows can be added to fit the data. I test with the following sample code and don't find any problem.

OleDbCommand oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
OleDbConnection oleDbConnection1 = new System.Data.OleDb.OleDbConnection();

oleDbConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + "d:\\Northwind.mdb";
oleDbSelectCommand1.CommandText = "SELECT CategoryID, CategoryName, Description, Picture FROM Categories";
oleDbSelectCommand1.Connection = oleDbConnection1;


Excel excel = new Excel();

excel.Open("d:\\test\\template.xls");

oleDbConnection1.Open();
OleDbDataReader reader = oleDbSelectCommand1.ExecuteReader();
excel.Worksheets[0].Cells.ImportFromDataReader(reader, 13, 1, true);
reader.Close();
oleDbConnection1.Close();
excel.Save("d:\\test\\abc.xls");

Which version of Aspose.Cells are you using? Attached is my template file.

And this is the output file.