Module: FastExcel::WorkbookExt
Instance Attribute Summary collapse
Instance Method Summary
collapse
#fields_hash, #pretty_print, #set
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
344
345
346
|
# File 'lib/fast_excel.rb', line 344
def filename
@filename
end
|
#is_open ⇒ Object
Returns the value of attribute is_open.
344
345
346
|
# File 'lib/fast_excel.rb', line 344
def is_open
@is_open
end
|
#tmp_file ⇒ Object
Returns the value of attribute tmp_file.
344
345
346
|
# File 'lib/fast_excel.rb', line 344
def tmp_file
@tmp_file
end
|
Instance Method Details
353
354
355
356
357
|
# File 'lib/fast_excel.rb', line 353
def add_format(options = nil)
new_format = super()
new_format.set(options) if options
new_format
end
|
#add_worksheet(sheetname = nil) ⇒ Object
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
# File 'lib/fast_excel.rb', line 375
def add_worksheet(sheetname = nil)
if !sheetname.nil?
error = validate_worksheet_name(sheetname)
if error != :no_error
error_code = ERROR_ENUM.find(error)
error_str = error_code ? Libxlsxwriter.strerror(error_code) : ''
raise ArgumentError, "Invalid worksheet name '#{sheetname}': (#{error_code} - #{error}) #{error_str}"
end
end
sheet = super(sheetname)
sheet.workbook = self
@sheets << sheet
@sheet_names << sheet[:name]
sheet
end
|
359
360
361
362
363
|
# File 'lib/fast_excel.rb', line 359
def bold_cell_format
bold = add_format
bold.set_bold
bold
end
|
#close ⇒ Object
399
400
401
402
403
|
# File 'lib/fast_excel.rb', line 399
def close
@is_open = false
@sheets.each(&:close)
super
end
|
#constant_memory? ⇒ Boolean
416
417
418
419
|
# File 'lib/fast_excel.rb', line 416
def constant_memory?
@constant_memory ||= self[:options][:constant_memory] != 0
end
|
#get_worksheet_by_name(name) ⇒ Object
392
393
394
395
396
397
|
# File 'lib/fast_excel.rb', line 392
def get_worksheet_by_name(name)
sheet = super(name)
sheet.workbook = self
sheet
end
|
#initialize(struct) ⇒ Object
346
347
348
349
350
351
|
# File 'lib/fast_excel.rb', line 346
def initialize(struct)
@is_open = true
@sheet_names = Set.new
@sheets = []
super(struct)
end
|
“#,##0.00” “[$-409]m/d/yy h:mm AM/PM;@”
369
370
371
372
373
|
# File 'lib/fast_excel.rb', line 369
def number_format(pattern)
format = add_format
format.set_num_format(pattern)
format
end
|
#read_string ⇒ Object
405
406
407
408
409
410
|
# File 'lib/fast_excel.rb', line 405
def read_string
close if @is_open
File.open(filename, 'rb', &:read)
ensure
remove_tmp_folder
end
|
#remove_tmp_folder ⇒ Object
412
413
414
|
# File 'lib/fast_excel.rb', line 412
def remove_tmp_folder
FileUtils.remove_entry(File.dirname(filename)) if tmp_file
end
|