Module: FastExcel::WorkbookExt

Includes:
AttributeHelper
Defined in:
lib/fast_excel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttributeHelper

#fields_hash, #pretty_print, #set

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



322
323
324
# File 'lib/fast_excel.rb', line 322

def filename
  @filename
end

#is_openObject

Returns the value of attribute is_open.



322
323
324
# File 'lib/fast_excel.rb', line 322

def is_open
  @is_open
end

#tmp_fileObject

Returns the value of attribute tmp_file.



322
323
324
# File 'lib/fast_excel.rb', line 322

def tmp_file
  @tmp_file
end

Instance Method Details

#add_format(options = nil) ⇒ Object



330
331
332
333
334
# File 'lib/fast_excel.rb', line 330

def add_format(options = nil)
  new_format = super()
  new_format.set(options) if options
  new_format
end

#add_worksheet(sheetname = nil) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/fast_excel.rb', line 350

def add_worksheet(sheetname = nil)
  sheetname = nil if sheetname == ""

  if !sheetname.nil? && @sheet_names.include?(sheetname)
    raise ArgumentError, "Worksheet name '#{sheetname}' is already in use"
  end
  @sheet_names << sheetname

  sheet = super
  sheet.workbook = self

  sheet
end

#bold_cell_formatObject



336
337
338
339
340
# File 'lib/fast_excel.rb', line 336

def bold_cell_format
  bold = add_format
  bold.set_bold
  bold
end

#closeObject



371
372
373
374
# File 'lib/fast_excel.rb', line 371

def close
  @is_open = false
  super
end

#constant_memory?Boolean

Returns:

  • (Boolean)


387
388
389
390
# File 'lib/fast_excel.rb', line 387

def constant_memory?
  #FastExcel.print_ffi_obj(self[:options])
  @constant_memory ||= self[:options][:constant_memory] != 0
end

#get_worksheet_by_name(name) ⇒ Object



364
365
366
367
368
369
# File 'lib/fast_excel.rb', line 364

def get_worksheet_by_name(name)
  sheet = super(name)
  sheet.workbook = self

  sheet
end

#initialize(struct) ⇒ Object



324
325
326
327
328
# File 'lib/fast_excel.rb', line 324

def initialize(struct)
  @is_open = true
  @sheet_names = Set.new
  super(struct)
end

#number_format(pattern) ⇒ Object

“#,##0.00” “[$-409]m/d/yy h:mm AM/PM;@”



344
345
346
347
348
# File 'lib/fast_excel.rb', line 344

def number_format(pattern)
  format = add_format
  format.set_num_format(pattern)
  format
end

#read_stringObject



376
377
378
379
380
381
# File 'lib/fast_excel.rb', line 376

def read_string
  close if @is_open
  File.open(filename, 'rb', &:read)
ensure
  remove_tmp_file
end

#remove_tmp_fileObject



383
384
385
# File 'lib/fast_excel.rb', line 383

def remove_tmp_file
  File.delete(filename) if tmp_file
end