Hello,
Hi,
Thanks for your posting and using Aspose.Cells.
I have tested your code with the latest version: Aspose.Cells for .NET v8.7.2.4 and it worked fine. I have also attached the output excel file generated with your code for your reference.
Please use SaveFormat.Xlsx as shown in the red color below in Workbook.Save() method.
VB.NET
Dim excel As New Aspose.Cells.Workbook()
Dim worksheet As Aspose.Cells.Worksheet = excel.Worksheets(0)
Dim cells As Aspose.Cells.Cells = worksheet.Cells
Dim dt As New DataTable(“Products”)
dt.Columns.Add(“Col_ID”, GetType(Int32))
dt.Columns.Add(“Col_Name”, GetType(String))
For x As Integer = 0 To 104550
Dim dr As DataRow = dt.NewRow()
dr(“Col_ID”) = x
dr(“Col_Name”) = “Data” + x.ToString()
dt.Rows.Add(dr)
Next
'cells.ImportDataTable(dt, True, “A1”)
'cells.ImportDataTable(dt, True, 0, 0, True)
cells.ImportDataTable(dt, True, 0, 0)
excel.Save(“out_rowstest.xlsx”, SaveFormat.Xlsx)
Thanks a lot for the quick response. The code does work if I use the latest version of Apsose Cells. But our company holds the license for ver 4.4 as of now. Do you know if there is anyway of getting this to work with that version?
Hi,
Thanks for your help.
Hi,
Thanks for using Aspose.Cells.
Will you please give a try to your code with the following modification with your older version and see if it works for you.
Changes are highlighted in red color.
VB.NET
Public Sub TestAspose()
Dim excel As New Aspose.Cells.Workbook(FileFormatType.Xlsx)
Dim worksheet As Aspose.Cells.Worksheet = excel.Worksheets(0)
Dim cells As Aspose.Cells.Cells = worksheet.Cells
Dim dt As New DataTable(“Products”)
dt.Columns.Add(“Col_ID”, GetType(Int32))
dt.Columns.Add(“Col_Name”, GetType(String))
For x As Integer = 0 To 104550
Dim dr As DataRow = dt.NewRow()
dr(“Col_ID”) = x
dr(“Col_Name”) = “Data” + x.ToString()
dt.Rows.Add(dr)
Next
'cells.ImportDataTable(dt, True, “A1”)
'cells.ImportDataTable(dt, True, 0, 0, True)
cells.ImportDataTable(dt, True, 0, 0)
excel.Save(“C:\test\out_rowstest.xlsx”, Aspose.Cells.FileFormatType.Excel2007Xlsx)
End Sub