

Using (var stream = new FileStream(excelFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) Public static bool SaveAsCsv(string excelFilePath, string destinationCsvFilePath) 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) static void ConvertExcelToCsv(string excelFilePath, string csvOutputFile, int worksheetNumber = 1) \"", data)) Ĭheckout the. You can overload the method if you need to support earlier versions. It's 4.0+ framework only, but that's mostly because of the optional worksheetNumber parameter.

Remember to add your own error handling - this mostly assumes that things work for the sake of brevity. Microsoft Office, LibreOffice, Kingsoft Office, Google Docs.Here's a C# method to do this. CSV implementations may not handle such field data or use quotation marks to surround the field. The basic idea of separating fields with a comma is clear, but that idea gets complicated when the field data may also contain commas or even embedded line-breaks. Since then, Microsoft has made the Excel binary format specification available to download freely. has created documentation of the Excel format. The comma as a field separator is the source of the name for this file format. Each record consists of one or more fields, separated by commas. In computing, a comma-separated values (CSV) file stores tabular data (numbers and text) in plain text. Excel 2007 uses Office Open XML as its primary file format, an XML-based format that followed after a previous XML-based format called "XML Spreadsheet".

Microsoft Excel, up until 2007 version used a proprietary binary file format called Excel Binary File Format (.XLS) as its primary format.
