Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Dec 21, 2016 9:27 am

Hello,

I need to display horizontal data bars in one of the columns, but for some reason data bar is displayed for the cell with Value = 0.

The code:
Code: Select all
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
sheet.Range["A1"].NumberValue = 1;
sheet.Range["A2"].NumberValue = 0;
sheet.Range["A3"].NumberValue = 3;
sheet.Range["A4"].NumberValue = 8;
sheet.Range["A5"].NumberValue = 5;
ConditionalFormatWrapper format = sheet.Range["A1:A5"].ConditionalFormats.AddCondition();
format.FormatType = ConditionalFormatType.DataBar;
workbook.SaveToFile("D:\\sample.xlsx", ExcelVersion.Version2010);

Here is what I have:
1.png
1.png (5.42 KiB) Viewed 2065 times

But when I set Data Bar using Excel tools directly, I have the following:
2.png
2.png (5.46 KiB) Viewed 2065 times

I.e. there is no horizontal data bar for A2 cell, as the value in it is 0.

Could you please let me know if it is possible to not show data bar for cells with 0 value using Spire.Xls library?

Thank you.

steim
 
Posts: 5
Joined: Thu Jan 28, 2016 9:08 am

Thu Dec 22, 2016 2:22 am

Dear steim,

Thanks for your inquiry.
Please try to use following code.
Code: Select all
            format.DataBar.PercentMin = 0;

If there is any question, welcome to get it back to us.

Sincerely,
Betsy
E-iceblu support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Dec 22, 2016 7:13 am

This works, thank you very much!

steim
 
Posts: 5
Joined: Thu Jan 28, 2016 9:08 am

Thu Dec 22, 2016 7:18 am

Dear steim,

Thanks for your feedback.
Please feel free to contact us if there is any question. We are here for help.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS