C
captain hermdog
Hi all,
As you may have guess, I'm working with the Excel object in C#. I am
trying to open a comma-delimited (.csv) file in Excel so I can easily
transfer the data to another Excel WorkBook.
I have read many examples online which all reference the
WorkBook.OpenText method -- for example:
myWorkBook = myApplication.WorkBooks.OpenText(blah, blah, ...);
Here is the problem, When I try to implement that code the OpenText
method returns void - thus rendering a compiler error.
COM Library
-----------
Microsoft Excel 11.0 Object Library
Code
----
rdWorkBook = rdApp.Workbooks.OpenText(
rawDataFile,
Type.Missing,
1,
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
Type.Missing,
Type.Missing,
Type.Missing,
true,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing);
---------------------
So, in order to work past this issue I used the WorkBook.Open method.
I can open the .csv file ok, however it is not recognizing the comma
delimited notation - so it essentially opens the file as a text file
rather than an Excel file (if you know what I mean).
Here is my code:
myWorkBook = myApp.Workbooks.Open(
rawDataFile,
0,
true,
5,
"",
"",
true,
Excel.XlPlatform.xlWindows,
",",
false,
false,
0,
true,
false,
false);
---------------------
Anyhow, does anyone know what's up? Is there a better way?
Thanks in advance!
Jes
As you may have guess, I'm working with the Excel object in C#. I am
trying to open a comma-delimited (.csv) file in Excel so I can easily
transfer the data to another Excel WorkBook.
I have read many examples online which all reference the
WorkBook.OpenText method -- for example:
myWorkBook = myApplication.WorkBooks.OpenText(blah, blah, ...);
Here is the problem, When I try to implement that code the OpenText
method returns void - thus rendering a compiler error.
COM Library
-----------
Microsoft Excel 11.0 Object Library
Code
----
rdWorkBook = rdApp.Workbooks.OpenText(
rawDataFile,
Type.Missing,
1,
Excel.XlTextParsingType.xlDelimited,
Excel.XlTextQualifier.xlTextQualifierDoubleQuote,
Type.Missing,
Type.Missing,
Type.Missing,
true,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing);
---------------------
So, in order to work past this issue I used the WorkBook.Open method.
I can open the .csv file ok, however it is not recognizing the comma
delimited notation - so it essentially opens the file as a text file
rather than an Excel file (if you know what I mean).
Here is my code:
myWorkBook = myApp.Workbooks.Open(
rawDataFile,
0,
true,
5,
"",
"",
true,
Excel.XlPlatform.xlWindows,
",",
false,
false,
0,
true,
false,
false);
---------------------
Anyhow, does anyone know what's up? Is there a better way?
Thanks in advance!
Jes