Hello,
Thanks for your feedback.
In the previous project I provided, I used the code “filters.Range = sht.Range[1, 1, sht.LastRow, sht.LastColumn]” to set the filter range, which includes many empty rows (the value of sht.LastRow is 65536). When using the free version, after executing the "filters.Filter() method" to filter the data, some empty rows are incorrectly filtered out (as shown below), which is the main reason for the slow speed.
- screenshot-1.png (30.12 KiB) Viewed 183 times
To avoid this issue, I used the following code to find the last non-empty row, and then changed the filter range to “filters.Range = sht.Range[1, 1, lastRow, sht.LastColumn]”. To help you better understand the changes, I have attached the commented code for your reference.
- Code: Select all
Worksheet sheet = wbk.Worksheets[0];
//Get the first columns
List<CellRange> crs = sheet.Columns[0].CellList;
for (int i = crs.Count - 1; i > 0; i--)
{
//Get the last non-empty row
if (!string.IsNullOrEmpty(crs[i].DisplayedText))
{
lastRow = i + 1;
break;
}
}
Sincerely,
Elena
E-iceblue support team