C# Create Excelfile
-
Hey guys sorry for disturbing again.... now a new and intressting problem: I have installed now Office XP && Office 2007. If I create a new excelfile with
worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);
it become a ".xls" Previous I only had Office 2007 and the same code created a ".xlsx" file then I used the following code to create a ".xls":
worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
I've a string with the full path, it contains which format I want to use... ("a\b\c\2003.xls" or "a\b\c\2007.xlsx")
if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xls") worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t); else if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xlsx") worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t); excelApp.Quit();
so what could I do to save the file in the right form? :confused: greets Mschauder
-
Hey guys sorry for disturbing again.... now a new and intressting problem: I have installed now Office XP && Office 2007. If I create a new excelfile with
worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t);
it become a ".xls" Previous I only had Office 2007 and the same code created a ".xlsx" file then I used the following code to create a ".xls":
worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t);
I've a string with the full path, it contains which format I want to use... ("a\b\c\2003.xls" or "a\b\c\2007.xlsx")
if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xls") worksheet.SaveAs(txtSavePfad.Text, XlFileFormat.xlExcel8, t, t, t, t, t, t, t, t); else if (txtSavePfad.Text.Substring(txtSavePfad.Text.LastIndexOf(".")) == ".xlsx") worksheet.SaveAs(txtSavePfad.Text, t, t, t, t, t, t, t, t, t); excelApp.Quit();
so what could I do to save the file in the right form? :confused: greets Mschauder
It sounds like you have installed stuff in the wrong order. Check out this MSDN article[^] If stuff is installed in the wrong order it won't work properly. My personal experience is that although Microsoft claim you can (but not recommended) have both versions installed at the same time, in practice every piece of code you write is almost guaranteed to break.
If you have knowledge, let others light their candles at it. Margaret Fuller (1810 - 1850) [My Articles] [My Website]