Hello,
It seems I am encountering a regression in null handling between Aspose.Cells 25.6.0 and above.
I have an excel template file with smart markers, with both direct values and nested object: for example, I have &=records.IssuerCountry and &=records.GeneralData.LastInteractionDate
Then I have a simple method to build the excel file:
public byte[] BuildReport<T>(ReportModel<T> reportModel, string templatePath) where T : class
{
var workbook = new Workbook(templatePath);
var designer = new WorkbookDesigner(workbook);
designer.SetDataSource("reportingDate", reportModel.ReportingDate.ToDateTime(TimeOnly.MinValue));
designer.SetDataSource("records", reportModel.Records);
designer.Process();
using var stream = new MemoryStream();
workbook.Save(stream, SaveFormat.Xlsx);
return stream.ToArray();
}
In version 25.6.0, if GeneralData is null, the smart markers is replaced by an empty string (what I was always expecting).
But starting from version 25.7.0, it throws a NullReferenceException on the method Process of WorkbookDesigner (the stacktrace is obfuscated inside Aspose.Cells until the method Process).
I checked the releases notes but can’t see anything about that, or any other way to have the same initial behaviour (having an empty cell instead of throwing an exception).
Can you assist on this ?
Thanks in advance !
@jcayrol
Please share template file with smart marker and sample data source here. We will check it soon.
Here is a simple API that showcase the issue.
In version 25.6.0, the excel is correctly created.
In version 25.7.0, it throws an exception.
internal record TestReportModel(string IssuerCountry, GeneralData? GeneralData);
internal record GeneralData(string LastInteractionDate);
public async Task<Results<FileContentHttpResult, NotFound<string>, NoContent>> GetTestReportAsync(string templatePath)
{
var workbook = new Workbook(templatePath);
var designer = new WorkbookDesigner(workbook);
List<TestReportModel> data = [new TestReportModel("FR", new GeneralData("2023-01-01")), new TestReportModel("US", null)];
designer.SetDataSource("records", data);
designer.Process();
using var stream = new MemoryStream();
workbook.Save(stream, SaveFormat.Xlsx);
var bytes = stream.ToArray();
var fileName = $"TestReport.xlsx";
return TypedResults.File(
bytes,
contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
fileDownloadName: fileName);
}
And the associated template
Test_Template.7z (7,6 Ko)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-60311
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The issues you have found earlier (filed as CELLSNET-60311) have been fixed in this update. This message was posted using Bugs notification tool by Agent assistant.