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

Free Support Forum - aspose.com

ImportDataTable problem


I tried to import the data from a datatable using a formatted xlsx file (designerFile - having set borders and colors for cells), but the format settings are lost after saving the file.
If using a xls file, it works just fine.

Here is the code I use:
Dim fstream As System.IO.FileStream
fstream = New System.IO.FileStream(designerFile, IO.FileMode.Open)
workbook.Open(fstream, FileFormatType.Excel2007Xlsx)
Dim worksheet1 As Worksheet = workbook.Worksheets(0)
worksheet1.Cells.ImportDataTable(dataTable, False, 1, 0, True)
workbook.Save(fileName, FileFormatType.Excel2007Xlsx)

I am using Aspose.Cells version

Thank you very much!

Hi Dariana,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

I tested your scenario with the attached latest version of Aspose.Cells and was unable to reproduce the issue. Please try the attached latest version and if you still face any problem, please share your template file here and we will check it soon.

Thank You & Best Regards,


Thank you for your quick response!

I have tried the latest version but I still have the same problem.
After importing from datatable, the conditional format rules set in the template are lost.
Attached is the template I used.

Thank you very much!

Hi Dariana,

Please try to change your line of code to:

worksheet1.Cells.ImportDataTable(dataTable, False, 1, 0, False)

The last boolean parameter should be False, so that no extra rows should be inserted based on the data in the data table.

Thank you.

Thank you very much!

Now it works.

Best regards,