lib/write_xlsx/workbook.rb in write_xlsx-0.72.2 vs lib/write_xlsx/workbook.rb in write_xlsx-0.72.3.beta1
- old
+ new
@@ -240,40 +240,37 @@
return unless @writer
# Prepare format object for passing to Style.rb.
prepare_format_properties
- write_xml_declaration
+ write_xml_declaration do
- # Write the root workbook element.
- write_workbook do
+ # Write the root workbook element.
+ write_workbook do
- # Write the XLSX file version.
- write_file_version
+ # Write the XLSX file version.
+ write_file_version
- # Write the workbook properties.
- write_workbook_pr
+ # Write the workbook properties.
+ write_workbook_pr
- # Write the workbook view properties.
- write_book_views
+ # Write the workbook view properties.
+ write_book_views
- # Write the worksheet names and ids.
- @worksheets.write_sheets(@writer)
+ # Write the worksheet names and ids.
+ @worksheets.write_sheets(@writer)
- # Write the workbook defined names.
- write_defined_names
+ # Write the workbook defined names.
+ write_defined_names
- # Write the workbook calculation properties.
- write_calc_pr
+ # Write the workbook calculation properties.
+ write_calc_pr
- # Write the workbook extension storage.
- #write_ext_lst
+ # Write the workbook extension storage.
+ #write_ext_lst
+ end
end
-
- # Close the XML writer object and filehandle.
- @writer.crlf
- @writer.close
end
#
# At least one worksheet should be added to a new workbook. A worksheet is used to write data into cells:
#
@@ -1071,86 +1068,85 @@
# Check that we have a 1D range only.
return nil if row_start != row_end && col_start != col_end
return [sheetname, row_start, col_start, row_end, col_end]
end
- def write_xml_declaration #:nodoc:
- @writer.xml_decl
- end
-
def write_workbook #:nodoc:
schema = 'http://schemas.openxmlformats.org'
attributes = [
- 'xmlns',
- schema + '/spreadsheetml/2006/main',
- 'xmlns:r',
- schema + '/officeDocument/2006/relationships'
+ ['xmlns',
+ schema + '/spreadsheetml/2006/main'],
+ ['xmlns:r',
+ schema + '/officeDocument/2006/relationships']
]
@writer.tag_elements('workbook', attributes) do
yield
end
end
def write_file_version #:nodoc:
attributes = [
- 'appName', 'xl',
- 'lastEdited', 4,
- 'lowestEdited', 4,
- 'rupBuild', 4505
+ ['appName', 'xl'],
+ ['lastEdited', 4],
+ ['lowestEdited', 4],
+ ['rupBuild', 4505]
]
if @vba_project
- attributes << :codeName << '{37E998C4-C9E5-D4B9-71C8-EB1FF731991C}'
+ attributes << [:codeName, '{37E998C4-C9E5-D4B9-71C8-EB1FF731991C}']
end
@writer.empty_tag('fileVersion', attributes)
end
def write_workbook_pr #:nodoc:
attributes = []
- attributes << 'codeName' << @vba_codename if ptrue?(@vba_codename)
- attributes << 'date1904' << 1 if date_1904?
- attributes << 'defaultThemeVersion' << 124226
+ attributes << ['codeName', @vba_codename] if ptrue?(@vba_codename)
+ attributes << ['date1904', 1] if date_1904?
+ attributes << ['defaultThemeVersion', 124226]
@writer.empty_tag('workbookPr', attributes)
end
def write_book_views #:nodoc:
@writer.tag_elements('bookViews') { write_workbook_view }
end
def write_workbook_view #:nodoc:
attributes = [
- 'xWindow', @x_window,
- 'yWindow', @y_window,
- 'windowWidth', @window_width,
- 'windowHeight', @window_height
+ ['xWindow', @x_window],
+ ['yWindow', @y_window],
+ ['windowWidth', @window_width],
+ ['windowHeight', @window_height]
]
if @tab_ratio != 500
- attributes << 'tabRatio' << @tab_ratio
+ attributes << ['tabRatio', @tab_ratio]
end
if @firstsheet > 0
- attributes << 'firstSheet' << @firstsheet + 1
+ attributes << ['firstSheet', @firstsheet + 1]
end
if @activesheet > 0
- attributes << 'activeTab' << @activesheet
+ attributes << ['activeTab', @activesheet]
end
@writer.empty_tag('workbookView', attributes)
end
def write_calc_pr #:nodoc:
- attributes = ['calcId', 124519, 'fullCalcOnLoad', 1]
+ attributes = [
+ ['calcId', 124519],
+ ['fullCalcOnLoad', 1]
+ ]
@writer.empty_tag('calcPr', attributes)
end
def write_ext_lst #:nodoc:
@writer.tag_elements('extLst') { write_ext }
end
def write_ext #:nodoc:
attributes = [
- 'xmlns:mx', "#{OFFICE_URL}mac/excel/2008/main",
- 'uri', uri
+ ['xmlns:mx', "#{OFFICE_URL}mac/excel/2008/main"],
+ ['uri', uri]
]
@writer.tag_elements('ext', attributes) { write_mx_arch_id }
end
def write_mx_arch_id #:nodoc:
@@ -1165,12 +1161,12 @@
end
def write_defined_name(defined_name) #:nodoc:
name, id, range, hidden = defined_name
- attributes = ['name', name]
- attributes << 'localSheetId' << "#{id}" unless id == -1
- attributes << 'hidden' << '1' if hidden
+ attributes = [ ['name', name] ]
+ attributes << ['localSheetId', "#{id}"] unless id == -1
+ attributes << ['hidden', '1'] if hidden
@writer.data_element('definedName', range, attributes)
end
def write_io(str) #:nodoc: