如何从Excel中转​​换后删除csv文件中多余的逗号

我有一个将excel文件转换为csv文件的下一个代码:

Microsoft.Office.Interop.Excel.Application reportExcel = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbooks reportBooks = null; Microsoft.Office.Interop.Excel.Workbook reportBook = null; Microsoft.Office.Interop.Excel.Sheets reportSheets = null; Microsoft.Office.Interop.Excel._Worksheet reportSheet = null; try { reportBooks = reportExcel.Workbooks; reportBook = reportBooks.Open(excelFilePath); reportSheets = reportBook.Sheets; reportSheet = reportSheets.get_Item(1); if (File.Exists(csvtempFile)) { File.Delete(csvtempFile); } reportBook.SaveAs(csvtempFile, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSVWindows, Type.Missing, Type.Missing, false, false); ... } catch (Exception ex) { ... } finally { ... } 

我在csv文件中获得下一个文本:

 ... "Some strings","309,145","4,964,398",,"1,194,780",, ... 

正如你看到的数字包含一个额外的逗号。 请告诉我如何删除额外的逗号获取下一个值:

 "Some strings","309,145","4964,398",,"1194,780",, 

看看这篇文章: 设置数据types,如excel列中的数字,文本和date使用Microsoft.Office.Interop.Excel在C#

您可以检查列的types,在每个要更改的范围上设置一个范围,然后在导出之前设置数字格式。

我知道这不是很漂亮,但如果你找不到漂亮的东西,可能会有用。