I create *.csv
file, but when I open it using Microsoft.Office.Interop.Excel
, it's formatting is wrong, because of ignoring the delimiter ;
.
excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false,5,"","", false, Excel.XlPlatform.xlWindows, "", true,
false, 0, true, false, false);
Which parameter of Workbooks.Open
should I change?
Thank you for your suggestions.
The delimiter argument, which is the 9th one. Change ""
to ";"
. For more info, check msdn
This is how it should be:
excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false,5,"","", false, Excel.XlPlatform.xlWindows, ";", true,
false, 0, true, false, false);
Interop Excel has a format to open CSV files.
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);
Format and Delimiter combo should be working in all cases.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.