Hi,
There is something weird going on here. FlexCel doesn't do any replacement of the character you specify: If you say a "," it will use a "," no matter what your locale is. You might be creating files for a customer in a different country, so it makes no sense that we automatically use your machine format settings.
If you wanted to use them, you could write
var listSeparatorStr = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
if (listSeparatorStr == null || listSeparatorStr.Length != 1) throw new Exception("Unsupported list separator."); var listSeparator = listSeparatorStr[0];
xls.Save("Export.csv", TFileFormats.Text, listSeparator);
But since you aren't, I don't know what could be going on. I've rechecked the code, and whatever you pass to the delimiter in xls.Save is directly saved to the file (no smart changing of formats behind the scene). I also tried this code:
static char ListSeparator()
{
var listSeparatorStr = CultureInfo.CurrentCulture.TextInfo.ListSeparator;
if (listSeparatorStr == null || listSeparatorStr.Length != 1)
throw new Exception("Unsupported list separator.");
return listSeparatorStr[0];
}
void main()
{
var xlso = new XlsFile(@"r:\test.xlsx", true);
xlso.Save("r:\\Export.comma.machineculture.csv", TFileFormats.Text, ',');
xlso.Save("r:\\Export.semicolon.machineculture.csv", TFileFormats.Text, ';');
xlso.Save("r:\\Export.listsep.machineculture.csv", TFileFormats.Text, ListSeparator());
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE");
xlso.Save("r:\\Export.comma.de-DEculture.csv", TFileFormats.Text, ',');
xlso.Save("r:\\Export.semicolon.de-DEculture.csv", TFileFormats.Text, ';');
xlso.Save("r:\\Export.listsep.de-DEculture.csv", TFileFormats.Text, ListSeparator());
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("hi-IN");
xlso.Save("r:\\Export.comma.hi-INculture.csv", TFileFormats.Text, ',');
xlso.Save("r:\\Export.semicolon.hi-INculture.csv", TFileFormats.Text, ';');
xlso.Save("r:\\Export.listsep.hi-INculture.csv", TFileFormats.Text, ListSeparator());
}
And all the files were created in their correct format. Specifically, Export.comma.hi-INculture.csv, Export.comma.de-DEculture.csv and Export.comma.machineculture.csv all use commas.
Can you reproduce your problem with the test code here? Or do you have an idea of how I could reproduce it?
Ps: You might have already seen it, but whenever someone asks for CSV, I recommend reading Understanding CSV files. | FlexCel Studio for the .NET Framework documentation