ImportDataTable problem

Hello,


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)
fstream.Dispose()
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 4.8.2.0.

Thank you very much!
Dariana

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,

Hi,


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!
Dariana

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,
Dariana