facebooktwittermenuarrow-up

GemBox Support Forum

XLSX file can't be read by Microsoft OpenXML

We have implemented an interface using GemBox Spreadsheet Version 45.0.35.1131.
The interface saves the data to an XLSX file, using the following code:

Workbook.Save("example.xlsx");

On the other end of the interface our client gets the following error (in German):

123

The current workaround is to open the XLSX file in Microsoft Excel, saving it as an XLS file and then saving it as an XLSX file again.

Should we be using a different way to save the XLSX file?

Hi MKruck,

I’m afraid I was unable to reproduce this.
I tried using the latest version of GemBox.Spreadsheet and OpenXML SDK:

static void Main()
{
    var path = "example.xlsx";

    // Write Excel file with GemBox.Spreadsheet.
    var workbook = new ExcelFile();
    var worksheet = workbook.Worksheets.Add("Sheet1");

    for (int r = 0; r < 50; r++)
        for (int c = 0; c < 10; c++)
            worksheet.Cells[r, c].Value = c + r * 10;

    workbook.Save(path);

    // Read Excel file with OpenXML SDK.
    using var spreadsheet = SpreadsheetDocument.Open(path, false);
    var rows = spreadsheet.WorkbookPart.WorksheetParts.First()
        .Worksheet.Elements<SheetData>().First()
        .Elements<Row>();

    foreach (var row in rows)
    {
        foreach (var cell in row.Elements<Cell>())
            Console.Write($"{cell.CellValue.Text,3}  ");
        Console.WriteLine();
    }
}

Just in case, can you try again with the latest versions?

If the problem remains, please send us a small Visual Studio project that reproduces your issue so that we can investigate it.

Regards,
Mario