Opening Microsoft.Office.Interop.Excel - * .csv

I create a *.csv file, but when I open it using Microsoft.Office.Interop.Excel , its formatting is incorrect due to ignoring the delimiter ; .

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

What parameter should Workbooks.Open be changed?

Thanks for your suggestions.

+1
source share
3 answers

The separator argument, which is the ninth. Change "" to ";" . For more information check msdn

+1
source

Here's how it should be:

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

Interop Excel has a format for opening 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); 

The Format and Delimiter layout should work in all cases.

A source

0
source

Source: https://habr.com/ru/post/1335005/


All Articles