繁体   English   中英

Microsoft.Office.Interop.Excel-* .csv文件打开

[英]Microsoft.Office.Interop.Excel - *.csv file opening

我创建了*.csv文件,但是当我使用Microsoft.Office.Interop.Excel打开它时,由于忽略了分隔符,因此格式设置错误;

excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
                    false,5,"","", false, Excel.XlPlatform.xlWindows, "", true,
                    false, 0, true, false, false);

我应该更改Workbooks.Open哪个参数?

谢谢你的建议。

定界符参数,这是第9个。 ""更改为";" 有关更多信息,请检查msdn

这应该是这样的:

excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
                false,5,"","", false, Excel.XlPlatform.xlWindows, ";", true,
                false, 0, true, false, false);

Interop Excel具有打开CSV文件的格式。

excel_app.Workbooks.Open(
        txtFile.Text,               // Filename
        Type.Missing,
        Type.Missing,
        Excel.XlFileFormat.xlCSV,   // Format
        Type.Missing,
        Type.Missing,
        Type.Missing,
        Type.Missing,
        txtDelimiter.Text,          // Delimiter
        Type.Missing,
        Type.Missing,
        Type.Missing,
        Type.Missing,
        Type.Missing,
        Type.Missing);

在所有情况下,格式和定界符组合都应该起作用。

资源

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM