LinqToExcel
LinqToExcel copied to clipboard
Add method to get worksheet names in the same order they appear in excel (for review/comments only)
This provides a method GetWorksheetNamesOrdered() to return the worksheet names in the same order as they would appear in excel.
Works by extracting the contents of the excel file, finding the XML file containing the worksheet names and parsing the XML contents of that file. I found the necessary information about the xlsx file format from this stack overflow answer: http://stackoverflow.com/a/19930386/2617732
Using the test excel files, the new method works fine with the xlsm and xlsx files. It also works with csv by returning an empty list. It doesn't work for the xls and xlsb files as they have a different format. If anybody knows where the same worksheet information could be found within an xls file, please comment on here.
Notes:
- Requires the project to use v4.5 .net framework
- Requires a reference to System.IO.Compression
- This doesn't have any dependencies within this project so even if its unsuitable for merging, its still potentially useful as a standalone function i.e. to offer a workaround to people that need the ordering of worksheets.
Thanks for the pull request @RyanDansie!
I would like to keep the .Net framework dependency at v3.5 if possible, so do you know the reason to require v4.5? I might be convinced to upgrade the dependency to 4.5, but I want to make sure it's worth while.
.net 4.5 is for the one line unzip of the xlsx file (ZipArchive class). I'm sure I could change that part to use DeflateStream.
If it's not too hard to use DeflateStream, that would be great. If it requires more work, then I could go ahead and create version 2.0 of LinqToExcel and make it depend on .Net 4.5