We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to obtain csv out of filtered data?

Hello Support,
I successfully filter an Excel data using IAutoFilter.  I need filtered data as csv.
Please instruct me how to get csv out of filtered data.
Thanks a lot!

3 Replies

SS Sridhar Sukumar Syncfusion Team October 17, 2016 11:16 AM UTC

Hi Sentaroh, 
Thank you for contacting Syncfusion support. 
As per MS Excel behavior, the filtered data cannot be converted as CSV, because all the hidden rows and columns are converted while converting worksheet to CSV. However, you can achieve this through a workaround by copying the filtered data to another worksheet. We have prepared a workaround sample for your reference which can be downloaded from the following link 
Kindly refer the following code snippet of this workaround. 
Code snippet: 
IWorksheet CSVSheet = workbook.Worksheets.Create("CSVSheet"); 
int i = 1; 
foreach (IRange row in filterRange.Rows) 
    if (row.RowHeight != 0) 
        row.CopyTo(CSVSheet[i, row.Column, i, row.LastColumn]); 
CSVSheet.SaveAs("CSVData.csv", ","); 
Sridhar S. 

SI Sentaroh Ishida October 19, 2016 07:09 AM UTC

Thank you for your response. It's been very helpful.

SS Sridhar Sukumar Syncfusion Team October 20, 2016 01:48 PM UTC

Hi Sentaroh, 


Thank you for updating us. 


We are glad that issue is resolved at your end. Please let us know if you need any further assistance. 



Sridhar S. 

SIGN IN To post a reply.
Live Chat Icon For mobile
Up arrow icon