Add custom abbreviation format for cells using AXLSX gem

42 Views Asked by At

I am using the caxlsx gem to export some data and I need to add custom abbreviation formatting for cells on a specific column to add units of T(trillions), B(billions), and M(millions) to the end. So:

  • 27 -> 27M
  • 1555.5 -> 1.56B
  • 1232567 -> 1.23T

I tried doing:

workbook = Axlsx::Workbook.new
sheet = workbook.add_worksheet
abbr = workbook.styles.add_style(format_code: '[>=1000000]0.0,,,"T";[>=1000]0.0,,"B";0"M"') #works in custom format when explicitly setting in excel 

which sends the data back and does download but when trying to open the file, it gives me We found a problem with some content in...

I've been at this for hours and can't seem to find a way. Any help is appreciated

0

There are 0 best solutions below