Xlsb file corrupted when saved first time from aspose workbook

//getting xcel corrupted with pivot table when saving a workbook as xslb first time “workbook.Save(fileName)”;
// When we save as xlsx, reload the file, save 2nd time as xlsb and open xlsb works fine
var xlFile = fileName.Replace(XLSB, XLSX);
//save as xlsx which opens fine
AsposeCells.LoadOptions loadOptions = new AsposeCells.LoadOptions(AsposeCells.LoadFormat.Xlsx) { MemorySetting = AsposeCells.MemorySetting.MemoryPreference };

// load saved xlsx to aspose workbook
using (var xlsx = new AsposeCells.Workbook(inputPathAndFile, loadOptions))
// save xlsb. When opened this file is not corrupted
xlsx.Save(outputPathAndFile, AsposeCells.SaveFormat.Xlsb);


Thanks for your query.

Please share your sample file and code snippet(runnable console application) with us for our testing. We will reproduce the problem and provide our feedback after analysis.

I am attaching the corrupted and non corrupted files.FirstXlsbSaveCorrupt.zip (634.8 KB)


I tried it simply by loading XLSX file and saving it back as XLSB, however no issue is observed when this output XLSB file is opened in Excel 2016. This scenario is tested using latest version Aspose.Cells for .NET 18.11.x and following sample code:

Workbook wb = new Workbook("FirstSaveXlsxWorks.xlsx");

Please try this scenario using latest version and provide your feedback. If still issue is there please send us the console application (runnable) along with the XLSX file for our testing.

This is similar to the below issue. Attaching the generated xlsb file which is corrupted when opened. Basically when you open excel it will give you repair warning and will deleteAsposeXlsbFirstSaveCorrupt.zip (179.0 KB)
the underlying “Pivot table” when said OK for repair.

When the xlsb file is opened, Microsoft gives below warning.

Removed Part: /xl/pivotTables/pivotTable2.bin part. (PivotTable view)
Removed Part: /xl/pivotTables/pivotTable1.bin part. (PivotTable view)
Removed Records: Workbook properties from /xl/workbook.bin part (Workbook)


I have tried the available sample XLSX file “FirstSaveXlsxWorks.xlsx” here using following sample code but no issue is observed. If this is not the file to test, please send us the source file which is to be tested along with the exact code used in your testing. We will analyze the file and provide our feedback.

Workbook wb = new Workbook(path + @"FirstSaveXlsxWorks.xlsx");
wb.Save(path + "output.xlsb", Aspose.Cells.SaveFormat.Xlsb);

I am attaching the Sample application. The xlsb is corrupted when you add more than 1 data field when xlsx works fine.

        //xlsb gets corrupted (EXCEL removes pivot table as a repair to the corrupted table on file opening) when more than 1 data field is added while xlsx works fine.

        //Open the source file
        Workbook wb11 = new Workbook(@"../../APP_DATA/xlsbdatasource1.xlsx");          
        DataTable dtGetExcelData = wb11.Worksheets[0].Cells.ExportDataTable(0, 0, wb11.Worksheets[0].Cells.MaxRow + 1, wb11.Worksheets[0].Cells.MaxColumn + 1);

        //add the data sheet
        Workbook wbAct = new Workbook();
        var wsData = wbAct.Worksheets[wbAct.Worksheets.Add()];
        wsData.Name = "Data1";

        //import data
        wsData.Cells.ImportDataTable(dtGetExcelData, true, "A1");

        //Add Pivot sheet
        var ws = wbAct.Worksheets[wbAct.Worksheets.Add()];
        ws.Name = "Pvt_Detailed_Sht";

        var pivotTableCollection = ws.PivotTables;
        int pivotIndex = pivotTableCollection.Add("Data1!" + wsData.Cells.FirstCell.Name + ":" + wsData.Cells.LastCell.Name, "A1", "Pivot12");      
        var pivotTable = pivotTableCollection[pivotIndex];

        pivotTable.RowGrand = true;
        pivotTable.ColumnGrand = true;

        //Add row fields
        var idx = pivotTable.AddFieldToArea(PivotFieldType.Row, 1);
        pivotTable.RowFields[idx].IsAutoSubtotals = false;
        pivotTable.RowFields[idx].IsRepeatItemLabels = true;

        var idx1 =  pivotTable.AddFieldToArea(PivotFieldType.Row, 7);
        pivotTable.RowFields[idx1].IsAutoSubtotals = false;
        pivotTable.RowFields[idx1].IsRepeatItemLabels = true;

      // When more than 1 data field is added xlsb file gets corrupted. If only 1 data column is added xlsb file is not corrupted
      // Xlsx is not corrupted even when multiple data fields are added.
      // add only 1 data column both xlsx and xlsb works fine

        pivotTable.AddFieldToArea(PivotFieldType.Data, "Column31");
        pivotTable.AddFieldToArea(PivotFieldType.Data, "Column32");       



XLSBCorruptFirstTime.zip (9.2 MB)

        wbAct.Save(@"../../APP_DATA/OutputCorrupted-Datacolsmorethan1.Xlsb", SaveFormat.Xlsb);
        //xlsx file coming uncorrupted.
        wbAct.Save(@"../../APP_DATA/Output-Datacolsmorethan1.Xlsx", SaveFormat.Xlsx);


We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46572 - xlsb is corrupted while adding more than 1 data field whereas xlsx works fine

Thanks for creating a ticket for this issue. Is there any update on this ticket?


I have checked the status of this ticket and it is still pending for analysis. We will write back here once any update is ready to provide.


I would like to update you that we will provide the fix version before 16th February 2019.

Once we have further update on it, we will let you know here.


Please try our latest version/fix: Aspose.Cells for .NET v19.1.6 (attached)

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.1.6 For .Net2_AuthenticodeSigned.Zip (4.7 MB)
Aspose.Cells19.1.6 For .Net4.0.Zip (4.8 MB)

Thanks for the fix. I tested initially with my sample application and it is fixed. Will test with the real application and will let you know.


Good to know that your issue is sorted out during initial tests with sample application. Feel free to contact us any time if you need further help or have some other issue or queries while using your actual application, we will be happy to assist you soon.

When will the new version be available in NuGet?


The new version 19.2 will be released in the last week of this month having this fix and will be available via NuGet. We will notify you here once new version is released.

We tested in real application and it works good. XLSB file is not getting corrupted. Look forward for the new version in NuGet.


Good to know that your issue is resolved using the latest version. This fix will be available via NuGet in a couple of week. We will notify you as soon as this new version is released.

The issues you have found earlier (filed as CELLSNET-46572) have been fixed in Aspose.Cells for .NET v19.2. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi