AXLSX: Conditional formatting for percent, changes the cell value

656 Views Asked by At

I'm following this example LINK. But, I have floating value for the cell, so when I run this example with every cell value as 4.5 (hardcoded), the excel generates cells with value 450.00 %, while expected value was 4.500 %.

NOTE: I have just changed line 26 of above example from:

ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "=100*B#{i}/SUM(B3:B#{rows+offset})"], :style=>[nil, money, percent]

to:

ws.add_row ["Q#{i}", 10000*((rows/2-i) * (rows/2-i)), "4.5"], :style=>[nil, money, percent]

Just hard-coded 4.5

OUTPUT:

enter image description here

How to add just a % sign to cell value without changing cell value?

Also, I don't wanr cell to be :string formatted, it has to be :float

0

There are 0 best solutions below