
Export Excel to CSV keeping special characters.All this is possible because a CSV document is plain text and an average user or even a novice can easily understand it without any learning curve. The CSV format allows users to glance at the file and immediately diagnose the problems with data, change the delimiter, text qualifier, etc. Its popularity and viability are due to the fact that CSV files are supported by many different applications and systems at least as an alternative import/export format. The methods work for all versions of Excel, from 365 to 2007.Ĭomma separated values ( CSV) is a widely used format that stores tabular data (numbers and text) as plain text. It seems to me, you probably started here, and you didn't do any preliminary work yourself.The article explorers quick and efficient ways to export data from Excel to CSV keeping all special characters and foreign symbols intact. If you get stuck, or if you have a very specific question, this site is a great place to post your question(s). That's the best way to learn how to do technical things. Actually, for something generic like this, you should always Google for a solution, and try to figure it out yourself. There are several other resources online that can help with this ind of thing. ThisCell.Value2 = "This is a .XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, .XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, Type.Missing, Type.Missing, .XlFileFormat.xlCSVWindows, Type.Missing, Type.Missing, Type.Missing, Type.Missing, .XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing) Range thisCell = (.Range)CurSheet.Cells

Worksheet CurSheet = (.Worksheet)wsSheet Application app = new .ApplicationClass() Or following: public static void SaveAs()

wbWorkbook.SaveAs("c:\yourdesiredFilename.csv", .XlFileFormat.xlCSV) Otherwise, a program could read the file as ASCII and choke on the first non-ASCII character encountered.Ĭheckout the. Using (var writer = new StreamWriter(targetFile,false, Encoding.UTF8))Įncoding.UTF8 ensures the file will be written as UTF8 with a Byte Order Mark that allows all programs to understand this is a UTF8 file instead of ASCII.

No need for a memory buffer, writing directly to a file

Var currentRow = new List(maxColumnNumber) You can write directly to a file instead, if you remove the memory stream and pass the path to the target file in ConvertToCsv : public static void ConvertToCsv(this ExcelPackage package, string targetFile) The code you linked to reads an XLSX sheet and returns the CSV data as a byte buffer through a memory stream.
