excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
is it possible to create an excel file from my c# app? If so, how do I this
and is there any good samples I can use?

Thanks
Julia
 
Thanks for your answer, very good page to read!

Do you know if there can be problems when my computer settings (regional
options) are set to Swedish? My code throws an error when I user the Swedish
settings. But if I change my regional options to English-United States no
error occur.

How can I solve this problem. I want to have my regional options set to
Swedish.

Thanks
Julia
 
You will have to post the (minimal) code that causes the exception...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
This is the code:
--------------------------------------------------------------
System.Globalization.CultureInfo myNewCulture = new
System.Globalization.CultureInfo("en-US");

objSheet = new Excel._Worksheet[1];
string[] sheetNames = {"ETT"};
string[][] allRowNames = new string[][]{ new string[]{"FirstRow"} };

objApp = new Excel.Application();
objApp.UserControl = true;
Object oBooks = objApp.Workbooks;

oBooks.GetType().InvokeMember("Add",
System.Reflection.BindingFlags.InvokeMethod, null, oBooks, null,
myNewCulture);

objApp.Save("C:\\Documents and Settings\\junorman\\Desktop\\text.xls");
--------------------------------------------------------------
- I have my regional options set to Swedish.
- The code fails at objApp.Save
- The error message is: {"Old format or invalid type library." }
- If I remove the first row and send in my CurrentCulture to the
oBooks.GetType()... this row will fail.


Is there anything special one needs to do to be able to work with Excel when
using regional option set to Swedish.

Thank you for spending time on this problem
Julia
 
Thank you for your help!

/Julia

Carlos J. Quintero said:
That's a bug of Excel. See:

BUG: "Old Format or Invalid Type Library" Error When Automating Excel
http://support.microsoft.com/kb/320369/en-us

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

Julia said:
This is the code:
--------------------------------------------------------------
System.Globalization.CultureInfo myNewCulture = new
System.Globalization.CultureInfo("en-US");

objSheet = new Excel._Worksheet[1];
string[] sheetNames = {"ETT"};
string[][] allRowNames = new string[][]{ new string[]{"FirstRow"} };

objApp = new Excel.Application();
objApp.UserControl = true;
Object oBooks = objApp.Workbooks;

oBooks.GetType().InvokeMember("Add",
System.Reflection.BindingFlags.InvokeMethod, null, oBooks, null,
myNewCulture);

objApp.Save("C:\\Documents and Settings\\junorman\\Desktop\\text.xls");
--------------------------------------------------------------
- I have my regional options set to Swedish.
- The code fails at objApp.Save
- The error message is: {"Old format or invalid type library." }
- If I remove the first row and send in my CurrentCulture to the
oBooks.GetType()... this row will fail.


Is there anything special one needs to do to be able to work with Excel
when
using regional option set to Swedish.

Thank you for spending time on this problem
Julia
 
Back
Top