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.
ADAdministrator Syncfusion Team May 12, 2003 05:16 AM
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.
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.
GRGregMay 11, 2004 02:40 PM
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.
ADAdministrator Syncfusion Team May 11, 2004 06:17 PM
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";
GRGregMay 11, 2004 07:00 PM
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.