This may be related to posts CELLSNET-41803 and CELLSNET-42158 regarding negative databar values not exporting to PDF, but I am not even getting that far. Trying to create an Excel file from scratch with databars, the axis is always left-justified, making the lowest negative number “zero”. On top of that, the barfilltype is always gradient, even when set to solid. Attached is an image where the first column is the data, the second is the Aspose.Cells generated databars , and the third is done by hand in LibreOffice with the desired bar style. I am using Aspose.Cells 126.96.36.199 evaluation.
Thank you for using Aspose products.
I have evaluated your presented scenario with latest build of Aspose.Cells for .NET 7.7.0, and I am able to achieve your desired results with below provide code snippet. Please have a look at the attached snapshot, you will notice that the axis is set in the middle of the cell and the BarFillType is set to solid, as per your requirement.
Workbook book = new Workbook(myDir + “Databar.xlsx”);
Worksheet sheet = book.Worksheets;
FormatConditionCollection conds = sheet.ConditionalFormattings[sheet.ConditionalFormattings.Add()];
int idx = conds.AddCondition(FormatConditionType.DataBar);
FormatCondition cond = conds[idx];
cond.DataBar.BarFillType = DataBarFillType.DataBarFillSolid;
cond.DataBar.BarBorder.Type = DataBarBorderType.DataBarBorderSolid;
cond.DataBar.BarBorder.Color = Color.Plum;
cond.DataBar.NegativeBarFormat.ColorType = DataBarNegativeColorType.DataBarColor;
cond.DataBar.NegativeBarFormat.Color = Color.Red;
cond.DataBar.NegativeBarFormat.BorderColorType = DataBarNegativeColorType.DataBarColor;
cond.DataBar.NegativeBarFormat.BorderColor = Color.Yellow;
cond.DataBar.AxisColor = Color.Blue;
cond.DataBar.AxisPosition = DataBarAxisPosition.DataBarAxisMidpoint;
CellArea ca = new CellArea();
ca.StartRow = 2;
ca.EndRow = 12;
ca.StartColumn = 1;
ca.EndColumn = 1;
book.Save(myDir + “output.xlsx”);
With the latest version, and with your example, I was able to get the data bars exactly how I wanted. And with 188.8.131.52 mentioned in CELLSNET-42158, I was able to get the pdf output to look correct as well. Thank you!
Thank you for your confirmation. Good to know that you are up and running again. Please feel free to write back in case you need any further assistance.