0

Hello I am trying to save convert xls file to xlsb.

public static string XLSToXLSB(this string path)
{

    Application excelApplication = new Application();
    Workbook workbook = excelApplication.Workbooks.Open(path, XlUpdateLinks.xlUpdateLinksNever, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    //reformat name
    path = path.Replace(".xls", ".xlsb");
    //save & close
    workbook.SaveAs(path, XlFileFormat.xlExcel12, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    workbook.Close(false, Type.Missing, Type.Missing);
    excelApplication.Quit();
    //return
    return path;
}

I am using newest Intertop nuget, but keep getting exception: could not load assembly office vbersion 15.0.0.0, culture neutral,

Office versions installed are 365.

Unfortunately i do niot have budget too look at Epplus/Aspose and im stuck with free/open source libraries. (Although i can use free depraceted Epplus version)

So this thread would not cut it. This one also didn't help.

Anyone can help me understand why am i getting this exception or how i could reformat xls to xlsb as unfortunately im stuck with automatic save of xls file, but its saved with errors... due to beeing saved in incorrect format, long story short i need it in xlsb or xlsm.

After me manually "converting" the file to xlsb, xlsm streaming is working, but I wanted to avoid manual opening and save as. Unfortunately file is quite large in xls: 600MB as xls, 20+MB as xlsb.

EDIT:

This one also resulted in same exeption but for ver 16.0.0.0: nuget

0 Answers0