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

#==, included, #index_in_collection, #initialize, #write_xml

Instance Attribute Details

#worksheetsObject

Returns the value of attribute worksheets.



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

def worksheets
  @worksheets
end

Instance Method Details

#applicationObject



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

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

#application=(v) ⇒ Object



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

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

#appversionObject



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

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

#appversion=(v) ⇒ Object



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

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

#before_write_xmlObject



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

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



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

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

#company=(v) ⇒ Object



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

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

#created_atObject



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

def created_at
  root.core_properties.created_at
end

#created_at=(v) ⇒ Object



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

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

#creatorObject



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

def creator
  root.core_properties.creator
end

#creator=(v) ⇒ Object



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

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

#date1904Object



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

def date1904
  workbook_properties && workbook_properties.date1904
end

#date1904=(v) ⇒ Object



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

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

#modified_atObject



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

def modified_at
  root.core_properties.modified_at
end

#modified_at=(v) ⇒ Object



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

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

#modifierObject



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

def modifier
  root.core_properties.modifier
end

#modifier=(v) ⇒ Object



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

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



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

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