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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to obtain csv out of filtered data?

Thread ID:

Created:

Updated:

Platform:

Replies:

126453 Oct 16,2016 07:22 AM UTC Oct 20,2016 01:48 PM UTC UWP 3
loading
Tags: XlsIO
Sentaroh Ishida
Asked On October 16, 2016 07:22 AM UTC

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!



Sridhar Sukumar [Syncfusion]
Replied On 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]); 
        i++; 
    } 
} 
CSVSheet.SaveAs("CSVData.csv", ","); 
 
Regards, 
Sridhar S. 


Sentaroh Ishida
Replied On October 19, 2016 07:09 AM UTC

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

Sridhar Sukumar [Syncfusion]
Replied On 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. 

 

Regards, 

Sridhar S. 

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;