ClosedXML.Report
ClosedXML.Report copied to clipboard
Lost formatting after render.
I'm trying to use the library, but after rendering the data, the resulting file loses formatting, except for the background of the cells. Now I do not save the font size, bold and row height. Attached the base template and result of the rendering. RenderResult.xlsx Template.xlsx The next data structure is used as data source:
public class BulkPlanSummaryReportData
{
public string PlanName { get; set; }
public string PlanType { get; set; }
public int WhsId { get; set; }
public string FinalBin { get; set; }
public string ShipmentId { get; set; }
public bool UseBoxing { get; set; }
public int ItemsCount { get; set; }
public int BoxesCount { get; set; }
public List<BulkPlanSummaryReportItemData> ItemsData { get; set; }
public List<string> BoxNames { get; set; }
public List<BulkPlanSummaryReportBoxData> Boxes { get; set; }
}
public class BulkPlanSummaryReportItemData
{
public string ItemId { get; set; }
public string Ups { get; set; }
public string Ean { get; set; }
public int OrderedQty { get; set; }
public int FinalQty { get; set; }
/// <summary>
/// This list should have same sort order as Boxes list
/// </summary>
public List<int> QtyByBoxes { get; set; }
}
public class BulkPlanSummaryReportBoxData
{
public int BoxId { get; set; }
public string Package { get; set; }
public decimal Length { get; set; }
public decimal Width { get; set; }
public decimal Height { get; set; }
public decimal Weight { get; set; }
public int Qty { get; set; }
}
Can you give me advice how to I can store formatting from template to the render result, please? I thought this feature is work by default, but not for me. What I do wrong?
I tried different variants and found the root of the problem. You need to update reference of ClosedXml package. The version 0.2.4 is used ClosedXml v.0.95.4, the last version of ClosedXml is 0.96. V 0.95.4 has SaveAs this issue:
var path = Path.Combine(templatesRoot, templateName);
var testXlsx = new XLWorkbook(path);
testXlsx.SaveAs("c:\\Users\\Nikolay\\Downloads\\test.xlsx");
But version 0.96 works correct.
You can't install both packages ClosedXml.Report v0.2.4+ClosedXml v0.96, you will have a build exception
I tried to downgrade ClosedXml to 0.95, but it is not helped.
Could you please try this with the latest ClosedXML.Report?