Class: Writeexcel::Worksheet::CellRange
- Inherits:
-
Object
- Object
- Writeexcel::Worksheet::CellRange
- Defined in:
- lib/writeexcel/cell_range.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#col_max ⇒ Object
Returns the value of attribute col_max.
-
#col_min ⇒ Object
Returns the value of attribute col_min.
-
#row_max ⇒ Object
Returns the value of attribute row_max.
-
#row_min ⇒ Object
Returns the value of attribute row_min.
Instance Method Summary collapse
- #col(val) ⇒ Object
- #increment_col_max ⇒ Object
- #increment_row_max ⇒ Object
-
#initialize(worksheet) ⇒ CellRange
constructor
A new instance of CellRange.
-
#name_record_long(type, ext_ref) ⇒ Object
assemble the NAME record in the long format that is used for storing the repeat rows and columns when both are specified.
-
#name_record_short(type, ext_ref, hidden = nil) ⇒ Object
assemble the NAME record in the short format that is used for storing the print area, repeat rows only and repeat columns only.
- #row(val) ⇒ Object
Constructor Details
#initialize(worksheet) ⇒ CellRange
Returns a new instance of CellRange.
7 8 9 |
# File 'lib/writeexcel/cell_range.rb', line 7 def initialize(worksheet) @worksheet = worksheet end |
Instance Attribute Details
#col_max ⇒ Object
Returns the value of attribute col_max.
5 6 7 |
# File 'lib/writeexcel/cell_range.rb', line 5 def col_max @col_max end |
#col_min ⇒ Object
Returns the value of attribute col_min.
5 6 7 |
# File 'lib/writeexcel/cell_range.rb', line 5 def col_min @col_min end |
#row_max ⇒ Object
Returns the value of attribute row_max.
5 6 7 |
# File 'lib/writeexcel/cell_range.rb', line 5 def row_max @row_max end |
#row_min ⇒ Object
Returns the value of attribute row_min.
5 6 7 |
# File 'lib/writeexcel/cell_range.rb', line 5 def row_min @row_min end |
Instance Method Details
#col(val) ⇒ Object
24 25 26 27 |
# File 'lib/writeexcel/cell_range.rb', line 24 def col(val) @col_min = val if !@col_min || (val < col_min) @col_max = val if !@col_max || (val > col_max) end |
#increment_col_max ⇒ Object
15 16 17 |
# File 'lib/writeexcel/cell_range.rb', line 15 def increment_col_max @col_max += 1 if @col_max end |
#increment_row_max ⇒ Object
11 12 13 |
# File 'lib/writeexcel/cell_range.rb', line 11 def increment_row_max @row_max += 1 if @row_max end |
#name_record_long(type, ext_ref) ⇒ Object
assemble the NAME record in the long format that is used for storing the repeat rows and columns when both are specified. This share a lot of code with name_record_short() but we use a separate method to keep the code clean. Code abstraction for reuse can be carried too far, and I should know. ;-)
type
ext_ref # TODO
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/writeexcel/cell_range.rb', line 38 def name_record_long(type, ext_ref) #:nodoc: record = 0x0018 # Record identifier length = 0x002a # Number of bytes to follow grbit = 0x0020 # Option flags chkey = 0x00 # Keyboard shortcut cch = 0x01 # Length of text name cce = 0x001a # Length of text definition unknown01 = 0x0000 # ixals = @worksheet.index + 1 # Sheet index unknown02 = 0x00 # = 0x00 # Length of cust menu text cch_description = 0x00 # Length of description text cch_helptopic = 0x00 # Length of help topic text cch_statustext = 0x00 # Length of status bar text rgch = type # Built-in name type unknown03 = 0x29 unknown04 = 0x0017 unknown05 = 0x3b header = [record, length].pack("vv") data = [grbit].pack("v") data += [chkey].pack("C") data += [cch].pack("C") data += [cce].pack("v") data += [unknown01].pack("v") data += [ixals].pack("v") data += [unknown02].pack("C") data += [].pack("C") data += [cch_description].pack("C") data += [cch_helptopic].pack("C") data += [cch_statustext].pack("C") data += [rgch].pack("C") # Column definition data += [unknown03].pack("C") data += [unknown04].pack("v") data += [unknown05].pack("C") data += [ext_ref].pack("v") data += [0x0000].pack("v") data += [0xffff].pack("v") data += [@col_min].pack("v") data += [@col_max].pack("v") # Row definition data += [unknown05].pack("C") data += [ext_ref].pack("v") data += [@row_min].pack("v") data += [@row_max].pack("v") data += [0x00].pack("v") data += [0xff].pack("v") # End of data data += [0x10].pack("C") [header, data] end |
#name_record_short(type, ext_ref, hidden = nil) ⇒ Object
assemble the NAME record in the short format that is used for storing the print area, repeat rows only and repeat columns only.
type
ext_ref # TODO
hidden # Name is hidden
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/writeexcel/cell_range.rb', line 104 def name_record_short(type, ext_ref, hidden = nil) #:nodoc: record = 0x0018 # Record identifier length = 0x001b # Number of bytes to follow grbit = 0x0020 # Option flags chkey = 0x00 # Keyboard shortcut cch = 0x01 # Length of text name cce = 0x000b # Length of text definition unknown01 = 0x0000 # ixals = @worksheet.index + 1 # Sheet index unknown02 = 0x00 # = 0x00 # Length of cust menu text cch_description = 0x00 # Length of description text cch_helptopic = 0x00 # Length of help topic text cch_statustext = 0x00 # Length of status bar text rgch = type # Built-in name type unknown03 = 0x3b # grbit = 0x0021 if hidden rowmin = row_min rowmax = row_max rowmin, rowmax = 0x0000, 0xffff unless row_min colmin = col_min colmax = col_max colmin, colmax = 0x00, 0xff unless col_min header = [record, length].pack("vv") data = [grbit].pack("v") data += [chkey].pack("C") data += [cch].pack("C") data += [cce].pack("v") data += [unknown01].pack("v") data += [ixals].pack("v") data += [unknown02].pack("C") data += [].pack("C") data += [cch_description].pack("C") data += [cch_helptopic].pack("C") data += [cch_statustext].pack("C") data += [rgch].pack("C") data += [unknown03].pack("C") data += [ext_ref].pack("v") data += [rowmin].pack("v") data += [rowmax].pack("v") data += [colmin].pack("v") data += [colmax].pack("v") [header, data] end |
#row(val) ⇒ Object
19 20 21 22 |
# File 'lib/writeexcel/cell_range.rb', line 19 def row(val) @row_min = val if !@row_min || (val < row_min) @row_max = val if !@row_max || (val > row_max) end |