Class: Excel::Worksheet
- Inherits:
-
Object
show all
- Extended by:
- Deco
- Defined in:
- lib/ru_excel/worksheet.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#_bitmaps_rec ⇒ Object
-
#_bof_rec ⇒ Object
-
#_calc_settings_rec ⇒ Object
-
#_colinfo_rec ⇒ Object
-
#_dimensions_rec ⇒ Object
-
#_eof_rec ⇒ Object
-
#_guts_rec ⇒ Object
-
#_merged_rec ⇒ Object
-
#_panes_rec ⇒ Object
-
#_print_settings_rec ⇒ Object
-
#_protection_rec ⇒ Object
-
#_row_blocks_rec ⇒ Object
-
#_window2_rec ⇒ Object
-
#_wsbool_rec ⇒ Object
-
#calc_mode ⇒ Object
-
#calc_mode=(value) ⇒ Object
Properties, “getters”, “setters”.
-
#col(indx) ⇒ Object
-
#col_width(col) ⇒ Object
-
#get_biff_data ⇒ Object
-
#initialize(sheetname, parent_book) ⇒ Worksheet
constructor
-
#insert_bitmap(filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1) ⇒ Object
-
#labels_count ⇒ Object
-
#merge(r1, r2, c1, c2, style = Style.XFStyle()) ⇒ Object
-
#row(indx) ⇒ Object
-
#row_height(row) ⇒ Object
-
#write(r, c, label = "", style = XFStyle.new()) ⇒ Object
-
#write_merge(r1, r2, c1, c2, label = "", style = XFStyle.new()) ⇒ Object
Methods included from Deco
absint_accessor, accepts, accepts_bool, array_accessor, bool_accessor, bool_int_accessor, float_accessor, int_accessor, returns, short_accessor, string_accessor, type_accessor
Constructor Details
#initialize(sheetname, parent_book) ⇒ Worksheet
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
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
|
# File 'lib/ru_excel/worksheet.rb', line 54
def initialize(sheetname, parent_book)
@name = sheetname
@parent = parent_book
@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
@hidden = 0
@page_preview = 0
@first_visible_row = 0
@first_visible_col = 0
@grid_colour = 0x40
@preview_magn = 0
@normal_magn = 0
@vert_split_pos = nil
@horz_split_pos = nil
@vert_split_first_visible = nil
@horz_split_first_visible = nil
@split_active_pane =
@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
@calc_mode = 1
@calc_count = 0x0064
@RC_ref_mode = 1
@iterations_on = 0
@delta = 0.001
@save_recalc = 0
@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 @right_margin = 0.3 @top_margin = 0.61 @bottom_margin = 0.37 @paper_size_code = 9 @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 @print_vres = 0x012C @header_margin = 0.1
@footer_margin = 0.1
@copies_num = 1
@wnd_protect = 0
@obj_protect = 0
@protect = 0
@scen_protect = 0
@password = ''
end
|
Instance Attribute Details
#bmp_rec ⇒ Object
Returns the value of attribute bmp_rec.
163
164
165
|
# File 'lib/ru_excel/worksheet.rb', line 163
def bmp_rec
@bmp_rec
end
|
#cols ⇒ Object
Returns the value of attribute cols.
163
164
165
|
# File 'lib/ru_excel/worksheet.rb', line 163
def cols
@cols
end
|
#merged_ranges ⇒ Object
Returns the value of attribute merged_ranges.
163
164
165
|
# File 'lib/ru_excel/worksheet.rb', line 163
def merged_ranges
@merged_ranges
end
|
#parent ⇒ Object
Returns the value of attribute parent.
163
164
165
|
# File 'lib/ru_excel/worksheet.rb', line 163
def parent
@parent
end
|
#rows ⇒ Object
Returns the value of attribute rows.
163
164
165
|
# File 'lib/ru_excel/worksheet.rb', line 163
def rows
@rows
end
|
Instance Method Details
#_bitmaps_rec ⇒ Object
378
379
380
|
# File 'lib/ru_excel/worksheet.rb', line 378
def _bitmaps_rec
@bmp_rec
end
|
#_calc_settings_rec ⇒ Object
382
383
384
385
386
387
388
389
390
391
|
# File 'lib/ru_excel/worksheet.rb', line 382
def _calc_settings_rec
result = ''
result << BiffRecord.calcModeRecord(@calc_mode & 0x01)
result << BiffRecord.calcCountRecord(@calc_count & 0xFFFF)
result << BiffRecord.refModeRecord(@RC_ref_mode & 0x01)
result << BiffRecord.iterationRecord(@iterations_on & 0x01)
result << BiffRecord.deltaRecord(@delta)
result << BiffRecord.saveRecalcRecord(@save_recalc & 0x01)
result
end
|
#_colinfo_rec ⇒ Object
287
288
289
|
# File 'lib/ru_excel/worksheet.rb', line 287
def _colinfo_rec
@cols.map{|k, col| col.get_biff_record}.join('')
end
|
#_dimensions_rec ⇒ Object
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
|
# File 'lib/ru_excel/worksheet.rb', line 291
def _dimensions_rec
first_used_row = 0
last_used_row = 0
first_used_col = 0
last_used_col = 0
if @rows.length > 0
first_used_row = @rows.min[0]
last_used_row = @rows.max[0]
first_used_col = 0xFFFFFFFF
last_used_col = 0
for k,r in @rows
_min = r.get_min_col()
_max = r.get_max_col()
if _min < first_used_col
first_used_col = _min
end
if _max > last_used_col
last_used_col = _max
end
end
end
BiffRecord.dimensionsRecord(first_used_row, last_used_row, first_used_col, last_used_col)
end
|
#_eof_rec ⇒ Object
283
284
285
|
# File 'lib/ru_excel/worksheet.rb', line 283
def _eof_rec
BiffRecord.eofRecord()
end
|
#_guts_rec ⇒ Object
253
254
255
256
257
258
259
260
261
262
263
264
265
|
# File 'lib/ru_excel/worksheet.rb', line 253
def _guts_rec
row_visible_levels = 0
if @rows.length != 0
row_visible_levels = @rows.map{|k,r| r.level}.max + 1
end
col_visible_levels = 0
if @cols.length != 0
col_visible_levels = @cols.map{|k,c| c.level}.max + 1
end
BiffRecord.gutsRecord(@row_gut_width, @col_gut_height, row_visible_levels, col_visible_levels)
end
|
#_panes_rec ⇒ Object
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
|
# File 'lib/ru_excel/worksheet.rb', line 336
def _panes_rec
return "" if @vert_split_pos == nil && @horz_split_pos == nil
@vert_split_pos ||= 0
@horz_split_pos ||= 0
if @panes_frozen
@vert_split_first_visible ||= @vert_split_pos
@horz_split_first_visible ||= @horz_split_pos
else
@vert_split_first_visible ||= 0
@horz_split_first_visible ||= 0
@horz_split_pos = 20*@horz_split_pos + 255
@vert_split_pos = 113.879*@vert_split_pos + 390
end
@split_active_pane = (@vert_split_pos > 0 ? 0 : 2) + (@horz_split_pos > 0 ? 0 : 1)
BiffRecord.panesRecord(@vert_split_pos,
@horz_split_pos,
@horz_split_first_visible,
@vert_split_first_visible,
@split_active_pane)
end
|
#_print_settings_rec ⇒ Object
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
|
# File 'lib/ru_excel/worksheet.rb', line 393
def _print_settings_rec
result = ''
result << BiffRecord.(@print_headers)
result << BiffRecord.printGridLinesRecord(@print_grid)
result << BiffRecord.gridSetRecord(@grid_set)
result << BiffRecord.horizontalPageBreaksRecord(@horz_page_breaks)
result << BiffRecord.verticalPageBreaksRecord(@vert_page_breaks)
result << BiffRecord.(@header_str)
result << BiffRecord.(@footer_str)
result << BiffRecord.hCenterRecord(@print_centered_horz)
result << BiffRecord.vCenterRecord(@print_centered_vert)
result << BiffRecord.leftMarginRecord(@left_margin)
result << BiffRecord.rightMarginRecord(@right_margin)
result << BiffRecord.topMarginRecord(@top_margin)
result << BiffRecord.bottomMarginRecord(@bottom_margin)
setup_page_options = (@print_in_rows & 0x01) << 0
setup_page_options |= (@portrait & 0x01) << 1
setup_page_options |= (0x00 & 0x01) << 2
setup_page_options |= (@print_not_colour & 0x01) << 3
setup_page_options |= (@print_draft & 0x01) << 4
setup_page_options |= (@print_notes & 0x01) << 5
setup_page_options |= (0x00 & 0x01) << 6
setup_page_options |= (0x01 & 0x01) << 7
setup_page_options |= (@print_notes_at_end & 0x01) << 9
setup_page_options |= (@print_omit_errors & 0x03) << 10
result << BiffRecord.(@paper_size_code,
@print_scaling,
@start_page_number,
@fit_width_to_pages,
@fit_height_to_pages,
setup_page_options,
@print_hres,
@print_vres,
@header_margin,
@footer_margin,
@copies_num)
result
end
|
#_protection_rec ⇒ Object
434
435
436
437
438
439
440
441
442
|
# File 'lib/ru_excel/worksheet.rb', line 434
def _protection_rec
result = ''
result << BiffRecord.protectRecord(@protect)
result << BiffRecord.scenProtectRecord(@scen_protect)
result << BiffRecord.windowProtectRecord(@wnd_protect)
result << BiffRecord.objectProtectRecord(@obj_protect)
result << BiffRecord.passwordRecord(@password)
result
end
|
#_row_blocks_rec ⇒ Object
362
363
364
365
366
367
368
369
370
371
372
|
# File 'lib/ru_excel/worksheet.rb', line 362
def _row_blocks_rec
result = []
for k, r in @rows
result << r.get_row_biff_data
result << r.get_cells_biff_data
end
result.join('')
end
|
#_window2_rec ⇒ Object
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
|
# File 'lib/ru_excel/worksheet.rb', line 316
def _window2_rec
options = 0
options |= (@show_formulas & 0x01) << 0
options |= (@show_grid & 0x01) << 1
options |= (@show_headers & 0x01) << 2
options |= (@panes_frozen & 0x01) << 3
options |= (@show_empty_as_zero & 0x01) << 4
options |= (@auto_colour_grid & 0x01) << 5
options |= (@cols_right_to_left & 0x01) << 6
options |= (@show_outline & 0x01) << 7
options |= (@remove_splits & 0x01) << 8
options |= (@selected & 0x01) << 9
options |= (@hidden & 0x01) << 10
options |= (@page_preview & 0x01) << 11
BiffRecord.window2Record(options, @first_visible_row, @first_visible_col,
@grid_colour,
@preview_magn, @normal_magn)
end
|
#_wsbool_rec ⇒ Object
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
# File 'lib/ru_excel/worksheet.rb', line 267
def _wsbool_rec
options = 0x00
options |= (@show_auto_page_breaks & 0x01) << 0
options |= (@dialogue_sheet & 0x01) << 4
options |= (@auto_style_outline & 0x01) << 5
options |= (@outline_below & 0x01) << 6
options |= (@outline_right & 0x01) << 7
options |= (@fit_num_pages & 0x01) << 8
options |= (@show_row_outline & 0x01) << 10
options |= (@show_col_outline & 0x01) << 11
options |= (@alt_expr_eval & 0x01) << 14
options |= (@alt_formula_entries & 0x01) << 15
BiffRecord.wsBoolRecord(options)
end
|
#calc_mode ⇒ Object
155
156
157
|
# File 'lib/ru_excel/worksheet.rb', line 155
def calc_mode
return @calc_mode
end
|
#calc_mode=(value) ⇒ Object
Properties, “getters”, “setters”
152
153
154
|
# File 'lib/ru_excel/worksheet.rb', line 152
def calc_mode=(value)
@calc_mode = value & 0x03
end
|
#col(indx) ⇒ Object
214
215
216
|
# File 'lib/ru_excel/worksheet.rb', line 214
def col(indx)
@cols[indx] ||= Column.new(indx, self)
end
|
#col_width(col) ⇒ Object
230
231
232
233
234
235
|
# File 'lib/ru_excel/worksheet.rb', line 230
def col_width(col) return 64
end
|
#get_biff_data ⇒ Object
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
# File 'lib/ru_excel/worksheet.rb', line 444
def get_biff_data
result = ''
result << _bof_rec()
result << _calc_settings_rec()
result << _guts_rec()
result << _wsbool_rec()
result << _colinfo_rec()
result << _dimensions_rec()
result << _print_settings_rec()
result << _protection_rec()
result << _row_blocks_rec()
result << _merged_rec()
result << _bitmaps_rec()
result << _window2_rec()
result << _panes_rec()
result << _eof_rec()
result
end
|
#insert_bitmap(filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1) ⇒ Object
208
209
210
211
212
213
|
# File 'lib/ru_excel/worksheet.rb', line 208
def insert_bitmap(filename, row, col, x = 0, y = 0, scale_x = 1, scale_y = 1)
bmp = BiffRecord.imDataBmpRecord(filename)
obj = BiffRecord.objBmpRecord(row, col, self, bmp, x, y, scale_x, scale_y)
@bmp_rec += obj + bmp
end
|
#labels_count ⇒ Object
237
238
239
240
241
242
243
|
# File 'lib/ru_excel/worksheet.rb', line 237
def labels_count
result = 0
for r, row in @rows
result += row.get_str_count()
end
return result
end
|
#merge(r1, r2, c1, c2, style = Style.XFStyle()) ⇒ Object
196
197
198
199
200
201
|
# File 'lib/ru_excel/worksheet.rb', line 196
def merge(r1, r2, c1, c2, style=Style.XFStyle())
for r in r1..r2
row(r).write_blanks(c1, c2, style)
end
@merged_ranges << [r1, r2, c1, c2]
end
|
#row(indx) ⇒ Object
218
219
220
|
# File 'lib/ru_excel/worksheet.rb', line 218
def row(indx)
@rows[indx] ||= Row.new(indx, self)
end
|
#row_height(row) ⇒ Object
222
223
224
225
226
227
228
|
# File 'lib/ru_excel/worksheet.rb', line 222
def row_height(row) if (row = @rows[row])
return row.get_height_in_pixels()
else
return 17
end
end
|
#write(r, c, label = "", style = XFStyle.new()) ⇒ Object
192
193
194
|
# File 'lib/ru_excel/worksheet.rb', line 192
def write(r, c, label="", style=XFStyle.new())
row(r).write(c, label, style)
end
|
#write_merge(r1, r2, c1, c2, label = "", style = XFStyle.new()) ⇒ Object
203
204
205
206
|
# File 'lib/ru_excel/worksheet.rb', line 203
def write_merge(r1, r2, c1, c2, label="", style=XFStyle.new())
merge(r1, r2, c1, c2, style)
write(r1, c1, label, style)
end
|