Spreadsheets are empty when opening in "Spreadsheet compare" Office tool
See original GitHub issueHello! First of all, thank you for the amazing tooling, metrics are really great and writes are so performant! I’m able to generate large xlsx files using .NET.
However, I have faced the issue when trying to compare the file generated with SpreadCheetah, with other xlsx files using the Spreadsheet Compare 2016 tool (part of Office). The file generated using SpreadCheetah is treated as empty for some reason by this tool, so I can’t compare it with others. At the same time, the file in Excel looks good and has the data. I had no similar issue when opening files created using NPOI package.
So, is it possible to make the SpreadCheetah-generated xlsx files compatible with Spreadsheet Compare? Could you please let me know if you can plan it, so that I can realize whether I can fully migrate to SpreadCheetah?
This is how the issue looks like in Spreadsheet Compare (left file that looks empty - SpreadCheetah, right file - created in Excel):
This is how the file looks like in Excel - it’s not empty:
Minimal code:
using var tempStream = new MemoryStream();
await using var spreadsheet = await Spreadsheet.CreateNewAsync(tempStream, null, cancellationToken);
await spreadsheet.StartWorksheetAsync("Report", null, cancellationToken);
var columnNames = new List<string> { "column1", "column2" };
var values = new List<string> { "value1", "value2" };
var headerRow = new List<Cell>();
foreach (var columnName in columnNames)
{
headerRow.Add(new Cell(columnName));
}
await spreadsheet.AddRowAsync(headerRow, cancellationToken);
var valuesRow = new List<Cell>();
foreach (var value in values)
{
valuesRow.Add(new Cell(value));
}
await spreadsheet.AddRowAsync(valuesRow, cancellationToken);
await spreadsheet.FinishAsync(cancellationToken);
Environment: Spreadcheetah 1.9.0 .NET 6
Issue Analytics
- State:
- Created 6 months ago
- Comments:5 (3 by maintainers)
It seems this is due to SpreadCheetah not writing the explicit cell reference for each cell. In an XLSX file, each cell element can have an explicit reference (or
"r"
) attribute. According to the Open XML specification this attribute is optional, but it seems it is required for Spreadsheet Compare to do a comparison. SpreadCheetah doesn’t write this attribute to achieve better performance, but I’m considering adding an option to write this attribute, something likeSpreadCheetahOptions.WriteCellReferenceAttributes
. The option would default tofalse
so that performance wouldn’t be affected for users that don’t need this feature.Hi, and thanks for the feedback!
Not sure what is causing this issue, but I can look into it. In the meantime, if you open the file created by SpreadCheetah in Excel, and then save the file from there, does it still show up as empty in Spreadsheet Compare?