Class: Worksheet
Constant Summary
Constants included from Utilities
Instance Attribute Summary collapse
-
#alt_expr_eval ⇒ Object
Returns the value of attribute alt_expr_eval.
-
#alt_formula_entries ⇒ Object
Returns the value of attribute alt_formula_entries.
-
#auto_colour_grid ⇒ Object
Returns the value of attribute auto_colour_grid.
-
#auto_style_outline ⇒ Object
Returns the value of attribute auto_style_outline.
-
#bmp_rec ⇒ Object
Returns the value of attribute bmp_rec.
-
#bottom_margin ⇒ Object
Returns the value of attribute bottom_margin.
-
#calc_count ⇒ Object
Returns the value of attribute calc_count.
-
#calc_mode ⇒ Object
Returns the value of attribute calc_mode.
-
#col_default_width ⇒ Object
Returns the value of attribute col_default_width.
-
#cols ⇒ Object
Returns the value of attribute cols.
-
#cols_right_to_left ⇒ Object
Returns the value of attribute cols_right_to_left.
-
#copies_num ⇒ Object
Returns the value of attribute copies_num.
-
#delta ⇒ Object
Returns the value of attribute delta.
-
#dialogue_sheet ⇒ Object
Returns the value of attribute dialogue_sheet.
-
#first_visible_col ⇒ Object
Returns the value of attribute first_visible_col.
-
#first_visible_row ⇒ Object
Returns the value of attribute first_visible_row.
-
#fit_height_to_pages ⇒ Object
Returns the value of attribute fit_height_to_pages.
-
#fit_num_pages ⇒ Object
Returns the value of attribute fit_num_pages.
-
#fit_width_to_pages ⇒ Object
Returns the value of attribute fit_width_to_pages.
-
#footer_margin ⇒ Object
Returns the value of attribute footer_margin.
-
#footer_str ⇒ Object
Returns the value of attribute footer_str.
-
#formula_options ⇒ Object
Returns the value of attribute formula_options.
-
#grid_colour ⇒ Object
Returns the value of attribute grid_colour.
-
#grid_set ⇒ Object
Returns the value of attribute grid_set.
-
#header_margin ⇒ Object
Returns the value of attribute header_margin.
-
#header_str ⇒ Object
Returns the value of attribute header_str.
-
#horz_page_breaks ⇒ Object
Returns the value of attribute horz_page_breaks.
-
#horz_split_first_visible ⇒ Object
Returns the value of attribute horz_split_first_visible.
-
#horz_split_pos ⇒ Object
Returns the value of attribute horz_split_pos.
-
#left_margin ⇒ Object
Returns the value of attribute left_margin.
-
#merged_ranges ⇒ Object
Returns the value of attribute merged_ranges.
-
#name ⇒ Object
Returns the value of attribute name.
-
#normal_magn ⇒ Object
Returns the value of attribute normal_magn.
-
#obj_protect ⇒ Object
Returns the value of attribute obj_protect.
-
#outline_below ⇒ Object
Returns the value of attribute outline_below.
-
#outline_right ⇒ Object
Returns the value of attribute outline_right.
-
#page_preview ⇒ Object
Returns the value of attribute page_preview.
-
#panes_frozen ⇒ Object
Returns the value of attribute panes_frozen.
-
#paper_size_code ⇒ Object
Returns the value of attribute paper_size_code.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#password ⇒ Object
Returns the value of attribute password.
-
#portrait ⇒ Object
Returns the value of attribute portrait.
-
#preview_magn ⇒ Object
Returns the value of attribute preview_magn.
-
#print_centered_horz ⇒ Object
Returns the value of attribute print_centered_horz.
-
#print_centered_vert ⇒ Object
Returns the value of attribute print_centered_vert.
-
#print_draft ⇒ Object
Returns the value of attribute print_draft.
-
#print_grid ⇒ Object
Returns the value of attribute print_grid.
-
#print_headers ⇒ Object
Returns the value of attribute print_headers.
-
#print_hres ⇒ Object
Returns the value of attribute print_hres.
-
#print_in_rows ⇒ Object
Returns the value of attribute print_in_rows.
-
#print_not_colour ⇒ Object
Returns the value of attribute print_not_colour.
-
#print_notes ⇒ Object
Returns the value of attribute print_notes.
-
#print_notes_at_end ⇒ Object
Returns the value of attribute print_notes_at_end.
-
#print_omit_errors ⇒ Object
Returns the value of attribute print_omit_errors.
-
#print_scaling ⇒ Object
Returns the value of attribute print_scaling.
-
#print_vres ⇒ Object
Returns the value of attribute print_vres.
-
#protect ⇒ Object
Returns the value of attribute protect.
-
#remove_splits ⇒ Object
Returns the value of attribute remove_splits.
-
#right_margin ⇒ Object
Returns the value of attribute right_margin.
-
#rows ⇒ Object
Returns the value of attribute rows.
-
#save_recalc ⇒ Object
Returns the value of attribute save_recalc.
-
#scen_protect ⇒ Object
Returns the value of attribute scen_protect.
-
#selected ⇒ Object
Returns the value of attribute selected.
-
#sheet_visible ⇒ Object
RED HERRING ALERT: “sheet_visible” is a clone of the “selected” attribute.
-
#show_auto_page_breaks ⇒ Object
Returns the value of attribute show_auto_page_breaks.
-
#show_col_outline ⇒ Object
Returns the value of attribute show_col_outline.
-
#show_empty_as_zero ⇒ Object
Returns the value of attribute show_empty_as_zero.
-
#show_formulas ⇒ Object
Returns the value of attribute show_formulas.
-
#show_grid ⇒ Object
Returns the value of attribute show_grid.
-
#show_headers ⇒ Object
Returns the value of attribute show_headers.
-
#show_outline ⇒ Object
Returns the value of attribute show_outline.
-
#show_row_outline ⇒ Object
Returns the value of attribute show_row_outline.
-
#start_page_number ⇒ Object
Returns the value of attribute start_page_number.
-
#top_margin ⇒ Object
Returns the value of attribute top_margin.
-
#vert_page_breaks ⇒ Object
Returns the value of attribute vert_page_breaks.
-
#vert_split_first_visible ⇒ Object
Returns the value of attribute vert_split_first_visible.
-
#vert_split_pos ⇒ Object
Returns the value of attribute vert_split_pos.
-
#visibility ⇒ Object
Returns the value of attribute visibility.
-
#wnd_protect ⇒ Object
Returns the value of attribute wnd_protect.
Instance Method Summary collapse
-
#col(index) ⇒ Object
(also: #column)
Fetch the col indicated by index, or create it if necessary.
- #col_width(column_index) ⇒ Object
- #default_row_height_record ⇒ Object
- #dimensions_rec ⇒ Object
- #guts_record ⇒ Object
- #hide_column(c) ⇒ Object
- #hide_columns(col_range) ⇒ Object
- #hyperlink_table_record ⇒ Object
-
#initialize(name, parent) ⇒ Worksheet
constructor
A new instance of Worksheet.
- #insert_bitmap(filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1) ⇒ Object
-
#merge(r1, r2, c1, c2, style = @parent.styles.default_style) ⇒ Object
Comment from xlwt: Stand-alone merge of previously written cells.
- #panes_record ⇒ Object
-
#row(index) ⇒ Object
Fetch the row indicated by index, or create it if necessary.
-
#row_default_height ⇒ Object
Accessors Performing Conversions.
- #row_default_height=(pixels) ⇒ Object
- #row_height(row) ⇒ Object
- #set_cell_style(r, c, style, create_blanks = false) ⇒ Object
-
#set_column_width(c, width) ⇒ Object
TODO fix this if column doesn’t exist yet.
- #set_column_widths(col_range, width) ⇒ Object
-
#set_range_style(row_range, col_range, style, create_blanks = false) ⇒ Object
Change the style for a range of cells.
- #setup_page_record ⇒ Object
- #to_biff ⇒ Object
- #unhide_column(c) ⇒ Object
- #unhide_columns(col_range) ⇒ Object
- #window_2_record ⇒ Object
-
#write(r, c, label = "", style = nil) ⇒ Object
TODO get rid of meaningless default value for label, should be required?.
- #write_array_to_column(array, c, r = 0, style = true) ⇒ Object
- #write_array_to_row(array, r, c = 0, style = true) ⇒ Object
- #write_arrays(r, c, array_of_arrays, style = true) ⇒ Object
- #write_merge(r1, r2, c1, c2, label = "", style = @parent.styles.default_style) ⇒ Object
- #wsbool_record ⇒ Object
Methods included from Utilities
#as_boolean, #as_excel_date, #as_numeric, #binary_string_to_hex_array, #cell_to_packed_rowcol, #cell_to_rowcol, #col_by_name, #hex, #hex_array_to_binary_string, #mock_unicode_string, #pixels_to_points, #pixels_to_twips, #points_to_pixels, #twips_to_pixels
Constructor Details
#initialize(name, parent) ⇒ Worksheet
Returns a new instance of Worksheet.
94 95 96 97 98 99 100 101 102 103 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/surpass/worksheet.rb', line 94 def initialize(name, parent) @name = name @parent = parent @rows = {} @cols = {} @merged_ranges = [] @bmp_rec = '' @show_formulas = 0 @show_grid = 1 @show_headers = 1 @panes_frozen = 0 @show_empty_as_zero = 1 @auto_colour_grid = 1 @cols_right_to_left = 0 @show_outline = 1 @remove_splits = 0 @selected = 0 @sheet_visible = 0 @page_preview = 0 @first_visible_row = 0 @first_visible_col = 0 @grid_colour = 0x40 @preview_magn = 0 @normal_magn = 0 @visibility = 0 @vert_split_pos = nil @horz_split_pos = nil @vert_split_first_visible = nil @horz_split_first_visible = nil @split_active_pane = nil # TODO test implications of converting None -> Nil @row_gut_width = 0 @col_gut_height = 0 @show_auto_page_breaks = 1 @dialogue_sheet = 0 @auto_style_outline = 0 @outline_below = 0 @outline_right = 0 @fit_num_pages = 0 @show_row_outline = 1 @show_col_outline = 1 @alt_expr_eval = 0 @alt_formula_entries = 0 @row_default_height = 0x00FF @col_default_width = 0x0008 @default_row_height_mismatch = 0 @default_row_hidden = 0 @default_row_space_above = 0 @default_row_space_below = 0 @calc_mode = 1 @calc_count = 0x0064 @rc_ref_mode = 1 @iterations_on = 0 @delta = 0.001 @save_recalc = 0 @formula_options = Formula::RECALC_ALWAYS | Formula::CALC_ON_OPEN @print_headers = 0 @print_grid = 0 @grid_set = 1 @vert_page_breaks = [] @horz_page_breaks = [] @header_str = '&P' @footer_str = '&F' @print_centered_vert = 0 @print_centered_horz = 1 @left_margin = 0.3 #0.5 @right_margin = 0.3 #0.5 @top_margin = 0.61 #1.0 @bottom_margin = 0.37 #1.0 @paper_size_code = 9 # A4 @print_scaling = 100 @start_page_number = 1 @fit_width_to_pages = 1 @fit_height_to_pages = 1 @print_in_rows = 1 @portrait = 1 @print_not_colour = 0 @print_draft = 0 @print_notes = 0 @print_notes_at_end = 0 @print_omit_errors = 0 @print_hres = 0x012C # 300 dpi @print_vres = 0x012C # 300 dpi @header_margin = 0.1 @footer_margin = 0.1 @copies_num = 1 @wnd_protect = 0 @obj_protect = 0 @protect = 0 @scen_protect = 0 @password = '' @charts = [] end |
Instance Attribute Details
#alt_expr_eval ⇒ Object
Returns the value of attribute alt_expr_eval.
81 82 83 |
# File 'lib/surpass/worksheet.rb', line 81 def alt_expr_eval @alt_expr_eval end |
#alt_formula_entries ⇒ Object
Returns the value of attribute alt_formula_entries.
82 83 84 |
# File 'lib/surpass/worksheet.rb', line 82 def alt_formula_entries @alt_formula_entries end |
#auto_colour_grid ⇒ Object
Returns the value of attribute auto_colour_grid.
15 16 17 |
# File 'lib/surpass/worksheet.rb', line 15 def auto_colour_grid @auto_colour_grid end |
#auto_style_outline ⇒ Object
Returns the value of attribute auto_style_outline.
75 76 77 |
# File 'lib/surpass/worksheet.rb', line 75 def auto_style_outline @auto_style_outline end |
#bmp_rec ⇒ Object
Returns the value of attribute bmp_rec.
9 10 11 |
# File 'lib/surpass/worksheet.rb', line 9 def bmp_rec @bmp_rec end |
#bottom_margin ⇒ Object
Returns the value of attribute bottom_margin.
54 55 56 |
# File 'lib/surpass/worksheet.rb', line 54 def bottom_margin @bottom_margin end |
#calc_count ⇒ Object
Returns the value of attribute calc_count.
86 87 88 |
# File 'lib/surpass/worksheet.rb', line 86 def calc_count @calc_count end |
#calc_mode ⇒ Object
Returns the value of attribute calc_mode.
85 86 87 |
# File 'lib/surpass/worksheet.rb', line 85 def calc_mode @calc_mode end |
#col_default_width ⇒ Object
Returns the value of attribute col_default_width.
84 85 86 |
# File 'lib/surpass/worksheet.rb', line 84 def col_default_width @col_default_width end |
#cols ⇒ Object
Returns the value of attribute cols.
7 8 9 |
# File 'lib/surpass/worksheet.rb', line 7 def cols @cols end |
#cols_right_to_left ⇒ Object
Returns the value of attribute cols_right_to_left.
16 17 18 |
# File 'lib/surpass/worksheet.rb', line 16 def cols_right_to_left @cols_right_to_left end |
#copies_num ⇒ Object
Returns the value of attribute copies_num.
71 72 73 |
# File 'lib/surpass/worksheet.rb', line 71 def copies_num @copies_num end |
#delta ⇒ Object
Returns the value of attribute delta.
39 40 41 |
# File 'lib/surpass/worksheet.rb', line 39 def delta @delta end |
#dialogue_sheet ⇒ Object
Returns the value of attribute dialogue_sheet.
74 75 76 |
# File 'lib/surpass/worksheet.rb', line 74 def dialogue_sheet @dialogue_sheet end |
#first_visible_col ⇒ Object
Returns the value of attribute first_visible_col.
29 30 31 |
# File 'lib/surpass/worksheet.rb', line 29 def first_visible_col @first_visible_col end |
#first_visible_row ⇒ Object
Returns the value of attribute first_visible_row.
28 29 30 |
# File 'lib/surpass/worksheet.rb', line 28 def first_visible_row @first_visible_row end |
#fit_height_to_pages ⇒ Object
Returns the value of attribute fit_height_to_pages.
59 60 61 |
# File 'lib/surpass/worksheet.rb', line 59 def fit_height_to_pages @fit_height_to_pages end |
#fit_num_pages ⇒ Object
Returns the value of attribute fit_num_pages.
78 79 80 |
# File 'lib/surpass/worksheet.rb', line 78 def fit_num_pages @fit_num_pages end |
#fit_width_to_pages ⇒ Object
Returns the value of attribute fit_width_to_pages.
58 59 60 |
# File 'lib/surpass/worksheet.rb', line 58 def fit_width_to_pages @fit_width_to_pages end |
#footer_margin ⇒ Object
Returns the value of attribute footer_margin.
70 71 72 |
# File 'lib/surpass/worksheet.rb', line 70 def @footer_margin end |
#footer_str ⇒ Object
Returns the value of attribute footer_str.
48 49 50 |
# File 'lib/surpass/worksheet.rb', line 48 def @footer_str end |
#formula_options ⇒ Object
Returns the value of attribute formula_options.
41 42 43 |
# File 'lib/surpass/worksheet.rb', line 41 def @formula_options end |
#grid_colour ⇒ Object
Returns the value of attribute grid_colour.
30 31 32 |
# File 'lib/surpass/worksheet.rb', line 30 def grid_colour @grid_colour end |
#grid_set ⇒ Object
Returns the value of attribute grid_set.
44 45 46 |
# File 'lib/surpass/worksheet.rb', line 44 def grid_set @grid_set end |
#header_margin ⇒ Object
Returns the value of attribute header_margin.
69 70 71 |
# File 'lib/surpass/worksheet.rb', line 69 def header_margin @header_margin end |
#header_str ⇒ Object
Returns the value of attribute header_str.
47 48 49 |
# File 'lib/surpass/worksheet.rb', line 47 def header_str @header_str end |
#horz_page_breaks ⇒ Object
Returns the value of attribute horz_page_breaks.
46 47 48 |
# File 'lib/surpass/worksheet.rb', line 46 def horz_page_breaks @horz_page_breaks end |
#horz_split_first_visible ⇒ Object
Returns the value of attribute horz_split_first_visible.
37 38 39 |
# File 'lib/surpass/worksheet.rb', line 37 def horz_split_first_visible @horz_split_first_visible end |
#horz_split_pos ⇒ Object
Returns the value of attribute horz_split_pos.
35 36 37 |
# File 'lib/surpass/worksheet.rb', line 35 def horz_split_pos @horz_split_pos end |
#left_margin ⇒ Object
Returns the value of attribute left_margin.
51 52 53 |
# File 'lib/surpass/worksheet.rb', line 51 def left_margin @left_margin end |
#merged_ranges ⇒ Object
Returns the value of attribute merged_ranges.
8 9 10 |
# File 'lib/surpass/worksheet.rb', line 8 def merged_ranges @merged_ranges end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/surpass/worksheet.rb', line 4 def name @name end |
#normal_magn ⇒ Object
Returns the value of attribute normal_magn.
32 33 34 |
# File 'lib/surpass/worksheet.rb', line 32 def normal_magn @normal_magn end |
#obj_protect ⇒ Object
Returns the value of attribute obj_protect.
90 91 92 |
# File 'lib/surpass/worksheet.rb', line 90 def obj_protect @obj_protect end |
#outline_below ⇒ Object
Returns the value of attribute outline_below.
76 77 78 |
# File 'lib/surpass/worksheet.rb', line 76 def outline_below @outline_below end |
#outline_right ⇒ Object
Returns the value of attribute outline_right.
77 78 79 |
# File 'lib/surpass/worksheet.rb', line 77 def outline_right @outline_right end |
#page_preview ⇒ Object
Returns the value of attribute page_preview.
27 28 29 |
# File 'lib/surpass/worksheet.rb', line 27 def page_preview @page_preview end |
#panes_frozen ⇒ Object
Returns the value of attribute panes_frozen.
13 14 15 |
# File 'lib/surpass/worksheet.rb', line 13 def panes_frozen @panes_frozen end |
#paper_size_code ⇒ Object
Returns the value of attribute paper_size_code.
55 56 57 |
# File 'lib/surpass/worksheet.rb', line 55 def paper_size_code @paper_size_code end |
#parent ⇒ Object
Returns the value of attribute parent.
5 6 7 |
# File 'lib/surpass/worksheet.rb', line 5 def parent @parent end |
#password ⇒ Object
Returns the value of attribute password.
92 93 94 |
# File 'lib/surpass/worksheet.rb', line 92 def password @password end |
#portrait ⇒ Object
Returns the value of attribute portrait.
61 62 63 |
# File 'lib/surpass/worksheet.rb', line 61 def portrait @portrait end |
#preview_magn ⇒ Object
Returns the value of attribute preview_magn.
31 32 33 |
# File 'lib/surpass/worksheet.rb', line 31 def preview_magn @preview_magn end |
#print_centered_horz ⇒ Object
Returns the value of attribute print_centered_horz.
50 51 52 |
# File 'lib/surpass/worksheet.rb', line 50 def print_centered_horz @print_centered_horz end |
#print_centered_vert ⇒ Object
Returns the value of attribute print_centered_vert.
49 50 51 |
# File 'lib/surpass/worksheet.rb', line 49 def print_centered_vert @print_centered_vert end |
#print_draft ⇒ Object
Returns the value of attribute print_draft.
63 64 65 |
# File 'lib/surpass/worksheet.rb', line 63 def print_draft @print_draft end |
#print_grid ⇒ Object
Returns the value of attribute print_grid.
43 44 45 |
# File 'lib/surpass/worksheet.rb', line 43 def print_grid @print_grid end |
#print_headers ⇒ Object
Returns the value of attribute print_headers.
42 43 44 |
# File 'lib/surpass/worksheet.rb', line 42 def print_headers @print_headers end |
#print_hres ⇒ Object
Returns the value of attribute print_hres.
67 68 69 |
# File 'lib/surpass/worksheet.rb', line 67 def print_hres @print_hres end |
#print_in_rows ⇒ Object
Returns the value of attribute print_in_rows.
60 61 62 |
# File 'lib/surpass/worksheet.rb', line 60 def print_in_rows @print_in_rows end |
#print_not_colour ⇒ Object
Returns the value of attribute print_not_colour.
62 63 64 |
# File 'lib/surpass/worksheet.rb', line 62 def print_not_colour @print_not_colour end |
#print_notes ⇒ Object
Returns the value of attribute print_notes.
64 65 66 |
# File 'lib/surpass/worksheet.rb', line 64 def print_notes @print_notes end |
#print_notes_at_end ⇒ Object
Returns the value of attribute print_notes_at_end.
65 66 67 |
# File 'lib/surpass/worksheet.rb', line 65 def print_notes_at_end @print_notes_at_end end |
#print_omit_errors ⇒ Object
Returns the value of attribute print_omit_errors.
66 67 68 |
# File 'lib/surpass/worksheet.rb', line 66 def print_omit_errors @print_omit_errors end |
#print_scaling ⇒ Object
Returns the value of attribute print_scaling.
56 57 58 |
# File 'lib/surpass/worksheet.rb', line 56 def print_scaling @print_scaling end |
#print_vres ⇒ Object
Returns the value of attribute print_vres.
68 69 70 |
# File 'lib/surpass/worksheet.rb', line 68 def print_vres @print_vres end |
#protect ⇒ Object
Returns the value of attribute protect.
88 89 90 |
# File 'lib/surpass/worksheet.rb', line 88 def protect @protect end |
#remove_splits ⇒ Object
Returns the value of attribute remove_splits.
18 19 20 |
# File 'lib/surpass/worksheet.rb', line 18 def remove_splits @remove_splits end |
#right_margin ⇒ Object
Returns the value of attribute right_margin.
52 53 54 |
# File 'lib/surpass/worksheet.rb', line 52 def right_margin @right_margin end |
#rows ⇒ Object
Returns the value of attribute rows.
6 7 8 |
# File 'lib/surpass/worksheet.rb', line 6 def rows @rows end |
#save_recalc ⇒ Object
Returns the value of attribute save_recalc.
40 41 42 |
# File 'lib/surpass/worksheet.rb', line 40 def save_recalc @save_recalc end |
#scen_protect ⇒ Object
Returns the value of attribute scen_protect.
91 92 93 |
# File 'lib/surpass/worksheet.rb', line 91 def scen_protect @scen_protect end |
#selected ⇒ Object
Returns the value of attribute selected.
19 20 21 |
# File 'lib/surpass/worksheet.rb', line 19 def selected @selected end |
#sheet_visible ⇒ Object
RED HERRING ALERT: “sheet_visible” is a clone of the “selected” attribute. Typically a workbook created by the Excel UI will have one sheet (the sheet that was selected when the user saved it) with both bits set to 1, and all other sheets will have both bits set to 0. The true visibility of the sheet is found in the “visibility” attribute obtained from the BOUNDSHEET record.
26 27 28 |
# File 'lib/surpass/worksheet.rb', line 26 def sheet_visible @sheet_visible end |
#show_auto_page_breaks ⇒ Object
Returns the value of attribute show_auto_page_breaks.
73 74 75 |
# File 'lib/surpass/worksheet.rb', line 73 def show_auto_page_breaks @show_auto_page_breaks end |
#show_col_outline ⇒ Object
Returns the value of attribute show_col_outline.
80 81 82 |
# File 'lib/surpass/worksheet.rb', line 80 def show_col_outline @show_col_outline end |
#show_empty_as_zero ⇒ Object
Returns the value of attribute show_empty_as_zero.
14 15 16 |
# File 'lib/surpass/worksheet.rb', line 14 def show_empty_as_zero @show_empty_as_zero end |
#show_formulas ⇒ Object
Returns the value of attribute show_formulas.
10 11 12 |
# File 'lib/surpass/worksheet.rb', line 10 def show_formulas @show_formulas end |
#show_grid ⇒ Object
Returns the value of attribute show_grid.
11 12 13 |
# File 'lib/surpass/worksheet.rb', line 11 def show_grid @show_grid end |
#show_headers ⇒ Object
Returns the value of attribute show_headers.
12 13 14 |
# File 'lib/surpass/worksheet.rb', line 12 def show_headers @show_headers end |
#show_outline ⇒ Object
Returns the value of attribute show_outline.
17 18 19 |
# File 'lib/surpass/worksheet.rb', line 17 def show_outline @show_outline end |
#show_row_outline ⇒ Object
Returns the value of attribute show_row_outline.
79 80 81 |
# File 'lib/surpass/worksheet.rb', line 79 def show_row_outline @show_row_outline end |
#start_page_number ⇒ Object
Returns the value of attribute start_page_number.
57 58 59 |
# File 'lib/surpass/worksheet.rb', line 57 def start_page_number @start_page_number end |
#top_margin ⇒ Object
Returns the value of attribute top_margin.
53 54 55 |
# File 'lib/surpass/worksheet.rb', line 53 def top_margin @top_margin end |
#vert_page_breaks ⇒ Object
Returns the value of attribute vert_page_breaks.
45 46 47 |
# File 'lib/surpass/worksheet.rb', line 45 def vert_page_breaks @vert_page_breaks end |
#vert_split_first_visible ⇒ Object
Returns the value of attribute vert_split_first_visible.
36 37 38 |
# File 'lib/surpass/worksheet.rb', line 36 def vert_split_first_visible @vert_split_first_visible end |
#vert_split_pos ⇒ Object
Returns the value of attribute vert_split_pos.
34 35 36 |
# File 'lib/surpass/worksheet.rb', line 34 def vert_split_pos @vert_split_pos end |
#visibility ⇒ Object
Returns the value of attribute visibility.
33 34 35 |
# File 'lib/surpass/worksheet.rb', line 33 def visibility @visibility end |
#wnd_protect ⇒ Object
Returns the value of attribute wnd_protect.
89 90 91 |
# File 'lib/surpass/worksheet.rb', line 89 def wnd_protect @wnd_protect end |
Instance Method Details
#col(index) ⇒ Object Also known as: column
Fetch the col indicated by index, or create it if necessary.
547 548 549 |
# File 'lib/surpass/worksheet.rb', line 547 def col(index) cols[index] ||= Column.new(index, self) end |
#col_width(column_index) ⇒ Object
560 561 562 563 564 565 566 |
# File 'lib/surpass/worksheet.rb', line 560 def col_width(column_index) if cols.keys.include?(column_index) cols[column_index].width_in_pixels else 64 end end |
#default_row_height_record ⇒ Object
405 406 407 408 409 410 411 412 413 |
# File 'lib/surpass/worksheet.rb', line 405 def default_row_height_record = 0x00 |= (@default_row_height_mismatch & 0x01) << 0 |= (@default_row_hidden & 0x01) << 1 |= (@default_row_space_above & 0x01) << 2 |= (@default_row_space_below & 0x01) << 3 DefaultRowHeight.new(, @row_default_height).to_biff end |
#dimensions_rec ⇒ Object
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
# File 'lib/surpass/worksheet.rb', line 431 def dimensions_rec first_used_row = 0 last_used_row = 0 first_used_col = 0 last_used_col = 0 if !@rows.empty? first_used_row = @rows.keys.sort.first last_used_row = @rows.keys.sort.last first_used_col = 0xFFFFFFFF last_used_col = 0 end first_used_col = @rows.values.inject(first_used_col) {|min_col, r| r.min_col_index < min_col ? min_col = r.min_col_index : min_col } last_used_col = @rows.values.inject(last_used_col) {|max_col, r| r.max_col_index > max_col ? max_col = r.max_col_index : max_col } DimensionsRecord.new(first_used_row, last_used_row, first_used_col, last_used_col).to_biff end |
#guts_record ⇒ Object
395 396 397 398 399 400 401 402 403 |
# File 'lib/surpass/worksheet.rb', line 395 def guts_record max_row_level = @rows.values.inject(-1) {|level, row| row.level > level ? row.level : level } max_col_level = @cols.values.inject(-1) {|level, col| col.level > level ? col.level : level } row_visible_levels = @rows.empty? ? 0 : max_row_level + 1 col_visible_levels = @cols.empty? ? 0 : max_col_level + 1 GutsRecord.new(@row_gut_width, @col_gut_height, row_visible_levels, col_visible_levels).to_biff end |
#hide_column(c) ⇒ Object
237 238 239 |
# File 'lib/surpass/worksheet.rb', line 237 def hide_column(c) col(c).hidden = true end |
#hide_columns(col_range) ⇒ Object
219 220 221 222 223 |
# File 'lib/surpass/worksheet.rb', line 219 def hide_columns(col_range) col_range.each do |c| hide_column(c) end end |
#hyperlink_table_record ⇒ Object
529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/surpass/worksheet.rb', line 529 def hyperlink_table_record result = '' return result if @links.nil? @links.each do |a, b| x, y = a url, target, textmark, description = b result += HyperlinkRecord.new(x, x, y, y, url, target, textmark, description).to_biff result += QuicktipRecord(x, x, y, y).to_biff unless description.nil? end result end |
#insert_bitmap(filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1) ⇒ Object
568 569 570 571 572 573 |
# File 'lib/surpass/worksheet.rb', line 568 def insert_bitmap(filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1) bmp = ImDataBmpRecord.new(filename) obj = ObjBmpRecord.new(row, col, self, bmp, x, y, scale_x, scale_y) @bmp_rec += obj.to_biff + bmp.to_biff end |
#merge(r1, r2, c1, c2, style = @parent.styles.default_style) ⇒ Object
Comment from xlwt: Stand-alone merge of previously written cells. Problems: (1) style to be used should be existing style of the top-left cell, not an arg. (2) should ensure that any previous data value in non-top-left cells is nobbled. Note: if a cell is set by a data record then later is referenced by a [MUL]BLANK record, Excel will blank out the cell on the screen, but OOo & Gnu will not blank it out. Need to do something better than writing multiple records. In the meantime, avoid this method and use write_merge() instead.
319 320 321 322 323 324 325 |
# File 'lib/surpass/worksheet.rb', line 319 def merge(r1, r2, c1, c2, style = @parent.styles.default_style) row(r1).write_blanks(c1 + 1, c2, style) if c2 > c1 ((r1+1)...(r2+1)).each do |r| row(r).write_blanks(c1, c2, style) end @merged_ranges << [r1, r2, c1, c2] end |
#panes_record ⇒ Object
506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/surpass/worksheet.rb', line 506 def panes_record return '' if @vert_split_pos.nil? && @horz_split_pos.nil? @vert_split_pos = 0 if @vert_split_pos.nil? @horz_split_pos = 0 if @horz_split_pos.nil? if @panes_frozen @vert_split_first_visible = @vert_split_pos if @vert_split_first_visible.nil? @horz_split_first_visible = @horz_split_pos if @horz_split_first_visible.nil? else @vert_split_first_visible = 0 if @vert_split_first_visible.nil? @horz_split_first_visible = 0 if @horz_split_first_visible.nil? # inspired by pyXLWriter @horz_split_pos = 20 * @horz_split_pos + 255 @vert_split_pos = 113.879 * @vert_split_pos + 390 end @split_active_pane = 0 if @vert_split_pos > 0 and @horz_split_pos > 0 @split_active_pane = 1 if @vert_split_pos < 0 and @horz_split_pos == 0 @split_active_pane = 2 if @vert_split_pos == 0 and @horz_split_pos > 0 @split_active_pane = 3 args = [@vert_split_pos, @horz_split_pos, @horz_split_first_visible, @vert_split_first_visible, @split_active_pane] PanesRecord.new(*args).to_biff end |
#row(index) ⇒ Object
Fetch the row indicated by index, or create it if necessary.
542 543 544 |
# File 'lib/surpass/worksheet.rb', line 542 def row(index) rows[index] ||= Row.new(index, self) end |
#row_default_height ⇒ Object
Accessors Performing Conversions
198 199 200 |
# File 'lib/surpass/worksheet.rb', line 198 def row_default_height twips_to_pixels(@row_default_height) end |
#row_default_height=(pixels) ⇒ Object
202 203 204 |
# File 'lib/surpass/worksheet.rb', line 202 def row_default_height=(pixels) @row_default_height = pixels_to_twips(pixels) end |
#row_height(row) ⇒ Object
552 553 554 555 556 557 558 |
# File 'lib/surpass/worksheet.rb', line 552 def row_height(row) if @rows.include?(row) @rows[row].height_in_pixels else 17 end end |
#set_cell_style(r, c, style, create_blanks = false) ⇒ Object
210 211 212 213 214 215 216 217 |
# File 'lib/surpass/worksheet.rb', line 210 def set_cell_style(r, c, style, create_blanks = false) cell = rows[r].cell(c) if cell.nil? write(r, c, nil, style) if create_blanks else cell.set_style(style) end end |
#set_column_width(c, width) ⇒ Object
TODO fix this if column doesn’t exist yet.
246 247 248 249 250 251 252 253 |
# File 'lib/surpass/worksheet.rb', line 246 def set_column_width(c, width) if width < 100 # Assume we are trying to use Excel-user style widths, scale up accordingly. # You can call col's width method directly to avoid this. width = width * 260 end col(c).width = width end |
#set_column_widths(col_range, width) ⇒ Object
231 232 233 234 235 |
# File 'lib/surpass/worksheet.rb', line 231 def set_column_widths(col_range, width) col_range.each do |c| set_column_width(c, width) end end |
#set_range_style(row_range, col_range, style, create_blanks = false) ⇒ Object
Change the style for a range of cells. If nil is supplied for row_range, the new style is supplied to every row (i.e. the entire column). Only changes style for cells which actually exist, so this does not paint anything which has not been written to.
259 260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/surpass/worksheet.rb', line 259 def set_range_style(row_range, col_range, style, create_blanks = false) row_range ||= 0..65535 col_range ||= 0..255 @rows.each do |i, r| next unless row_range.include?(i) r.cells.each do |c| next unless col_range.include?(c.col) c.set_style(style) end end end |
#setup_page_record ⇒ Object
450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 |
# File 'lib/surpass/worksheet.rb', line 450 def setup_page_record = (@print_in_rows & 0x01) << 0 |= (@portrait & 0x01) << 1 |= (0x00 & 0x01) << 2 |= (@print_not_colour & 0x01) << 3 |= (@print_draft & 0x01) << 4 |= (@print_notes & 0x01) << 5 |= (0x00 & 0x01) << 6 |= (0x01 & 0x01) << 7 |= (@print_notes_at_end & 0x01) << 9 |= (@print_omit_errors & 0x03) << 10 args = [ @paper_size_code, @print_scaling, @start_page_number, @fit_width_to_pages, @fit_height_to_pages, , @print_hres, @print_vres, @header_margin, @footer_margin, @copies_num ] SetupPageRecord.new(*args).to_biff end |
#to_biff ⇒ Object
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/surpass/worksheet.rb', line 333 def to_biff result = [] result << Biff8BOFRecord.new(Biff8BOFRecord::WORKSHEET).to_biff # Calc Settings result << CalcModeRecord.new(@calc_mode).to_biff result << CalcCountRecord.new(@calc_count & 0xFFFF).to_biff result << RefModeRecord.new(@rc_ref_mode & 0x01).to_biff result << IterationRecord.new(@iterations_on & 0x01).to_biff result << DeltaRecord.new(@delta).to_biff result << SaveRecalcRecord.new(@save_recalc & 0x01).to_biff result << guts_record result << default_row_height_record result << wsbool_record result << @cols.sort.collect {|k, v| v.to_biff }.join result << dimensions_rec ### @end # Print Settings result << PrintHeadersRecord.new(@print_headers).to_biff result << PrintGridLinesRecord.new(@print_grid).to_biff result << GridSetRecord.new(@grid_set).to_biff result << HorizontalPageBreaksRecord.new(@horz_page_breaks.collect {|b| b.is_a?(Integer) ? [b, 0, -1] : b }).to_biff result << VerticalPageBreaksRecord.new(@vert_page_breaks.collect {|b| b.is_a?(Integer) ? [b, 0, -1] : b }).to_biff result << HeaderRecord.new(@header_str).to_biff result << FooterRecord.new(@footer_str).to_biff result << HCenterRecord.new(@print_centered_horz).to_biff result << VCenterRecord.new(@print_centered_vert).to_biff result << LeftMarginRecord.new(@left_margin).to_biff result << RightMarginRecord.new(@right_margin).to_biff result << TopMarginRecord.new(@top_margin).to_biff result << BottomMarginRecord.new(@bottom_margin).to_biff result << setup_page_record # Protection Settings result << ProtectRecord.new(as_numeric(@protect)).to_biff() result << ScenarioProtectRecord.new(as_numeric(@scen_protect)).to_biff() result << WindowProtectRecord.new(as_numeric(@wnd_protect)).to_biff() result << ObjectProtectRecord.new(as_numeric(@obj_protect)).to_biff() result << PasswordRecord.new(@password).to_biff() ### @export "to-biff-rows" keys = @rows.keys.sort keys.each do |i| result << @rows[i].to_biff result << @rows[i].cells_biff end ### @end # @charts.each do |c| # result << c.to_biff # end result << MergedCellsRecord.new(@merged_ranges).to_biff result << @bmp_rec result << window_2_record result << panes_record # result << hyperlink_table_record result << EOFRecord.new.to_biff result.join end |
#unhide_column(c) ⇒ Object
241 242 243 |
# File 'lib/surpass/worksheet.rb', line 241 def unhide_column(c) col(c).hidden = false end |
#unhide_columns(col_range) ⇒ Object
225 226 227 228 229 |
# File 'lib/surpass/worksheet.rb', line 225 def unhide_columns(col_range) col_range.each do |c| unhide_column(c) end end |
#window_2_record ⇒ Object
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/surpass/worksheet.rb', line 478 def window_2_record = 0 |= (as_numeric(@show_formulas ) & 0x01) << 0 |= (as_numeric(@show_grid ) & 0x01) << 1 |= (as_numeric(@show_headers ) & 0x01) << 2 |= (as_numeric(@panes_frozen ) & 0x01) << 3 |= (as_numeric(@show_empty_as_zero ) & 0x01) << 4 |= (as_numeric(@auto_colour_grid ) & 0x01) << 5 |= (as_numeric(@cols_right_to_left ) & 0x01) << 6 |= (as_numeric(@show_outline ) & 0x01) << 7 |= (as_numeric(@remove_splits ) & 0x01) << 8 |= (as_numeric(@selected ) & 0x01) << 9 |= (as_numeric(@sheet_visible ) & 0x01) << 10 |= (as_numeric(@page_preview ) & 0x01) << 11 if @page_preview != 0 if @preview_magn == 0 scl_magn = 60 else scl_magn = @preview_magn end else scl_magn = @normal_magn end Window2Record.new(, @first_visible_row, @first_visible_col, @grid_colour, @preview_magn, @normal_magn, scl_magn).to_biff end |
#write(r, c, label = "", style = nil) ⇒ Object
TODO get rid of meaningless default value for label, should be required?
274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/surpass/worksheet.rb', line 274 def write(r, c, label = "", style = nil) if label.is_a?(Array) if label[0].is_a?(Array) write_arrays(r, c, label, style || true) else write_array_to_row(label, r, c, style || true) end else row(r).write(c, label, style) end end |
#write_array_to_column(array, c, r = 0, style = true) ⇒ Object
293 294 295 296 297 |
# File 'lib/surpass/worksheet.rb', line 293 def write_array_to_column(array, c, r = 0, style = true) array.each_with_index do |a, i| row(r + i).write(c, a, style) end end |
#write_array_to_row(array, r, c = 0, style = true) ⇒ Object
287 288 289 290 291 |
# File 'lib/surpass/worksheet.rb', line 287 def write_array_to_row(array, r, c = 0, style = true) array.each_with_index do |a, i| row(r).write(c + i, a, style) end end |
#write_arrays(r, c, array_of_arrays, style = true) ⇒ Object
299 300 301 302 303 304 |
# File 'lib/surpass/worksheet.rb', line 299 def write_arrays(r, c, array_of_arrays, style = true) array_of_arrays.each_with_index do |a, i| raise "not an array of arrays!" unless a.is_a?(Array) write_array_to_row(a, r + i, c, style) end end |
#write_merge(r1, r2, c1, c2, label = "", style = @parent.styles.default_style) ⇒ Object
327 328 329 330 |
# File 'lib/surpass/worksheet.rb', line 327 def write_merge(r1, r2, c1, c2, label="", style = @parent.styles.default_style) write(r1, c1, label, style) merge(r1, r2, c1, c2, style) end |
#wsbool_record ⇒ Object
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/surpass/worksheet.rb', line 415 def wsbool_record = 0x00 |= (@show_auto_page_breaks & 0x01) << 0 |= (@dialogue_sheet & 0x01) << 4 |= (@auto_style_outline & 0x01) << 5 |= (@outline_below & 0x01) << 6 |= (@outline_right & 0x01) << 7 |= (@fit_num_pages & 0x01) << 8 |= (@show_row_outline & 0x01) << 10 |= (@show_col_outline & 0x01) << 11 |= (@alt_expr_eval & 0x01) << 14 |= (@alt_formula_entries & 0x01) << 15 WSBoolRecord.new().to_biff end |