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

Free Support Forum - aspose.com

How to import a excel - XLS to a DataSet?

Hi,

What is the easiest way to import a excel file to a dataset?

Thanks,

JB

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

Thank you for considering Aspose.

You can use ExportDataTable() and ExportDataTableAsString() methods to Export the data from your worksheet to a DataTable and then you can add that DataTable to your DataSet. Please see the following Sample Code in this regard,

Sample Code:

Workbook workbook = new Workbook();
workbook.Open(@"d:\test\MyFile.xls");
Worksheet worksheet = workbook.Worksheets[0];
DataTable dataTable = new DataTable();
dataTable = worksheet.Cells.ExportDataTable(0, 0, worksheet.Cells.MaxRow + 1, worksheet.Cells.MaxColumn + 1);

dataTable.AcceptChanges();

DataSet ds = new DataSet();

ds.Tables.Add(dataTable);

Please see the following Links which will help you understand the different Export methods provided in Aspose.Cells.

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/exporting-data-from-worksheets.html

Thank You & Best Regards,

Hi,

We are not considering it, we bought it :slight_smile: it is a great tool

Thanks for the example.