I need to create an excel 2007 template (.xltx) from my c# code. I am using excel automation to create.
The following code creates an xltx file. But when I open, I get an empty excel application with an error message "Excel cannot open the file 'NewTemplate.xltx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
code:
/////////////////
workbook = workbooks.Add(System.Reflection, Missing.Value);
workbook.SaveAs("D:\\NewTemplate.xltx", office2007.XlFileFormat.xlTemplate8, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false, office2007.XlSaveAsAccessMode.xlNoChange, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
workbooks.Close();
excelApplication.Quit();
/////////////////////////
Can anyone please help me to find the problem in creating a new xltx template file.
Many thanx in advance.
kumari
The following code creates an xltx file. But when I open, I get an empty excel application with an error message "Excel cannot open the file 'NewTemplate.xltx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."
code:
/////////////////
workbook = workbooks.Add(System.Reflection, Missing.Value);
workbook.SaveAs("D:\\NewTemplate.xltx", office2007.XlFileFormat.xlTemplate8, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false, office2007.XlSaveAsAccessMode.xlNoChange, System.Reflection.Missing.Value, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
workbooks.Close();
excelApplication.Quit();
/////////////////////////
Can anyone please help me to find the problem in creating a new xltx template file.
Many thanx in advance.
kumari