I want to copy all rows and columns from a worksheet into a datatable instead of specifying how many rows and how many columns. How can I do that? (or) Is there a way to find out rowcount and columncount in a worksheet.
Below is the code:
Dim workbook As Workbook = New Workbook()
Dim fstream As FileStream = New FileStream("C:\\Output1.xls", FileMode.Open)
workbook.Open(fstream)
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim dTable As DataTable = New DataTable()
dTable = worksheet.Cells.ExportDataTable(0, 0, ?, ?, True)
Hi,
Thank you for considering Aspose.
Well, you can use Cells.MaxDataColumn and Cells.MaxDataRow to get the maximum index of rows and columns in a worksheet. Please see the following Updated code as per your need,
Dim workbook As Workbook = New Workbook()
Dim fstream As FileStream = New FileStream("C:\\Output1.xls", FileMode.Open)
workbook.Open(fstream)
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim dTable As DataTable = New DataTable()
dTable = worksheet.Cells.ExportDataTable(0, 0, worksheet.Cells.MaxDataRow, worksheet.Cells.MaxDataColumn, True)
Thank You & Best Regards,