zaratin
asked on
Excel files create and read
Hello everybody,
can somebody tell me how to create an Excel file and read from an Excel file in C#? I'm having problems with this command:
...
Excel.Application xlApp = new Excel.Application(); //works fine
Excel.Workbook xlWb = xlApp.Workbooks.Open(
myExcelFile.xls, true, 5, "", "", true, Excel.XlPlatform.xlWindows ,
"\t", false, false,0, true);
// here I get the message that xlApp.Workbooks.Open method doesn't take 13 Parameters?!
I'm using WinXP Pro and .NET Enterprise Architect
Thanks!!!
can somebody tell me how to create an Excel file and read from an Excel file in C#? I'm having problems with this command:
...
Excel.Application xlApp = new Excel.Application(); //works fine
Excel.Workbook xlWb = xlApp.Workbooks.Open(
myExcelFile.xls, true, 5, "", "", true, Excel.XlPlatform.xlWindows
"\t", false, false,0, true);
// here I get the message that xlApp.Workbooks.Open method doesn't take 13 Parameters?!
I'm using WinXP Pro and .NET Enterprise Architect
Thanks!!!
PS which version of excel do you use?
ASKER
Hello bruintje,
I use Excel 10.0 (Oxffice XP Developer). When trying to save an Excel workbook with:
...
Excel.Application exc=new Excel.Application();
Excel.Workbook wb = exc.Workbooks.Add (Type.Missing );
Excel.Sheets She = (Excel.Sheets)wb.Worksheet s;
Excel.Worksheet Sheet = (Excel.Worksheet)(She.get_ Item(1));
Excel.Range Range = Sheet.get_Range("A1", "A2");
Range.Value2 = "Foo";
wb.SaveAs (myPath,0, "", "",1,0,
Excel.XlSaveAsAccessMode.x lNoChange, true,false , false,
0, false);
wb.Close(false, myPath, false);
I get the following message:
System.Runtime.InteropServ ices.COMEx ception
If I save the workbook with "Save()"- Method (no arguments), it is saved in my profile's MyDocuments folder...
What am I doing wrong?
Thanks
I use Excel 10.0 (Oxffice XP Developer). When trying to save an Excel workbook with:
...
Excel.Application exc=new Excel.Application();
Excel.Workbook wb = exc.Workbooks.Add (Type.Missing );
Excel.Sheets She = (Excel.Sheets)wb.Worksheet
Excel.Worksheet Sheet = (Excel.Worksheet)(She.get_
Excel.Range Range = Sheet.get_Range("A1", "A2");
Range.Value2 = "Foo";
wb.SaveAs (myPath,0, "", "",1,0,
Excel.XlSaveAsAccessMode.x
0, false);
wb.Close(false, myPath, false);
I get the following message:
System.Runtime.InteropServ
If I save the workbook with "Save()"- Method (no arguments), it is saved in my profile's MyDocuments folder...
What am I doing wrong?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sure to change you xlfileformat
ASKER
bruintje, you've got it!
Works great, thanks for your help
Many greetings
Works great, thanks for your help
Many greetings
:) you're welcome, and thanks for the grade
source : http://msdn.microsoft.com/library/default.asp?url=/library/en-us/off2000/html/xlmthOpen.asp
description :
--------------
Syntax
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended,
--------------
chek for all parameters on the link,
you can also see this
-when you open excel
-open the vba editor with ALT+F11
-choose F2 and you can browse through all obejcts, methods and properties with F1 you got the parameter values
hope this helps a bit