zdavatz / spreadsheet

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

Is there anyway to set outline buttons above outline group #186

Closed xinqinglxl closed 7 years ago

xinqinglxl commented 7 years ago

Hi, i'm a new newcomer to ruby , and now I want to generate an excel contains outline, I found the bellow guide in readme but I wonder if there is any api to make outline buttons above outline group. Just like sheet.setRowSumsBelow(false); in java or ws.ViewOptions.OutlineRowButtonsBelow = false; in C#.

# row
sheet.row(3).hidden = true
sheet.row(4).hidden = true
sheet.row(3).outline_level = 1
sheet.row(4).outline_level = 1

Now I'm using hook as below to deal the case, can someone provide an api so that I can make it easier to understand .

require_relative 'hook'
include Spreadsheet::Excel::Writer
include Hook

$aboveButton = 1
class Spreadsheet::Excel::Writer::Worksheet
    hook do
        def write_wsbool
            if $aboveButton ==1
                bits = [
                     #   Bit  Mask    Contents
                  1, #     0  0x0001  0 = Do not show automatic page breaks
                     #                1 = Show automatic page breaks
                  0, #     4  0x0010  0 = Standard sheet
                     #                1 = Dialogue sheet (BIFF5-BIFF8)
                  0, #     5  0x0020  0 = No automatic styles in outlines
                     #                1 = Apply automatic styles to outlines
                  0, #     6  0x0040  0 = Outline buttons above outline group
                     #                1 = Outline buttons below outline group
                  1, #     7  0x0080  0 = Outline buttons left of outline group
                     #                1 = Outline buttons right of outline group
                  0, #     8  0x0100  0 = Scale printout in percent (➜ 6.89)
                     #                1 = Fit printout to number of pages (➜ 6.89)
                  0, #     9  0x0200  0 = Save external linked values
                     #                    (BIFF3-BIFF4 only, ➜ 5.10)
                     #                1 = Do not save external linked values
                     #                    (BIFF3-BIFF4 only, ➜ 5.10)
                  1, #    10  0x0400  0 = Do not show row outline symbols
                     #                1 = Show row outline symbols
                  0, #    11  0x0800  0 = Do not show column outline symbols
                     #                1 = Show column outline symbols
                  0, # 13-12  0x3000  These flags specify the arrangement of windows.
                     #                They are stored in BIFF4 only.
                     #                00 = Arrange windows tiled
                     #                01 = Arrange windows horizontal
                  0, #                10 = Arrange windows vertical
                     #                11 = Arrange windows cascaded
                     # The following flags are valid for BIFF4-BIFF8 only:
                  0, #    14  0x4000  0 = Standard expression evaluation
                     #                1 = Alternative expression evaluation
                  0, #    15  0x8000  0 = Standard formula entries
                     #                1 = Alternative formula entries
                ]
                weights = [4,5,6,7,8,9,10,11,12,13,14,15]
                value = bits.inject do |a, b| a | (b << weights.shift) end
                write_op 0x0081, [value].pack('v')
            else
                super
            end
        end
    end
end

zdavatz commented 7 years ago

Good question. I am not aware of a solution at the moment. Let me know if you find a solution.