簡體   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