Creating excel template 2003 in C# on a machine with both 2003 and 2007 installed.

Posted by Ragha J on Stack Overflow See other posts from Stack Overflow or by Ragha J
Published on 2010-04-13T17:49:17Z Indexed on 2010/04/13 17:53 UTC
Read the original article Hit count: 413

Filed under:
|
|
|

I have both 2003 and 2007 Excel versions installed on my machine. The current source code uses Office11 (2003) interop assembly Microsoft.Office.Interop.Excel.dll to create the Excel template.

When I create the template and open in Excel 2007, it opens perfectly. The same template when I open in 2003 I get the message "File format is not valid".

_excel = new Excel.Application();
_workbooks = _excel.Workbooks;
_excel.Visible = false;

_excel.DisplayAlerts = false;

// create and add a workbook with 1 worksheet named "Sheet1" 
_workbook = _workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);

_sheet = (Excel.Worksheet)_workbook.ActiveSheet;

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET