Class: RubyXL::Workbook

Inherits:
OOXMLTopLevelObject show all
Includes:
LegacyWorkbook, RelationshipSupport
Defined in:
lib/rubyXL/objects/workbook.rb

Overview

Constant Summary collapse

CONTENT_TYPE =
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml'
REL_TYPE =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'

Constants included from LegacyWorkbook

LegacyWorkbook::APPLICATION, LegacyWorkbook::APPVERSION, LegacyWorkbook::SHEET_NAME_TEMPLATE

Constants inherited from OOXMLTopLevelObject

OOXMLTopLevelObject::ROOT, OOXMLTopLevelObject::SAVE_ORDER

Instance Attribute Summary collapse

Attributes included from RelationshipSupport

#generic_storage, #relationship_container

Attributes inherited from OOXMLTopLevelObject

#root

Instance Method Summary collapse

Methods included from LegacyWorkbook

#[], #add_worksheet, #borders, #cell_xfs, #date_to_num, #each, #fills, #fonts, #get_fill_color, #initialize, #modify_alignment, #modify_border, #modify_fill, #modify_text_wrap, #num_to_date, #register_new_fill, #register_new_font, #register_new_xf, #save, #stream

Methods included from RelationshipSupport

#attach_relationship, #collect_related_objects, included, #load_relationships, #store_relationship

Methods inherited from OOXMLTopLevelObject

#add_to_zip, #file_index, parse_file, set_namespaces

Methods included from OOXMLObjectInstanceMethods

#dup, included, #index_in_collection, #initialize, #write_xml

Instance Attribute Details

#calculation_chainObject

Returns the value of attribute calculation_chain.



347
348
349
# File 'lib/rubyXL/objects/workbook.rb', line 347

def calculation_chain
  @calculation_chain
end

#shared_strings_containerObject

Returns the value of attribute shared_strings_container.



347
348
349
# File 'lib/rubyXL/objects/workbook.rb', line 347

def shared_strings_container
  @shared_strings_container
end

#stylesheetObject

Returns the value of attribute stylesheet.



347
348
349
# File 'lib/rubyXL/objects/workbook.rb', line 347

def stylesheet
  @stylesheet
end

#themeObject

Returns the value of attribute theme.



347
348
349
# File 'lib/rubyXL/objects/workbook.rb', line 347

def theme
  @theme
end

#worksheetsObject

Returns the value of attribute worksheets.



347
348
349
# File 'lib/rubyXL/objects/workbook.rb', line 347

def worksheets
  @worksheets
end

Instance Method Details

#applicationObject



379
380
381
# File 'lib/rubyXL/objects/workbook.rb', line 379

def application
  root.document_properties.application && self.document_properties.application.value
end

#application=(v) ⇒ Object



383
384
385
386
# File 'lib/rubyXL/objects/workbook.rb', line 383

def application=(v)
  root.document_properties.application ||= StringNode.new
  root.document_properties.application.value = v
end

#appversionObject



388
389
390
# File 'lib/rubyXL/objects/workbook.rb', line 388

def appversion
  root.document_properties.app_version && root.document_properties.app_version.value
end

#appversion=(v) ⇒ Object



392
393
394
395
# File 'lib/rubyXL/objects/workbook.rb', line 392

def appversion=(v)
  root.document_properties.app_version ||= StringNode.new
  root.document_properties.app_version.value = v
end

#before_write_xmlObject



349
350
351
352
353
354
355
356
357
358
359
# File 'lib/rubyXL/objects/workbook.rb', line 349

def before_write_xml
  self.sheets = RubyXL::Sheets.new

  worksheets.each_with_index { |sheet, i|
    rel = relationship_container.find_by_target(sheet.xlsx_path)
    sheets << RubyXL::Sheet.new(:name => sheet.sheet_name[0..30], # Max sheet name length is 31 char
                                :sheet_id => sheet.sheet_id || (i + 1),
                                :state => sheet.state, :r_id => rel.id)
  }
  true
end

#companyObject



370
371
372
# File 'lib/rubyXL/objects/workbook.rb', line 370

def company
  self.document_properties.company && self.document_properties.company.value
end

#company=(v) ⇒ Object



374
375
376
377
# File 'lib/rubyXL/objects/workbook.rb', line 374

def company=(v)
  root.document_properties.company ||= StringNode.new
  root.document_properties.company.value = v
end

#created_atObject



413
414
415
# File 'lib/rubyXL/objects/workbook.rb', line 413

def created_at
  root.core_properties.created_at
end

#created_at=(v) ⇒ Object



417
418
419
# File 'lib/rubyXL/objects/workbook.rb', line 417

def created_at=(v)
  root.core_properties.created_at = v
end

#creatorObject



397
398
399
# File 'lib/rubyXL/objects/workbook.rb', line 397

def creator
  root.core_properties.creator
end

#creator=(v) ⇒ Object



401
402
403
# File 'lib/rubyXL/objects/workbook.rb', line 401

def creator=(v)
  root.core_properties.creator = v
end

#date1904Object



361
362
363
# File 'lib/rubyXL/objects/workbook.rb', line 361

def date1904
  workbook_properties && workbook_properties.date1904
end

#date1904=(v) ⇒ Object



365
366
367
368
# File 'lib/rubyXL/objects/workbook.rb', line 365

def date1904=(v)
  self.workbook_properties ||= RubyXL::WorkbookProperties.new
  workbook_properties.date1904 = v
end

#modified_atObject



421
422
423
# File 'lib/rubyXL/objects/workbook.rb', line 421

def modified_at
  root.core_properties.modified_at
end

#modified_at=(v) ⇒ Object



425
426
427
# File 'lib/rubyXL/objects/workbook.rb', line 425

def modified_at=(v)
  root.core_properties.modified_at = v
end

#modifierObject



405
406
407
# File 'lib/rubyXL/objects/workbook.rb', line 405

def modifier
  root.core_properties.modifier
end

#modifier=(v) ⇒ Object



409
410
411
# File 'lib/rubyXL/objects/workbook.rb', line 409

def modifier=(v)
  root.core_properties.modifier = v
end


303
304
305
# File 'lib/rubyXL/objects/workbook.rb', line 303

def related_objects
  [ calculation_chain, stylesheet, theme, shared_strings_container ] + @worksheets
end

#xlsx_pathObject



429
430
431
# File 'lib/rubyXL/objects/workbook.rb', line 429

def xlsx_path
  ROOT.join('xl', 'workbook.xml')
end