write_xlsx 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -60,6 +60,9 @@ in an Excel XMLX spreadsheet called ruby.xlsx:
60
60
 
61
61
  == Recent change
62
62
 
63
+ 2012-02-14 v0.0.4
64
+ Fix for x-axis major/minor units in scatter charts.(CPAN_0.46)
65
+
63
66
  2012-01-25 v0.0.3
64
67
  alignment format support. see examples/formats.rb
65
68
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -980,6 +980,23 @@ def set_embedded_config_data
980
980
 
981
981
  end
982
982
 
983
+ #
984
+ # Write the <c:barChart> element.
985
+ #
986
+ def write_bar_chart # :nodoc:
987
+ subtype = @subtype
988
+ subtype = 'percentStacked' if subtype == 'percent_stacked'
989
+
990
+ @writer.tag_elements('c:barChart') do
991
+ # Write the c:barDir element.
992
+ write_bar_dir
993
+ # Write the c:grouping element.
994
+ write_grouping(subtype)
995
+ # Write the series elements.
996
+ write_series
997
+ end
998
+ end
999
+
983
1000
  private
984
1001
 
985
1002
  #
@@ -1436,46 +1453,37 @@ def write_style # :nodoc:
1436
1453
  # Write the <c:chart> element.
1437
1454
  #
1438
1455
  def write_chart # :nodoc:
1439
- @writer.start_tag('c:chart')
1456
+ @writer.tag_elements('c:chart') do
1457
+ # Write the chart title elements.
1458
+ if title = @title_formula
1459
+ write_title_formula(title, @title_data_id)
1460
+ elsif title = @title_name
1461
+ write_title_rich(title)
1462
+ end
1440
1463
 
1441
- # Write the chart title elements.
1442
- if title = @title_formula
1443
- write_title_formula(title, @title_data_id)
1444
- elsif title = @title_name
1445
- write_title_rich(title)
1464
+ # Write the c:plotArea element.
1465
+ write_plot_area
1466
+ # Write the c:legend element.
1467
+ write_legend
1468
+ # Write the c:plotVisOnly element.
1469
+ write_plot_vis_only
1446
1470
  end
1447
-
1448
- # Write the c:plotArea element.
1449
- write_plot_area
1450
-
1451
- # Write the c:legend element.
1452
- write_legend
1453
-
1454
- # Write the c:plotVisOnly element.
1455
- write_plot_vis_only
1456
-
1457
- @writer.end_tag('c:chart')
1458
1471
  end
1459
1472
 
1460
1473
  #
1461
1474
  # Write the <c:plotArea> element.
1462
1475
  #
1463
1476
  def write_plot_area # :nodoc:
1464
- @writer.start_tag('c:plotArea')
1465
-
1466
- # Write the c:layout element.
1467
- write_layout
1468
-
1469
- # Write the subclass chart type element.
1470
- write_chart_type
1471
-
1472
- # Write the c:catAx element.
1473
- write_cat_axis
1474
-
1475
- # Write the c:catAx element.
1476
- write_val_axis
1477
-
1478
- @writer.end_tag('c:plotArea')
1477
+ @writer.tag_elements('c:plotArea') do
1478
+ # Write the c:layout element.
1479
+ write_layout
1480
+ # Write the subclass chart type element.
1481
+ write_chart_type
1482
+ # Write the c:catAx element.
1483
+ write_cat_axis
1484
+ # Write the c:catAx element.
1485
+ write_val_axis
1486
+ end
1479
1487
  end
1480
1488
 
1481
1489
  #
@@ -1504,6 +1512,10 @@ def write_grouping(val) # :nodoc:
1504
1512
  # Write the series elements.
1505
1513
  #
1506
1514
  def write_series # :nodoc:
1515
+ write_series_base { nil }
1516
+ end
1517
+
1518
+ def write_series_base
1507
1519
  # Write each series with subelements.
1508
1520
  index = 0
1509
1521
  @series.each do |series|
@@ -1514,6 +1526,10 @@ def write_series # :nodoc:
1514
1526
  # Write the c:marker element.
1515
1527
  write_marker_value
1516
1528
 
1529
+ # Write the c:overlap element
1530
+ # block given by Bar and Column
1531
+ yield
1532
+
1517
1533
  # Generate the axis ids.
1518
1534
  add_axis_id
1519
1535
  add_axis_id
@@ -1527,39 +1543,28 @@ def write_series # :nodoc:
1527
1543
  # Write the <c:ser> element.
1528
1544
  #
1529
1545
  def write_ser(index, series) # :nodoc:
1530
- @writer.start_tag('c:ser')
1531
-
1532
- # Write the c:idx element.
1533
- write_idx(index)
1534
-
1535
- # Write the c:order element.
1536
- write_order(index)
1537
-
1538
- # Write the series name.
1539
- write_series_name(series)
1540
-
1541
- # Write the c:spPr element.
1542
- write_sp_pr(series)
1543
-
1544
- # Write the c:marker element.
1545
- write_marker(series[:_marker])
1546
-
1547
- # Write the c:invertIfNegative element.
1548
- write_c_invert_if_negative(series[:_invert_if_neg])
1549
-
1550
- # Write the c:dLbls element.
1551
- write_d_lbls(series[:labels])
1552
-
1553
- # Write the c:trendline element.
1554
- write_trendline(series[:trendline])
1555
-
1556
- # Write the c:cat element.
1557
- write_cat(series)
1558
-
1559
- # Write the c:val element.
1560
- write_val(series)
1561
-
1562
- @writer.end_tag('c:ser')
1546
+ @writer.tag_elements('c:ser') do
1547
+ # Write the c:idx element.
1548
+ write_idx(index)
1549
+ # Write the c:order element.
1550
+ write_order(index)
1551
+ # Write the series name.
1552
+ write_series_name(series)
1553
+ # Write the c:spPr element.
1554
+ write_sp_pr(series)
1555
+ # Write the c:marker element.
1556
+ write_marker(series[:_marker])
1557
+ # Write the c:invertIfNegative element.
1558
+ write_c_invert_if_negative(series[:_invert_if_neg])
1559
+ # Write the c:dLbls element.
1560
+ write_d_lbls(series[:labels])
1561
+ # Write the c:trendline element.
1562
+ write_trendline(series[:trendline])
1563
+ # Write the c:cat element.
1564
+ write_cat(series)
1565
+ # Write the c:val element.
1566
+ write_val(series)
1567
+ end
1563
1568
  end
1564
1569
 
1565
1570
  #
@@ -1606,86 +1611,75 @@ def write_cat(series) # :nodoc:
1606
1611
 
1607
1612
  @has_category = 1
1608
1613
 
1609
- @writer.start_tag('c:cat')
1610
-
1611
- # Check the type of cached data.
1612
- type = get_data_type(data)
1613
-
1614
- if type == 'str'
1615
- @has_category = 0
1616
-
1617
- # Write the c:numRef element.
1618
- write_str_ref(formula, data, type)
1619
- else
1620
- # Write the c:numRef element.
1621
- write_num_ref(formula, data, type)
1614
+ @writer.tag_elements('c:cat') do
1615
+ # Check the type of cached data.
1616
+ type = get_data_type(data)
1617
+ if type == 'str'
1618
+ @has_category = 0
1619
+ # Write the c:numRef element.
1620
+ write_str_ref(formula, data, type)
1621
+ else
1622
+ # Write the c:numRef element.
1623
+ write_num_ref(formula, data, type)
1624
+ end
1622
1625
  end
1623
-
1624
- @writer.end_tag('c:cat')
1625
1626
  end
1626
1627
 
1627
1628
  #
1628
1629
  # Write the <c:val> element.
1629
1630
  #
1630
1631
  def write_val(series) # :nodoc:
1631
- formula = series[:_values]
1632
- data_id = series[:_val_data_id]
1633
- data = @formula_data[data_id]
1634
-
1635
- @writer.start_tag('c:val')
1632
+ write_val_base(series[:_values], series[:_val_data_id], 'c:val')
1633
+ end
1636
1634
 
1637
- # Check the type of cached data.
1638
- type = get_data_type(data)
1635
+ def write_val_base(formula, data_id, tag) # :nodoc:
1636
+ data = @formula_data[data_id]
1639
1637
 
1640
- if type == 'str'
1641
- # Write the c:numRef element.
1642
- write_str_ref(formula, data, type)
1643
- else
1644
- # Write the c:numRef element.
1645
- write_num_ref(formula, data, type)
1638
+ @writer.tag_elements(tag) do
1639
+ # Check the type of cached data.
1640
+ type = get_data_type(data)
1641
+ if type == 'str'
1642
+ # Write the c:numRef element.
1643
+ write_str_ref(formula, data, type)
1644
+ else
1645
+ # Write the c:numRef element.
1646
+ write_num_ref(formula, data, type)
1647
+ end
1646
1648
  end
1647
-
1648
- @writer.end_tag('c:val')
1649
1649
  end
1650
1650
 
1651
1651
  #
1652
1652
  # Write the <c:numRef> element.
1653
1653
  #
1654
1654
  def write_num_ref(formula, data, type) # :nodoc:
1655
- @writer.start_tag('c:numRef')
1656
-
1657
- # Write the c:f element.
1658
- write_series_formula(formula)
1659
-
1660
- if type == 'num'
1661
- # Write the c:numCache element.
1662
- write_num_cache(data)
1663
- elsif type == 'str'
1664
- # Write the c:strCache element.
1665
- write_str_cache(data)
1655
+ @writer.tag_elements('c:numRef') do
1656
+ # Write the c:f element.
1657
+ write_series_formula(formula)
1658
+ if type == 'num'
1659
+ # Write the c:numCache element.
1660
+ write_num_cache(data)
1661
+ elsif type == 'str'
1662
+ # Write the c:strCache element.
1663
+ write_str_cache(data)
1664
+ end
1666
1665
  end
1667
-
1668
- @writer.end_tag('c:numRef')
1669
1666
  end
1670
1667
 
1671
1668
  #
1672
1669
  # Write the <c:strRef> element.
1673
1670
  #
1674
1671
  def write_str_ref(formula, data, type) # :nodoc:
1675
- @writer.start_tag('c:strRef')
1676
-
1677
- # Write the c:f element.
1678
- write_series_formula(formula)
1679
-
1680
- if type == 'num'
1681
- # Write the c:numCache element.
1682
- write_num_cache(data)
1683
- elsif type == 'str'
1684
- # Write the c:strCache element.
1685
- write_str_cache(data)
1672
+ @writer.tag_elements('c:strRef') do
1673
+ # Write the c:f element.
1674
+ write_series_formula(formula)
1675
+ if type == 'num'
1676
+ # Write the c:numCache element.
1677
+ write_num_cache(data)
1678
+ elsif type == 'str'
1679
+ # Write the c:strCache element.
1680
+ write_str_cache(data)
1681
+ end
1686
1682
  end
1687
-
1688
- @writer.end_tag('c:strRef')
1689
1683
  end
1690
1684
 
1691
1685
  #
@@ -1719,51 +1713,39 @@ def write_cat_axis(position = nil) # :nodoc:
1719
1713
  # Overwrite the default axis position with a user supplied value.
1720
1714
  position = x_axis[:_position] || position
1721
1715
 
1722
- @writer.start_tag('c:catAx')
1723
-
1724
- write_axis_id(@axis_ids[0])
1725
-
1726
- # Write the c:scaling element.
1727
- write_scaling(x_axis[:_reverse])
1728
-
1729
- # Write the c:axPos element.
1730
- write_axis_pos(position, y_axis[:_reverse])
1731
-
1732
- # Write the axis title elements.
1733
- if title = @x_axis[:_formula]
1734
- write_title_formula(title, @x_axis[:_data_id], horiz)
1735
- elsif title = @x_axis[:_name]
1736
- write_title_rich(title, horiz)
1737
- end
1738
-
1739
- # Write the c:numFmt element.
1740
- write_num_fmt
1741
-
1742
- # Write the c:tickLblPos element.
1743
- write_tick_label_pos(x_axis[:_label_position])
1744
-
1745
- # Write the c:crossAx element.
1746
- write_cross_axis(@axis_ids[1])
1747
-
1748
- # Note, the category crossing comes from the value axis.
1749
- if y_axis[:_crossing].nil? || y_axis[:_crossing] == 'max'
1750
- # Write the c:crosses element.
1751
- write_crosses(y_axis[:_crossing])
1752
- else
1753
- # Write the c:crossesAt element.
1754
- write_c_crosses(y_axis[:_crossing])
1716
+ @writer.tag_elements('c:catAx') do
1717
+ write_axis_id(@axis_ids[0])
1718
+ # Write the c:scaling element.
1719
+ write_scaling(x_axis[:_reverse])
1720
+ # Write the c:axPos element.
1721
+ write_axis_pos(position, y_axis[:_reverse])
1722
+ # Write the axis title elements.
1723
+ if title = @x_axis[:_formula]
1724
+ write_title_formula(title, @x_axis[:_data_id], horiz)
1725
+ elsif title = @x_axis[:_name]
1726
+ write_title_rich(title, horiz)
1727
+ end
1728
+ # Write the c:numFmt element.
1729
+ write_num_fmt
1730
+ # Write the c:tickLblPos element.
1731
+ write_tick_label_pos(x_axis[:_label_position])
1732
+ # Write the c:crossAx element.
1733
+ write_cross_axis(@axis_ids[1])
1734
+ # Note, the category crossing comes from the value axis.
1735
+ if nil_or_max?(y_axis[:_crossing])
1736
+ # Write the c:crosses element.
1737
+ write_crosses(y_axis[:_crossing])
1738
+ else
1739
+ # Write the c:crossesAt element.
1740
+ write_c_crosses(y_axis[:_crossing])
1741
+ end
1742
+ # Write the c:auto element.
1743
+ write_auto(1)
1744
+ # Write the c:labelAlign element.
1745
+ write_label_align('ctr')
1746
+ # Write the c:labelOffset element.
1747
+ write_label_offset(100)
1755
1748
  end
1756
-
1757
- # Write the c:auto element.
1758
- write_auto(1)
1759
-
1760
- # Write the c:labelAlign element.
1761
- write_label_align('ctr')
1762
-
1763
- # Write the c:labelOffset element.
1764
- write_label_offset(100)
1765
-
1766
- @writer.end_tag('c:catAx')
1767
1749
  end
1768
1750
 
1769
1751
  #
@@ -1772,62 +1754,19 @@ def write_cat_axis(position = nil) # :nodoc:
1772
1754
  # TODO. Maybe should have a _write_cat_val_axis method as well for scatter.
1773
1755
  #
1774
1756
  def write_val_axis(position = nil, hide_major_gridlines = nil) # :nodoc:
1775
- position ||= @val_axis_position
1776
- horiz = @horiz_val_axis
1777
- x_axis = @x_axis
1778
- y_axis = @y_axis
1779
-
1780
- # Overwrite the default axis position with a user supplied value.
1781
- position = y_axis[:_position] || position
1782
-
1783
- @writer.start_tag('c:valAx')
1784
-
1785
- write_axis_id(@axis_ids[1])
1786
-
1787
- # Write the c:scaling element.
1788
- write_scaling(y_axis[:_reverse], y_axis[:_min], y_axis[:_max], y_axis[:_log_base])
1789
-
1790
- # Write the c:axPos element.
1791
- write_axis_pos(position, x_axis[:_reverse])
1792
-
1793
- # Write the c:majorGridlines element.
1794
- write_major_gridlines unless hide_major_gridlines
1795
-
1796
- # Write the axis title elements.
1797
- if title = @y_axis[:_formula]
1798
- write_title_formula(title, @y_axis[:_data_id], horiz)
1799
- elsif title = @y_axis[:_name]
1800
- write_title_rich(title, horiz)
1801
- end
1802
-
1803
- # Write the c:numberFormat element.
1804
- write_number_format
1805
-
1806
- # Write the c:tickLblPos element.
1807
- write_tick_label_pos(y_axis[:_label_position])
1808
-
1809
- # Write the c:crossAx element.
1810
- write_cross_axis(@axis_ids[0])
1811
-
1812
- # Note, the category crossing comes from the value axis.
1813
- if x_axis[:crossing].nil? || x_axis[:_crossing] == 'max'
1814
- # Write the c:crosses element.
1815
- write_crosses(x_axis[:_crossing])
1816
- else
1817
- # Write the c:crossesAt element.
1818
- write_c_crosses_at(x_axis[:_crossing])
1819
- end
1820
-
1821
- # Write the c:crossBetween element.
1822
- write_cross_between
1823
-
1824
- # Write the c:majorUnit element.
1825
- write_c_major_unit(y_axis[:_major_unit])
1826
-
1827
- # Write the c:minorUnit element.
1828
- write_c_minor_unit(y_axis[:_minor_unit])
1829
-
1830
- @writer.end_tag('c:valAx')
1757
+ params = {
1758
+ :axis_position => @y_axis[:_position],
1759
+ :axis_id => @axis_ids[1],
1760
+ :scaling_axis => @y_axis,
1761
+ :axis_position_element => @x_axis[:_reverse],
1762
+ :title_axis => @y_axis,
1763
+ :tick_label_pos => @y_axis[:_label_position],
1764
+ :cross_axis => @axis_ids[0],
1765
+ :category_crossing => @x_axis[:_crossing],
1766
+ :major_unit => @y_axis[:_major_unit],
1767
+ :minor_unit => @y_axis[:_minor_unit]
1768
+ }
1769
+ write_val_axis_common(position, hide_major_gridlines, params)
1831
1770
  end
1832
1771
 
1833
1772
  #
@@ -1836,62 +1775,65 @@ def write_val_axis(position = nil, hide_major_gridlines = nil) # :nodoc:
1836
1775
  # Usually the X axis.
1837
1776
  #
1838
1777
  def write_cat_val_axis(position, hide_major_gridlines) # :nodoc:
1778
+ params = {
1779
+ :axis_position => @x_axis[:_position],
1780
+ :axis_id => @axis_ids[0],
1781
+ :scaling_axis => @x_axis,
1782
+ :axis_position_element => @y_axis[:_reverse],
1783
+ :title_axis => @x_axis,
1784
+ :tick_label_pos => @x_axis[:_label_position],
1785
+ :cross_axis => @axis_ids[1],
1786
+ :category_crossing => @y_axis[:_crossing],
1787
+ :major_unit => @x_axis[:_major_unit],
1788
+ :minor_unit => @x_axis[:_minor_unit]
1789
+ }
1790
+ write_val_axis_common(position, hide_major_gridlines, params)
1791
+ end
1792
+
1793
+ def write_val_axis_common(position, hide_major_gridlines, params) # :nodoc:
1839
1794
  position ||= @val_axis_position
1840
- horiz = @horiz_val_axis
1841
- x_axis = @x_axis
1842
- y_axis = @y_axis
1795
+ horiz = @horiz_val_axis
1843
1796
 
1844
1797
  # Overwrite the default axis position with a user supplied value.
1845
- position = x_axis[:_position] || position
1846
-
1847
- @writer.start_tag('c:valAx')
1848
-
1849
- write_axis_id(@axis_ids[0])
1850
-
1851
- # Write the c:scaling element.
1852
- write_scaling(x_axis[:_reverse], x_axis[:_min], x_axis[:_max], x_axis[:_log_base])
1853
-
1854
- # Write the c:axPos element.
1855
- write_axis_pos(position, y_axis[:_reverse])
1856
-
1857
- # Write the c:majorGridlines element.
1858
- write_major_gridlines unless hide_major_gridlines
1859
-
1860
- # Write the axis title elements.
1861
- if title = @x_axis[:_formula]
1862
- write_title_formula(title, @y_axis[:_data_id], horiz)
1863
- elsif title = @x_axis[:_name]
1864
- write_title_rich(title, horiz)
1865
- end
1866
-
1867
- # Write the c:numberFormat element.
1868
- write_number_format
1869
-
1870
- # Write the c:tickLblPos element.
1871
- write_tick_label_pos(x_axis[:_label_position])
1872
-
1873
- # Write the c:crossAx element.
1874
- write_cross_axis(@axis_ids[1])
1875
-
1876
- # Note, the category crossing comes from the value axis.
1877
- if y_axis[:_clossing].nil? || y_axis[:_crossing] == 'max'
1878
- # Write the c:crosses element.
1879
- write_crosses(y_axis[:_crossing])
1880
- else
1881
- # Write the c:crossesAt element.
1882
- write_c_crosses_at(y_axis[:_crossing])
1798
+ position = params[:axis_position] || position
1799
+
1800
+ @writer.tag_elements('c:valAx') do
1801
+ write_axis_id(params[:axis_id])
1802
+ # Write the c:scaling element.
1803
+ write_scaling(
1804
+ params[:scaling_axis][:_reverse], params[:scaling_axis][:_min],
1805
+ params[:scaling_axis][:_max], params[:scaling_axis][:_log_base])
1806
+ # Write the c:axPos element.
1807
+ write_axis_pos(position, params[:axis_position_element])
1808
+ # Write the c:majorGridlines element.
1809
+ write_major_gridlines unless hide_major_gridlines
1810
+ # Write the axis title elements.
1811
+ if title = params[:title_axis][:_formula]
1812
+ write_title_formula(title, @y_axis[:_data_id], horiz)
1813
+ elsif title = params[:title_axis][:_name]
1814
+ write_title_rich(title, horiz)
1815
+ end
1816
+ # Write the c:numberFormat element.
1817
+ write_number_format
1818
+ # Write the c:tickLblPos element.
1819
+ write_tick_label_pos(params[:tick_label_pos])
1820
+ # Write the c:crossAx element.
1821
+ write_cross_axis(params[:cross_axis])
1822
+ # Note, the category crossing comes from the value axis.
1823
+ if nil_or_max?(params[:category_crossing])
1824
+ # Write the c:crosses element.
1825
+ write_crosses(params[:category_crossing])
1826
+ else
1827
+ # Write the c:crossesAt element.
1828
+ write_c_crosses_at(params[:category_crossing])
1829
+ end
1830
+ # Write the c:crossBetween element.
1831
+ write_cross_between
1832
+ # Write the c:majorUnit element.
1833
+ write_c_major_unit(params[:major_unit])
1834
+ # Write the c:minorUnit element.
1835
+ write_c_minor_unit(params[:minor_unit])
1883
1836
  end
1884
-
1885
- # Write the c:crossBetween element.
1886
- write_cross_between
1887
-
1888
- # Write the c:majorunit element.
1889
- write_c_major_unit(y_axis[:_major_unit])
1890
-
1891
- # Write the c:minorUnit element.
1892
- write_c_minor_unit(y_axis[:_minor_unit])
1893
-
1894
- @writer.end_tag('c:valAx')
1895
1837
  end
1896
1838
 
1897
1839
  #
@@ -1902,85 +1844,65 @@ def write_date_axis(position = nil) # :nodoc:
1902
1844
  x_axis = @x_axis
1903
1845
  y_axis = @y_axis
1904
1846
 
1905
- @writer.start_tag('c:dateAx')
1906
-
1907
- write_axis_id(@axis_ids[0])
1908
-
1909
- # Write the c:scaling element.
1910
- write_scaling(x_axis[:reverse], x_axis[:_min], x_axis[:_max], x_axis[:_log_base])
1911
-
1912
- # Write the c:axPos element.
1913
- write_axis_pos(position, y_axis[:reverse])
1914
-
1915
- # Write the axis title elements.
1916
- if title = x_axis[:_formula]
1917
- write_title_formula(title, x_axis[:_data_id])
1918
- elsif title = x_axis[:_name]
1919
- write_title_rich(title)
1920
- end
1921
-
1922
- # Write the c:numFmt element.
1923
- write_num_fmt('dd/mm/yyyy')
1924
-
1925
- # Write the c:tickLblPos element.
1926
- write_tick_label_pos(x_axis[:_label_position])
1927
-
1928
- # Write the c:crossAx element.
1929
- write_cross_axis(@axis_ids[1])
1930
-
1931
- # Note, the category crossing comes from the value axis.
1932
- if y_axis[:_crossing].nil? || y_axis[:_crossing] == 'max'
1933
- # Write the c:crossing element.
1934
- write_crosses(y_axis[:_crossing])
1935
- else
1936
- # Write the c:crossesAt element.
1937
- write_c_crosses_at(y_axis[:_crossing])
1938
- end
1939
-
1940
- # Write the c:auto element.
1941
- write_auto(1)
1942
-
1943
- # Write the c:labelOffset element.
1944
- write_label_offset(100)
1945
-
1946
- # Write the c:majorUnit element.
1947
- write_c_major_unit(x_axis[:_major_unit])
1948
-
1949
- # Write the c:majorTimeUnit element.
1950
- if !x_axis[:_major_unit].nil?
1951
- write_c_major_time_unit(x_axis[:_major_unit_type])
1952
- end
1953
-
1954
- # Write the c:minorUnit element.
1955
- write_c_minor_unit(x_axis[:_minor_unit])
1956
-
1957
- # Write the c:minorTimeUnit element.
1958
- if !x_axis[:_minor_unit].nil?
1959
- write_c_minor_time_unit(x_axis[:_minor_unit_type])
1847
+ @writer.tag_elements('c:dateAx') do
1848
+ write_axis_id(@axis_ids[0])
1849
+ # Write the c:scaling element.
1850
+ write_scaling(x_axis[:reverse], x_axis[:_min], x_axis[:_max], x_axis[:_log_base])
1851
+ # Write the c:axPos element.
1852
+ write_axis_pos(position, y_axis[:reverse])
1853
+ # Write the axis title elements.
1854
+ if title = x_axis[:_formula]
1855
+ write_title_formula(title, x_axis[:_data_id])
1856
+ elsif title = x_axis[:_name]
1857
+ write_title_rich(title)
1858
+ end
1859
+ # Write the c:numFmt element.
1860
+ write_num_fmt('dd/mm/yyyy')
1861
+ # Write the c:tickLblPos element.
1862
+ write_tick_label_pos(x_axis[:_label_position])
1863
+ # Write the c:crossAx element.
1864
+ write_cross_axis(@axis_ids[1])
1865
+ # Note, the category crossing comes from the value axis.
1866
+ if nil_or_max?(y_axis[:_crossing])
1867
+ # Write the c:crossing element.
1868
+ write_crosses(y_axis[:_crossing])
1869
+ else
1870
+ # Write the c:crossesAt element.
1871
+ write_c_crosses_at(y_axis[:_crossing])
1872
+ end
1873
+ # Write the c:auto element.
1874
+ write_auto(1)
1875
+ # Write the c:labelOffset element.
1876
+ write_label_offset(100)
1877
+ # Write the c:majorUnit element.
1878
+ write_c_major_unit(x_axis[:_major_unit])
1879
+ # Write the c:majorTimeUnit element.
1880
+ if !x_axis[:_major_unit].nil?
1881
+ write_c_major_time_unit(x_axis[:_major_unit_type])
1882
+ end
1883
+ # Write the c:minorUnit element.
1884
+ write_c_minor_unit(x_axis[:_minor_unit])
1885
+ # Write the c:minorTimeUnit element.
1886
+ if !x_axis[:_minor_unit].nil?
1887
+ write_c_minor_time_unit(x_axis[:_minor_unit_type])
1888
+ end
1960
1889
  end
1961
-
1962
- @writer.end_tag('c:dateAx')
1963
1890
  end
1964
1891
 
1965
1892
  #
1966
1893
  # Write the <c:scaling> element.
1967
1894
  #
1968
1895
  def write_scaling(reverse, min = nil, max = nil, log_base = nil) # :nodoc:
1969
- @writer.start_tag('c:scaling')
1970
-
1971
- # Write the c:logBase element.
1972
- write_c_log_base(log_base)
1973
-
1974
- # Write the c:orientation element.
1975
- write_orientation(reverse)
1976
-
1977
- # Write the c:max element.
1978
- write_c_max(max)
1979
-
1980
- # Write the c:min element.
1981
- write_c_min(min)
1982
-
1983
- @writer.end_tag('c:scaling')
1896
+ @writer.tag_elements('c:scaling') do
1897
+ # Write the c:logBase element.
1898
+ write_c_log_base(log_base)
1899
+ # Write the c:orientation element.
1900
+ write_orientation(reverse)
1901
+ # Write the c:max element.
1902
+ write_c_max(max)
1903
+ # Write the c:min element.
1904
+ write_c_min(min)
1905
+ end
1984
1906
  end
1985
1907
 
1986
1908
  #
@@ -2241,24 +2163,19 @@ def write_legend # :nodoc:
2241
2163
 
2242
2164
  position = allowed[position]
2243
2165
 
2244
- @writer.start_tag('c:legend')
2245
-
2246
- # Write the c:legendPos element.
2247
- write_legend_pos(position)
2248
-
2249
- # Remove series labels from the legend.
2250
- @delete_series.each do |index|
2251
- # Write the c:legendEntry element.
2252
- write_legend_entry(index)
2253
- end if @delete_series
2254
-
2255
- # Write the c:layout element.
2256
- write_layout
2257
-
2258
- # Write the c:overlay element.
2259
- write_overlay if overlay
2260
-
2261
- @writer.end_tag('c:legend')
2166
+ @writer.tag_elements('c:legend') do
2167
+ # Write the c:legendPos element.
2168
+ write_legend_pos(position)
2169
+ # Remove series labels from the legend.
2170
+ @delete_series.each do |index|
2171
+ # Write the c:legendEntry element.
2172
+ write_legend_entry(index)
2173
+ end if @delete_series
2174
+ # Write the c:layout element.
2175
+ write_layout
2176
+ # Write the c:overlay element.
2177
+ write_overlay if overlay
2178
+ end
2262
2179
  end
2263
2180
 
2264
2181
  #
@@ -2274,15 +2191,12 @@ def write_legend_pos(val) # :nodoc:
2274
2191
  # Write the <c:legendEntry> element.
2275
2192
  #
2276
2193
  def write_legend_entry(index) # :nodoc:
2277
- @writer.start_tag('c:legendEntry')
2278
-
2279
- # Write the c:idx element.
2280
- write_idx(index)
2281
-
2282
- # Write the c:delete element.
2283
- write_delete(1)
2284
-
2285
- @writer.end_tag('c:legendEntry')
2194
+ @writer.tag_elements('c:legendEntry') do
2195
+ # Write the c:idx element.
2196
+ write_idx(index)
2197
+ # Write the c:delete element.
2198
+ write_delete(1)
2199
+ end
2286
2200
  end
2287
2201
 
2288
2202
  #
@@ -2311,18 +2225,14 @@ def write_plot_vis_only # :nodoc:
2311
2225
  # Write the <c:printSettings> element.
2312
2226
  #
2313
2227
  def write_print_settings # :nodoc:
2314
- @writer.start_tag('c:printSettings')
2315
-
2316
- # Write the c:headerFooter element.
2317
- write_header_footer
2318
-
2319
- # Write the c:pageMargins element.
2320
- write_page_margins
2321
-
2322
- # Write the c:pageSetup element.
2323
- write_page_setup
2324
-
2325
- @writer.end_tag('c:printSettings')
2228
+ @writer.tag_elements('c:printSettings') do
2229
+ # Write the c:headerFooter element.
2230
+ write_header_footer
2231
+ # Write the c:pageMargins element.
2232
+ write_page_margins
2233
+ # Write the c:pageSetup element.
2234
+ write_page_setup
2235
+ end
2326
2236
  end
2327
2237
 
2328
2238
  #
@@ -2366,57 +2276,40 @@ def write_page_setup # :nodoc:
2366
2276
  # Write the <c:title> element for a rich string.
2367
2277
  #
2368
2278
  def write_title_rich(title, horiz = nil) # :nodoc:
2369
- @writer.start_tag('c:title')
2370
-
2371
- # Write the c:tx element.
2372
- write_tx_rich(title, horiz)
2373
-
2374
- # Write the c:layout element.
2375
- write_layout
2376
-
2377
- @writer.end_tag('c:title')
2279
+ @writer.tag_elements('c:title') do
2280
+ # Write the c:tx element.
2281
+ write_tx_rich(title, horiz)
2282
+ # Write the c:layout element.
2283
+ write_layout
2284
+ end
2378
2285
  end
2379
2286
 
2380
2287
  #
2381
2288
  # Write the <c:title> element for a rich string.
2382
2289
  #
2383
2290
  def write_title_formula(title, data_id, horiz) # :nodoc:
2384
- @writer.start_tag('c:title')
2385
-
2386
- # Write the c:tx element.
2387
- write_tx_formula(title, data_id)
2388
-
2389
- # Write the c:layout element.
2390
- write_layout
2391
-
2392
- # Write the c:txPr element.
2393
- write_tx_pr(horiz)
2394
-
2395
- @writer.end_tag('c:title')
2291
+ @writer.tag_elements('c:title') do
2292
+ # Write the c:tx element.
2293
+ write_tx_formula(title, data_id)
2294
+ # Write the c:layout element.
2295
+ write_layout
2296
+ # Write the c:txPr element.
2297
+ write_tx_pr(horiz)
2298
+ end
2396
2299
  end
2397
2300
 
2398
2301
  #
2399
2302
  # Write the <c:tx> element.
2400
2303
  #
2401
2304
  def write_tx_rich(title, horiz) # :nodoc:
2402
- @writer.start_tag('c:tx')
2403
-
2404
- # Write the c:rich element.
2405
- write_rich(title, horiz)
2406
-
2407
- @writer.end_tag('c:tx')
2305
+ @writer.tag_elements('c:tx') { write_rich(title, horiz) }
2408
2306
  end
2409
2307
 
2410
2308
  #
2411
2309
  # Write the <c:tx> element with a simple value such as for series names.
2412
2310
  #
2413
2311
  def write_tx_value(title) # :nodoc:
2414
- @writer.start_tag('c:tx')
2415
-
2416
- # Write the c:v element.
2417
- write_v(title)
2418
-
2419
- @writer.end_tag('c:tx')
2312
+ @writer.tag_elements('c:tx') { write_v(title) }
2420
2313
  end
2421
2314
 
2422
2315
  #
@@ -2425,30 +2318,21 @@ def write_tx_value(title) # :nodoc:
2425
2318
  def write_tx_formula(title, data_id) # :nodoc:
2426
2319
  data = @formula_data[data_id] if data_id
2427
2320
 
2428
- @writer.start_tag('c:tx')
2429
-
2430
- # Write the c:strRef element.
2431
- write_str_ref(title, data, 'str')
2432
-
2433
- @writer.end_tag('c:tx')
2321
+ @writer.tag_elements('c:tx') { write_str_ref(title, data, 'str') }
2434
2322
  end
2435
2323
 
2436
2324
  #
2437
2325
  # Write the <c:rich> element.
2438
2326
  #
2439
2327
  def write_rich(title, horiz) # :nodoc:
2440
- @writer.start_tag('c:rich')
2441
-
2442
- # Write the a:bodyPr element.
2443
- write_a_body_pr(horiz)
2444
-
2445
- # Write the a:lstStyle element.
2446
- write_a_lst_style
2447
-
2448
- # Write the a:p element.
2449
- write_a_p_rich(title)
2450
-
2451
- @writer.end_tag('c:rich')
2328
+ @writer.tag_elements('c:rich') do
2329
+ # Write the a:bodyPr element.
2330
+ write_a_body_pr(horiz)
2331
+ # Write the a:lstStyle element.
2332
+ write_a_lst_style
2333
+ # Write the a:p element.
2334
+ write_a_p_rich(title)
2335
+ end
2452
2336
  end
2453
2337
 
2454
2338
  #
@@ -2479,54 +2363,38 @@ def write_a_lst_style # :nodoc:
2479
2363
  # Write the <a:p> element for rich string titles.
2480
2364
  #
2481
2365
  def write_a_p_rich(title) # :nodoc:
2482
- @writer.start_tag('a:p')
2483
-
2484
- # Write the a:pPr element.
2485
- write_a_p_pr_rich
2486
-
2487
- # Write the a:r element.
2488
- write_a_r(title)
2489
-
2490
- @writer.end_tag('a:p')
2366
+ @writer.tag_elements('a:p') do
2367
+ # Write the a:pPr element.
2368
+ write_a_p_pr_rich
2369
+ # Write the a:r element.
2370
+ write_a_r(title)
2371
+ end
2491
2372
  end
2492
2373
 
2493
2374
  #
2494
2375
  # Write the <a:p> element for formula titles.
2495
2376
  #
2496
2377
  def write_a_p_formula(title) # :nodoc:
2497
- @writer.start_tag('a:p')
2498
-
2499
- # Write the a:pPr element.
2500
- write_a_p_pr_formula
2501
-
2502
- # Write the a:endParaRPr element.
2503
- write_a_end_para_rpr
2504
-
2505
- @writer.end_tag('a:p')
2378
+ @writer.tag_elements('a:p') do
2379
+ # Write the a:pPr element.
2380
+ write_a_p_pr_formula
2381
+ # Write the a:endParaRPr element.
2382
+ write_a_end_para_rpr
2383
+ end
2506
2384
  end
2507
2385
 
2508
2386
  #
2509
2387
  # Write the <a:pPr> element for rich string titles.
2510
2388
  #
2511
2389
  def write_a_p_pr_rich # :nodoc:
2512
- @writer.start_tag('a:pPr')
2513
-
2514
- # Write the a:defRPr element.
2515
- write_a_def_rpr
2516
-
2517
- @writer.end_tag('a:pPr')
2390
+ @writer.tag_elements('a:pPr') { write_a_def_rpr }
2518
2391
  end
2519
2392
 
2520
2393
  #
2521
2394
  # Write the <a:pPr> element for formula titles.
2522
2395
  #
2523
2396
  def write_a_p_pr_formula # :nodoc:
2524
- @writer.start_tag('a:pPr')
2525
-
2526
- # Write the a:defRPr element.
2527
- write_a_def_rpr
2528
-
2529
- @writer.end_tag('a:pPr')
2397
+ @writer.tag_elements('a:pPr') { write_a_def_rpr }
2530
2398
  end
2531
2399
 
2532
2400
  #
@@ -2551,15 +2419,12 @@ def write_a_end_para_rpr # :nodoc:
2551
2419
  # Write the <a:r> element.
2552
2420
  #
2553
2421
  def write_a_r(title) # :nodoc:
2554
- @writer.start_tag('a:r')
2555
-
2556
- # Write the a:rPr element.
2557
- write_a_r_pr
2558
-
2559
- # Write the a:t element.
2560
- write_a_t(title)
2561
-
2562
- @writer.end_tag('a:r')
2422
+ @writer.tag_elements('a:r') do
2423
+ # Write the a:rPr element.
2424
+ write_a_r_pr
2425
+ # Write the a:t element.
2426
+ write_a_t(title)
2427
+ end
2563
2428
  end
2564
2429
 
2565
2430
  #
@@ -2584,18 +2449,14 @@ def write_a_t(title) # :nodoc:
2584
2449
  # Write the <c:txPr> element.
2585
2450
  #
2586
2451
  def write_tx_pr(horiz) # :nodoc:
2587
- @writer.start_tag('c:txPr')
2588
-
2589
- # Write the a:bodyPr element.
2590
- write_a_body_pr(horiz)
2591
-
2592
- # Write the a:lstStyle element.
2593
- write_a_lst_style
2594
-
2595
- # Write the a:p element.
2596
- write_a_p_formula
2597
-
2598
- @writer.end_tag('c:txPr')
2452
+ @writer.tag_elements('c:txPr') do
2453
+ # Write the a:bodyPr element.
2454
+ write_a_body_pr(horiz)
2455
+ # Write the a:lstStyle element.
2456
+ write_a_lst_style
2457
+ # Write the a:p element.
2458
+ write_a_p_formula
2459
+ end
2599
2460
  end
2600
2461
 
2601
2462
  #
@@ -2607,19 +2468,15 @@ def write_marker(marker = nil) # :nodoc:
2607
2468
  return if marker.nil? || marker == 0
2608
2469
  return if marker[:automatic] && marker[:automatic] != 0
2609
2470
 
2610
- @writer.start_tag('c:marker')
2611
-
2612
- # Write the c:symbol element.
2613
- write_symbol(marker[:type])
2614
-
2615
- # Write the c:size element.
2616
- size = marker[:size]
2617
- write_marker_size(size) if !size.nil? && size != 0
2618
-
2619
- # Write the c:spPr element.
2620
- write_sp_pr(marker)
2621
-
2622
- @writer.end_tag('c:marker')
2471
+ @writer.tag_elements('c:marker') do
2472
+ # Write the c:symbol element.
2473
+ write_symbol(marker[:type])
2474
+ # Write the c:size element.
2475
+ size = marker[:size]
2476
+ write_marker_size(size) if !size.nil? && size != 0
2477
+ # Write the c:spPr element.
2478
+ write_sp_pr(marker)
2479
+ end
2623
2480
  end
2624
2481
 
2625
2482
  #
@@ -2660,15 +2517,12 @@ def write_sp_pr(series) # :nodoc:
2660
2517
  return if (!series.has_key?(:_line) || series[:_line][:_defined].nil? || series[:_line][:_defined]== 0) &&
2661
2518
  (!series.has_key?(:_fill) || series[:_fill][:_defined].nil? || series[:_fill][:_defined]== 0)
2662
2519
 
2663
- @writer.start_tag('c:spPr')
2664
-
2665
- # Write the a:solidFill element for solid charts such as pie and bar.
2666
- write_a_solid_fill(series[:_fill]) if series[:_fill] && series[:_fill][:_defined] != 0
2667
-
2668
- # Write the a:ln element.
2669
- write_a_ln(series[:_line]) if series[:_line] && series[:_line][:_defined]
2670
-
2671
- @writer.end_tag('c:spPr')
2520
+ @writer.tag_elements('c:spPr') do
2521
+ # Write the a:solidFill element for solid charts such as pie and bar.
2522
+ write_a_solid_fill(series[:_fill]) if series[:_fill] && series[:_fill][:_defined] != 0
2523
+ # Write the a:ln element.
2524
+ write_a_ln(series[:_line]) if series[:_line] && series[:_line][:_defined]
2525
+ end
2672
2526
  end
2673
2527
 
2674
2528
  #
@@ -2688,24 +2542,21 @@ def write_a_ln(line) # :nodoc:
2688
2542
  attributes = ['w', width]
2689
2543
  end
2690
2544
 
2691
- @writer.start_tag('a:ln', attributes)
2692
-
2693
- # Write the line fill.
2694
- if !line[:none].nil? && line[:none] != 0
2695
- # Write the a:noFill element.
2696
- write_a_no_fill
2697
- else
2698
- # Write the a:solidFill element.
2699
- write_a_solid_fill(line)
2700
- end
2701
-
2702
- # Write the line/dash type.
2703
- if type = line[:dash_type]
2704
- # Write the a:prstDash element.
2705
- write_a_prst_dash(type)
2545
+ @writer.tag_elements('a:ln', attributes) do
2546
+ # Write the line fill.
2547
+ if !line[:none].nil? && line[:none] != 0
2548
+ # Write the a:noFill element.
2549
+ write_a_no_fill
2550
+ else
2551
+ # Write the a:solidFill element.
2552
+ write_a_solid_fill(line)
2553
+ end
2554
+ # Write the line/dash type.
2555
+ if type = line[:dash_type]
2556
+ # Write the a:prstDash element.
2557
+ write_a_prst_dash(type)
2558
+ end
2706
2559
  end
2707
-
2708
- @writer.end_tag('a:ln')
2709
2560
  end
2710
2561
 
2711
2562
  #
@@ -2719,16 +2570,14 @@ def write_a_no_fill # :nodoc:
2719
2570
  # Write the <a:solidFill> element.
2720
2571
  #
2721
2572
  def write_a_solid_fill(line) # :nodoc:
2722
- @writer.start_tag('a:solidFill')
2723
-
2724
- if line[:color]
2725
- color = get_color(line[:color])
2573
+ @writer.tag_elements('a:solidFill') do
2574
+ if line[:color]
2575
+ color = get_color(line[:color])
2726
2576
 
2727
- # Write the a:srgbClr element.
2728
- write_a_srgb_clr(color)
2577
+ # Write the a:srgbClr element.
2578
+ write_a_srgb_clr(color)
2579
+ end
2729
2580
  end
2730
-
2731
- @writer.end_tag('a:solidFill')
2732
2581
  end
2733
2582
 
2734
2583
  #
@@ -2755,31 +2604,22 @@ def write_a_prst_dash(val) # :nodoc:
2755
2604
  def write_trendline(trendline) # :nodoc:
2756
2605
  return unless trendline
2757
2606
 
2758
- @writer.start_tag('c:trendline')
2759
-
2760
- # Write the c:name element.
2761
- write_name(trendline[name])
2762
-
2763
- # Write the c:spPr element.
2764
- write_sp_pr(trendline)
2765
-
2766
- # Write the c:trendlineType element.
2767
- write_trendline_type(trendline[type])
2768
-
2769
- # Write the c:order element for polynomial trendlines.
2770
- write_trendline_order(trendline[order]) if trendline[type] == 'poly'
2771
-
2772
- # Write the c:period element for moving average trendlines.
2773
- write_period(trendline[period]) if trendline[type] == 'movingAvg'
2774
-
2775
-
2776
- # Write the c:forward element.
2777
- write_forward(trendline[forward])
2778
-
2779
- # Write the c:backward element.
2780
- write_backward(trendline[backward])
2781
-
2782
- @writer.end_tag('c:trendline')
2607
+ @writer.tag_elements('c:trendline') do
2608
+ # Write the c:name element.
2609
+ write_name(trendline[name])
2610
+ # Write the c:spPr element.
2611
+ write_sp_pr(trendline)
2612
+ # Write the c:trendlineType element.
2613
+ write_trendline_type(trendline[type])
2614
+ # Write the c:order element for polynomial trendlines.
2615
+ write_trendline_order(trendline[order]) if trendline[type] == 'poly'
2616
+ # Write the c:period element for moving average trendlines.
2617
+ write_period(trendline[period]) if trendline[type] == 'movingAvg'
2618
+ # Write the c:forward element.
2619
+ write_forward(trendline[forward])
2620
+ # Write the c:backward element.
2621
+ write_backward(trendline[backward])
2622
+ end
2783
2623
  end
2784
2624
 
2785
2625
  #
@@ -2862,43 +2702,25 @@ def write_overlap # :nodoc:
2862
2702
  # Write the <c:numCache> element.
2863
2703
  #
2864
2704
  def write_num_cache(data) # :nodoc:
2865
- count = data.size
2866
-
2867
- @writer.start_tag('c:numCache')
2868
-
2869
- # Write the c:formatCode element.
2870
- write_format_code('General')
2871
-
2872
- # Write the c:ptCount element.
2873
- write_pt_count(count)
2874
-
2875
- (0 .. count - 1).each do |i|
2876
-
2877
- # Write the c:pt element.
2878
- write_pt(i, data[i])
2705
+ @writer.tag_elements('c:numCache') do
2706
+ write_format_code('General')
2707
+ write_pt_count(data.size)
2708
+ write_pts(data)
2879
2709
  end
2880
-
2881
- @writer.end_tag('c:numCache')
2882
2710
  end
2883
2711
 
2884
2712
  #
2885
2713
  # Write the <c:strCache> element.
2886
2714
  #
2887
2715
  def write_str_cache(data) # :nodoc:
2888
- count = data.size
2889
-
2890
- @writer.start_tag('c:strCache')
2891
-
2892
- # Write the c:ptCount element.
2893
- write_pt_count(count)
2894
-
2895
- (0 .. count - 1).each do |i|
2896
-
2897
- # Write the c:pt element.
2898
- write_pt(i, data[i])
2716
+ @writer.tag_elements('c:strCache') do
2717
+ write_pt_count(data.size)
2718
+ write_pts(data)
2899
2719
  end
2720
+ end
2900
2721
 
2901
- @writer.end_tag('c:strCache')
2722
+ def write_pts(data)
2723
+ data.each_index { |i| write_pt(i, data[i])}
2902
2724
  end
2903
2725
 
2904
2726
  #
@@ -2925,12 +2747,7 @@ def write_pt(idx, value) # :nodoc:
2925
2747
 
2926
2748
  attributes = ['idx', idx]
2927
2749
 
2928
- @writer.start_tag('c:pt', attributes)
2929
-
2930
- # Write the c:v element.
2931
- write_v(value)
2932
-
2933
- @writer.end_tag('c:pt')
2750
+ @writer.tag_elements('c:pt', attributes) { write_v(value) }
2934
2751
  end
2935
2752
 
2936
2753
  #
@@ -2955,18 +2772,14 @@ def write_protection # :nodoc:
2955
2772
  def write_d_lbls(labels) # :nodoc:
2956
2773
  return unless labels
2957
2774
 
2958
- @writer.start_tag('c:dLbls')
2959
-
2960
- # Write the c:showVal element.
2961
- write_show_val if labels[value]
2962
-
2963
- # Write the c:showCatName element.
2964
- write_show_cat_name if labels[category]
2965
-
2966
- # Write the c:showSerName element.
2967
- write_show_ser_name if labels[series_name]
2968
-
2969
- @writer.end_tag('c:dLbls')
2775
+ @writer.tag_elements('c:dLbls') do
2776
+ # Write the c:showVal element.
2777
+ write_show_val if labels[value]
2778
+ # Write the c:showCatName element.
2779
+ write_show_cat_name if labels[category]
2780
+ # Write the c:showSerName element.
2781
+ write_show_ser_name if labels[series_name]
2782
+ end
2970
2783
  end
2971
2784
 
2972
2785
  #
@@ -3023,5 +2836,9 @@ def write_c_invert_if_negative(invert = nil) # :nodoc:
3023
2836
 
3024
2837
  @writer.empty_tag('c:invertIfNegative', attributes)
3025
2838
  end
2839
+
2840
+ def nil_or_max?(val)
2841
+ val.nil? || val == 'max'
2842
+ end
3026
2843
  end
3027
2844
  end