Named range to data table

I have a spreadsheet that has a named range that I would like to import and turn into a data table. For example:

Id First Last
1 John Hennesey
2 Chad Huelsman

The named range (“Names”) encompases the first row (Id, First, Last) to the last row (2, Chad, Huelsman).

I am able to get the data using the WorkbookDesigner.Worksheets.GetRangeByName(“Names”) method, but when I try WorkbookDesigner.Worksheets.GetRangeByNames(“Names”).ExportDataTable() it doesn’t recognize the first row is column names.

I don’t see any kind of a parameter to say first row is column names - is there a better way?

p.s. I am using the .net version.

@JohnHennesey,

Thanks for your query.

We were able to understand the requirement but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46252 - Argument to skip row/rows as data headers in ExportDataTable()

@JohnHennesey,

This is to inform you that the issue “CELLSNET-46252” has been resolved now. After implementing QA and adding other extensions and fixes, we will provide a fixed version soon.

@JohnHennesey,

Please find attached our latest version/fix: Aspose.Cells for .NET v18.7.4 (.NET 2.0 and .NET 4.0)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells18.7.4 For .Net2_AuthenticodeSigned.Zip (3.8 MB)
Aspose.Cells18.7.4 For .Net4.0.Zip (3.8 MB)

Wow, that was fast! Thank you, I will take a look at it as soon as I can. We are nearing the end of our sprint and it’s too late to upgrade our Cells version [we are a few behind]. I will upgrade at the start of the next sprint and get back to you.

Thanks again!
John

@JohnHennesey,

Please take your time to test the fix. Feel free to write us back if you have further queries or issue, we will be happy to assist you soon.

The issues you have found earlier (filed as CELLSNET-46252) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

@JohnHennesey,

Please use below code snippet on your side and then let us know your feedback.

Workbook source = new Workbook(Constants.sourcePath + "CELLSNET46252.xlsx");
WorkbookDesigner designer = new WorkbookDesigner(source);
var range = designer.Workbook.Worksheets.GetRangeByName("Names");
ExportTableOptions options = new ExportTableOptions();
options.ExportColumnName = true;
var dataTable = designer.Workbook.Worksheets.GetRangeByName("Names").ExportDataTable(options);

Thank you - because of time constraints I had to roll my own with the older version. Will the newer version appropriately recognize the data types from Excel? Or will everything be double, datetime and varchar(max)?

@JohnHennesey,

Latest versions are enhanced and updated versions so things usually work as expected. In case you notice any issue then share sample data and code snippet with us.

@JohnHennesey,

Moreover, we only check the data type of the first row as the data type of the data column.