So i know that to convert an xls to an xlsx file you need to physically save the file so i do this, using interop i physically open the file and use SaveAs which is the same as saving as the normal way. My problem is if i open the file and save it as the normal way i can then access it but if i do it programatically(see bellow) it will fail
using excel = Microsoft.Office.Interop.Excel;
excel.Workbook workbook = Globals.ThisAddIn.Application.Workbooks.Open(txbBrowse.Text);
workbook.SaveAs(newFileName, excel.XlFileFormat.xlOpenXMLWorkbook);
workbook.Close();
If i now open this file it will open just fine with out saying its corrupted, however if i try to access it via OpenXML
using (var spreadsheet = SpreadsheetDocument.Open(filename, true, new OpenSettings{ AutoSave = true }))
{//...do something here}
i get The specified package is invalid. The main part is missing.
.xls
file containing any kind of VBA Macros? Have you tried saving the file as.xlsm
instead of.xlsx
(i.e. change format fromxlOpenXMLWorkbook
toxlOpenXMLWorkbookMacroEnabled
)? - bassfader