Adding conditional formats (using the example file of NPOI 2.1.3) to an xlsx spreadsheet are missing when the file is opened in LibreOffice Calc. Excel opens correctly after "repairing" the file. If the "repaired" file is saved from excel the formats also appear in Calc.
Some digging in the xml data revealed that NPOI sets all "priority" fields in the cfRule entry of the sheet to "0".
It seems there is a line missing in the sheet.cs module .\ooxml\OpenXmlFormats\Speradsheet\Sheet.cs which copies the CT_CFRule fields to the XML file. Adding the priority field in the Set function fixes the issue.
public void Set(CT_CfRule src)
{
this.formula = src.formula;
this.stopIfTrue = src.stopIfTrue;
this.bottom = src.bottom;
this.percent = src.percent;
this.dxfId = src.dxfId;
// added priority field transfer copy
this.priority = src.priority;
this.@operator = src.@operator;
this.type = src.type;
this.equalAverage = src.equalAverage;
this.aboveAverage = src.aboveAverage;
this.colorScale = src.colorScale;
this.dataBar = src.dataBar;
this.iconSet = src.iconSet;
this.extLst = src.extLst;
}
Comments: ** Comment from web user: tonyqus **
Some digging in the xml data revealed that NPOI sets all "priority" fields in the cfRule entry of the sheet to "0".
It seems there is a line missing in the sheet.cs module .\ooxml\OpenXmlFormats\Speradsheet\Sheet.cs which copies the CT_CFRule fields to the XML file. Adding the priority field in the Set function fixes the issue.
public void Set(CT_CfRule src)
{
this.formula = src.formula;
this.stopIfTrue = src.stopIfTrue;
this.bottom = src.bottom;
this.percent = src.percent;
this.dxfId = src.dxfId;
// added priority field transfer copy
this.priority = src.priority;
this.@operator = src.@operator;
this.type = src.type;
this.equalAverage = src.equalAverage;
this.aboveAverage = src.aboveAverage;
this.colorScale = src.colorScale;
this.dataBar = src.dataBar;
this.iconSet = src.iconSet;
this.extLst = src.extLst;
}
Comments: ** Comment from web user: tonyqus **
This will be fixed!