zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

What's the plan about TODO (Percent style)? #252

Closed shatle closed 4 years ago

shatle commented 4 years ago

I want to set some cell to Percent style, but i saw the TODO. And, what's the plan for it?

lib/spreadsheet/excel/writer/workbook.rb

def write_styles workbook, writer
    # TODO: Style implementation. The following is simply a standard builtin
    #       style.
    # TODO: User defined styles
    data = [
      0x8000, #   Bit  Mask    Contents
              # 11- 0  0x0fff  Index to style XF record (➜ 6.115)
              #    15  0x8000  Always 1 for built-in styles
      0x00,   # Identifier of the built-in cell style:
              # 0x00 = Normal
              # 0x01 = RowLevel_lv (see next field)
              # 0x02 = ColLevel_lv (see next field)
              # 0x03 = Comma
              # 0x04 = Currency
              # 0x05 = Percent
              # 0x06 = Comma [0] (BIFF4-BIFF8)
              # 0x07 = Currency [0] (BIFF4-BIFF8)
              # 0x08 = Hyperlink (BIFF8)
              # 0x09 = Followed Hyperlink (BIFF8)
      0xff,   # Level for RowLevel or ColLevel style (zero-based, lv),
              # 0xff otherwise
              # The RowLevel and ColLevel styles specify the formatting of
              # subtotal cells in a specific outline level. The level is
              # specified by the last field in the STYLE record. Valid values
              # are 0…6 for the outline levels 1…7.
    ]
    write_op writer, 0x0293, data.pack('vC2')
  end

Thanks.

zdavatz commented 4 years ago

@shatle feel free to submit a Pull-Request.

shatle commented 4 years ago

Ooook, i try

zdavatz commented 4 years ago

great, thank you @shatle