I have trouble sorting data in an Excel file.
My file has multiple columns and I want to sort the data based on one column.
I use code that can be found here :
https://www.e-iceblue.com/Tutorials/Spi ... -data.html
So far i have tried :
- Code: Select all
workbook.DataSorter.Sort(worksheet["A:A"]);
- Code: Select all
workbook.DataSorter.Sort(worksheet.Columns[0]);
But i keep having a corrupted output file.
With this line fisrt column is sorted but the sort is not extended to the other coumns :
- Code: Select all
workbook.DataSorter.Sort(worksheet["A1:A6"]);
Can you please provide me code to sort all the data based on one column ?
Thnak for your advice.
Edit : With this code it seems that can sort all the columns but the first row is not sorted :
- Code: Select all
workbook.DataSorter.Sort(worksheet.Range[1, 1, worksheet.Rows.Count(), worksheet.Columns.Count()]);
Is it the right way to do it ? How can i sort the first row also ?