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

Export to various Formats

Thread ID:





4414 May 12,2003 09:09 AM UTC May 11,2004 11:00 PM UTC WinForms 4
Tags: GridControl
Asked On May 12, 2003 09:09 AM UTC

Is it possible to export the contents of the grid to few formats like Excel, CSV and TXT. One way is that I parse thru the grid and write the file in desired format and save it on the disk but is there any inbuilt feature that provides such support. Regards Ashish

Administrator [Syncfusion]
Replied On May 12, 2003 09:16 AM UTC

Currently, you can import/export data in delimited text files such as CSV or TSV. You can find code snippets in the 3rd or 4th entry of this forum thread. http://www.syncfusion.com/forums/message.asp?MessageID=3292 We will support reading and writing of BIFF files(excel) in an upcoming release. I do not know a projected release date yet force this support.

Replied On May 11, 2004 06:40 PM UTC

That was a very nice example of CSV exporting, but unfortunately it is not complete enough for real use. It fails to achieve my goals on two parts, making it unlikely to write and read what it has written: 1) When a cell contains the cell delimeter character (comma for U.S.), the entire cell should be surrounded by double quotes, and (related) 2) If cell contents contain double quotes, then double quotes need to surround the cell contents, and all pre-existing double quotes doubled. Thanks for the attempt. -Greg

Administrator [Syncfusion]
Replied On May 11, 2004 10:17 PM UTC

If you own the source code, you can copy and modify the code used in our CopyTextToBuffer and PasteTextFromBuffer methods to use the extra quotes you need for your data. Or, maybe another option would be to use a different delimiter that avoids the problem with the comma, (maybe a tab). this.gridControl1.Model.TextDataExchange.ExportTabDelim = "\t"; this.gridControl1.Model.TextDataExchange.ImportTabDelim = "\t";

Replied On May 11, 2004 11:00 PM UTC

Thanks, Clay. For anyone wanting logic to format cell text for CSV output that works for internal commas and quotes: for each row in range clear StringBuilder line for each column in range get string celltext // replace quotes with doubled quotes celltext = cell.Text.Replace("\"","\"\""); // if any quotes or comma (separator), // then start and end with a quote if (-1 != celltext.IndexOfAny(",\"".ToCharArray())) celltext = "\"" + celltext + "\""; line.Append(celltext); // append that cell line.Append(",");// column separator (comma or semicolon) } // each column // compress out trailing commas str = line.ToString(); str = str.TrimEnd(","); WriteLine(str); // write that row } // each row Worked for me. Cheers, Greg


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon