I am using C# to create a spreadsheet, here is the code:
try
{
_excel = new Excel.Application();
_excel.Visible = false;
_workbook = _excel.Workbooks.Add( Type.Missing );
_worksheet = (Excel.Worksheet)_workbook.Sheets[1];
createColumnHeaders();
_workbook.SaveCopyAs( savePath );
}
catch (Exception ex)
{
Logger.Error( "Error creating spreadsheet: {0}", ex.Message );
}
finally
{
// Cleanup
}
This runs nicely, saves the sheet into the savePath. However, if I change SaveCopyAs() to
SaveAs( savePath,
Excel.XlFileFormat.xlWorkbookNormal,
Type.Missing,
Type.Missing,
false,
false,
XlSaveAsAccessMode.xlNoChange,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing,
Type.Missing );
then the application gets a COMException saying
'C:\//temp/00-04.20.18-24-07-2014/' cannot be accessed. The file may be corrupted,
located on a server that is not responding, or read-only.
This is a pain since I really need to be saving in .xls format, not .xlsx. Any ideas why this exception occurs for SaveAs()?