lib/write_xlsx/chartsheet.rb in write_xlsx-0.0.4 vs lib/write_xlsx/chartsheet.rb in write_xlsx-0.51.0
- old
+ new
@@ -13,26 +13,28 @@
module Writexlsx
class Chartsheet < Worksheet
include Writexlsx::Utility
+ attr_writer :chart
+
def initialize(workbook, index, name)
super
- @drawing = 1
+ @drawing = Drawing.new
@is_chartsheet = true
@chart = nil
@charts = [1]
@zoom_scale_normal = 0
- @oriantation = 0
+ @print_style.orientation = false
end
#
# Assemble and write the XML file.
#
def assemble_xml_file # :nodoc:
return unless @writer
- write_xml_declaration
+ @writer.xml_decl
# Write the root chartsheet element.
write_chartsheet
# Write the worksheet properties.
@@ -62,11 +64,11 @@
# Close the worksheet tag.
@writer.end_tag('chartsheet')
# Close the XML writer object and filehandle.
@writer.crlf
- @writer.getOutput->close
+ @writer.close
end
def protect(password = '', options = {})
@chart.protection = 1
@@ -94,10 +96,18 @@
def set_y_axis(*args)
@chart.set_y_axis(*args)
end
+ def set_x2_axis(*args)
+ @chart.set_x2_axis(*args)
+ end
+
+ def set_y2_axis(*args)
+ @chart.set_y2_axis(*args)
+ end
+
def set_title(*args)
@chart.set_title(*args)
end
def set_legend(*args)
@@ -114,25 +124,33 @@
def set_style(*args)
@chart.set_style(*args)
end
- private
+ def show_blanks_as(*args)
+ @chart.show_blanks_as(*args)
+ end
+ def show_hidden_data(*args)
+ @chart.show_hidden_data(*args)
+ end
+
#
# Set up chart/drawings.
#
def prepare_chart(index, chart_id, drawing_id) # :nodoc:
drawing = Drawing.new
@drawing = drawing
- @drawing.orientation = @orientation
+ @drawing.orientation = @print_style.orientation
- @external_drawing_links << [ '/drawing', '../drawings/drawing' << drawing_id << '.xml' ]
+ @external_drawing_links << [ '/drawing', "../drawings/drawing#{drawing_id}.xml" ]
- @drawing_links << [ '/chart', '../charts/chart' << chart_id << '.xml' ]
+ @drawing_links << [ '/chart', "../charts/chart#{chart_id}.xml"]
end
+ private
+
#
# Write the <chartsheet> element. This is the root element of Chartsheet.
#
def write_chartsheet # :nodoc:
schema = 'http://schemas.openxmlformats.org/'
@@ -152,16 +170,16 @@
end
#
# Write the <sheetPr> element for Sheet level properties.
#
- def _write_sheet_pr # :nodoc:
+ def write_sheet_pr # :nodoc:
attributes = []
- attributes << {'filterMode' => 1} if @filter_on
+ attributes << {'filterMode' => 1} if ptrue?(@filter_on)
- if @fit_page || @tab_color
+ if ptrue?(@fit_page) || ptrue?(@tab_color)
@writer.tag_elements('sheetPr', attributes) do
write_tab_color
write_page_set_up_pr
end
else