html/en/doc_en.html in writeexcel-0.6.7 vs html/en/doc_en.html in writeexcel-0.6.8
- old
+ new
@@ -966,11 +966,11 @@
<p>However, if the user edits this string Excel may convert it back to a number. To get around this you can use the Excel text format <code>@</code>:</p>
<pre>
# Format as a string. Doesn't change to a number when edited
- format1 = workbook.add_format(num_format => '@')
+ format1 = workbook.add_format(:num_format => '@')
worksheet.write_string('A2', '01209', format1)
</pre>
<p>See also the note about <a href="#Cell_notation" class="podlinkpod"
>"Cell notation"</a>.</p>
@@ -1082,11 +1082,11 @@
>write_col(row, column, array [, format])</a></h2>
<p>The <code>write_col</code> method can be used to write a 1D or 2D array of data in one go. This is useful for converting the results of a database query into an Excel worksheet. You must pass a reference to the array of data rather than the array itself. The <code>write</code> method is then called for each element of the data. For example:</p>
<pre>
- array = [39;awk', 'gawk', 'mawk']
+ array = ['awk', 'gawk', 'mawk']
worksheet.write_col(0, 0, array)
# The above example is equivalent to:
worksheet.write(0, 0, array[0])
@@ -1171,11 +1171,11 @@
<p>A date should always have a <code>format</code>, otherwise it will appear as a number, see <a href="#DATES_AND_TIME_IN_EXCEL" class="podlinkpod"
>"DATES AND TIME IN EXCEL"</a> and <a href="#CELL_FORMATTING" class="podlinkpod"
>"CELL FORMATTING"</a>. Here is a typical example:</p>
<pre>
- date_format = workbook.add_format(num_format => 'mm/dd/yy')
+ date_format = workbook.add_format(:num_format => 'mm/dd/yy')
worksheet.write_date_time('A1', '2004-05-13T23:20', date_format)
</pre>
<p>Valid dates should be in the range 1900-01-01 to 9999-12-31, for the 1900 epoch and 1904-01-01 to 9999-12-31, for the 1904 epoch. As with Excel, dates outside these ranges will be written as a string.</p>
@@ -1455,11 +1455,11 @@
<dd>
<p>This option is used to indicate that the comment string is encoded as <code>UTF-16BE</code>.</p>
<pre>
- comment = pack 'n', 0x263a; # UTF-16BE Smiley symbol
+ comment = [0x263a].pack('n') # UTF-16BE Smiley symbol
worksheet.write_comment('C3', comment, :encoding => 1)
</pre>
</dd>
<dt><a name="Option:_author"
@@ -1673,11 +1673,11 @@
>insert_chart(row, col, chart [, x, y, scale_x, scale_y])</a></h2>
<p>This method can be used to insert a Chart object into a worksheet. The Chart must be created by the <code>add_chart</code> Workbook method and it must have the <code>embedded</code> option set.</p>
<pre>
- chart = workbook.add_chart( type => 'Chart::Line', :embedded => true )
+ chart = workbook.add_chart( :type => 'Chart::Line', :embedded => true )
# Configure the chart.
...
# Insert the chart into the a worksheet.
@@ -1829,12 +1829,12 @@
<p>The <code>protect</code> method also has the effect of enabling a cell's <code>locked</code> and <code>hidden</code> properties if they have been set. A "locked" cell cannot be edited. A "hidden" cell will display the results of a formula but not the formula itself. In Excel a cell's locked property is on by default.</p>
<pre>
# Set some format properties
- unlocked = workbook.add_format(locked => 0)
- hidden = workbook.add_format(hidden => 1)
+ unlocked = workbook.add_format(:locked => 0)
+ hidden = workbook.add_format(:hidden => 1)
# Enable worksheet protection
worksheet.protect
# This cell cannot be edited, it is locked by default
@@ -2107,13 +2107,13 @@
<p>The <code>merge_range</code> method allows you to do Excel97+ style formatting where the cells can contain other types of alignment in addition to the merging:</p>
<pre>
format = workbook.add_format(
- border => 6,
- valign => 'vcenter',
- align => 'center',
+ :border => 6,
+ :valign => 'vcenter',
+ :align => 'center',
)
worksheet.merge_range('B3:D4', 'Vertical and horizontal', format)
</pre>
@@ -2590,21 +2590,21 @@
>set_landscape</a></h2>
<p>This method is used to set the orientation of a worksheet's printed page to landscape:</p>
<pre>
- worksheet.set_landscape; # Landscape mode
+ worksheet.set_landscape # Landscape mode
</pre>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="set_portrait"
>set_portrait</a></h2>
<p>This method is used to set the orientation of a worksheet's printed page to portrait. The default worksheet orientation is portrait, so you won't generally need to call this method.</p>
<pre>
- worksheet.set_portrait; # Portrait mode
+ worksheet.set_portrait # Portrait mode
</pre>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="set_page_view"
>set_page_view</a></h2>
@@ -2705,14 +2705,14 @@
<pre>
set_margins # Set all margins to the same value
set_margins_LR # Set left and right margins to the same value
set_margins_TB # Set top and bottom margins to the same value
- set_margin_left; # Set left margin
- set_margin_right; # Set right margin
- set_margin_top; # Set top margin
- set_margin_bottom; # Set bottom margin
+ set_margin_left # Set left margin
+ set_margin_right # Set right margin
+ set_margin_top # Set top margin
+ set_margin_bottom # Set bottom margin
</pre>
<p>All of these methods take a distance in inches as a parameter. Note: 1 inch = 25.4mm. ;-) The default left and right margin is 0.75 inch. The default top and bottom margin is 1.00 inch.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
@@ -3224,11 +3224,11 @@
<p>In general a method call without an argument will turn a property on, for example:</p>
<pre>
format1 = workbook.add_format
- format1.set_bold; # Turns bold on
+ format1.set_bold # Turns bold on
format1.set_bold(1) # Also turns bold on
format1.set_bold(0) # Turns bold off
</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
@@ -3273,27 +3273,27 @@
set_top_color
set_left_color
set_right_color
</pre>
-<p>The above methods can also be applied directly as properties. For example <code>format.set_bold</code> is equivalent to <code>workbook.add_format(bold => 1)</code>.</p>
+<p>The above methods can also be applied directly as properties. For example <code>format.set_bold</code> is equivalent to <code>workbook.add_format(:bold => 1)</code>.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="set_format_properties"
>set_format_properties(properties)</a></h2>
<p>The properties of an existing Format object can be also be set by means of <code>set_format_properties</code>:</p>
<pre>
format = workbook.add_format
- format.set_format_properties(bold => 1, color => 'red')
+ format.set_format_properties(:bold => 1, :color => 'red')
</pre>
<p>However, this method is here mainly for legacy reasons. It is preferable to set the properties in the format constructor:</p>
<pre>
- format = workbook.add_format(bold => 1, color => 'red')
+ format = workbook.add_format(:bold => 1, :color => 'red')
</pre>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="set_font"
>set_font(fontname)</a></h2>
@@ -3381,11 +3381,11 @@
</pre>
<p>Set the bold property of the font:</p>
<pre>
- format.set_bold; # Turn bold on
+ format.set_bold # Turn bold on
</pre>
<p>[1] Actually, values in the range 100..1000 are also valid. 400 is normal, 700 is bold and 1000 is very bold indeed. It is probably best to set the value to 1 and use normal bold.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
@@ -3399,11 +3399,11 @@
</pre>
<p>Set the italic property of the font:</p>
<pre>
- format.set_italic; # Turn italic on
+ format.set_italic # Turn italic on
</pre>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="set_underline"
>set_underline</a></h2>
@@ -3419,11 +3419,11 @@
</pre>
<p>Set the underline property of the font.</p>
<pre>
- format.set_underline; # Single underline
+ format.set_underline # Single underline
</pre>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="set_font_strikeout"
>set_font_strikeout</a></h2>
@@ -3844,11 +3844,11 @@
<p>Here is an example of how to set up a solid fill in a cell:</p>
<pre>
format = workbook.add_format
- format.set_pattern; # This is optional when using a solid fill
+ format.set_pattern # This is optional when using a solid fill
format.set_bg_color('green')
worksheet.write('A1', 'Ray', format)
</pre>
@@ -4140,15 +4140,15 @@
<p>The <code>add_series</code>, <code>set_x_axis</code>, <code>set_y_axis</code> and <code>set_title</code> methods all support a <code>name</code> property. These names can be UTF8 strings.</p>
<p>You can write Unicode strings as UTF-16BE by adding a <code>name_encoding</code> property:</p>
<pre>
- utf16be_name = pack 'n', 0x263A;
+ utf16be_name = [0x263a].pack('n')
chart.set_title(
- name => utf16be_name,
- name_encoding => 1,
+ :name => utf16be_name,
+ :name_encoding => 1,
)
</pre>
<h1><a class='u' href='#___top' title='click to go to top of document'
name="DATES_AND_TIME_IN_EXCEL"
@@ -4193,26 +4193,26 @@
number = 39506.5
worksheet.write('A1', number) # 39506.5
- format2 = workbook.add_format(num_format => 'dd/mm/yy')
+ format2 = workbook.add_format(:num_format => 'dd/mm/yy')
worksheet.write('A2', number , format2) # 28/02/08
- format3 = workbook.add_format(num_format => 'mm/dd/yy')
+ format3 = workbook.add_format(:num_format => 'mm/dd/yy')
worksheet.write('A3', number , format3) # 02/28/08
- format4 = workbook.add_format(num_format => 'd-m-yyyy')
+ format4 = workbook.add_format(:num_format => 'd-m-yyyy')
worksheet.write('A4', number , format4) # 28-2-2008
- format5 = workbook.add_format(num_format => 'dd/mm/yy hh:mm')
+ format5 = workbook.add_format(:num_format => 'dd/mm/yy hh:mm')
worksheet.write('A5', number , format5) # 28/02/08 12:00
- format6 = workbook.add_format(num_format => 'd mmm yyyy')
+ format6 = workbook.add_format(:num_format => 'd mmm yyyy')
worksheet.write('A6', number , format6) # 28 Feb 2008
- format7 = workbook.add_format(num_format => 'mmm d yyyy hh:mm AM/PM')
+ format7 = workbook.add_format(:num_format => 'mmm d yyyy hh:mm AM/PM')
worksheet.write('A7', number , format7) # Feb 28 2008 12:00 PM
</pre>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="WriteExcel_doesnt_automatically_convert_date_time_strings"
@@ -4252,11 +4252,11 @@
workbook = WriteExcel.new('example.xls')
worksheet = workbook.add_worksheet
# Set the default format for dates.
- date_format = workbook.add_format(num_format => 'mmm d yyyy')
+ date_format = workbook.add_format(:num_format => 'mmm d yyyy')
# Increase column width to improve visibility of data.
worksheet.set_column('A:C', 20)
# Simulate reading from a data source.
@@ -4417,11 +4417,11 @@
<p>The following sections describe how to use the <code>data_validation</code> method and its various options.</p>
<h2><a class='u' href='#___top' title='click to go to top of document'
name="data_validation"
->data_validation(row, col, { parameter => 'value', ... })</a></h2>
+>data_validation(row, col, { :parameter => 'value', ... })</a></h2>
<p>The <code>data_validation</code> method is used to construct an Excel data validation.</p>
<p>It can be applied to a single cell or a range of cells. You can pass 3 parameters such as <code>(row, col, {...})</code> or 5 parameters such as <code>(first_row, first_col, last_row, last_col, {...})</code>. You can also use <code>A1</code> style notation. For example:</p>
@@ -5446,16 +5446,16 @@
workbook = WriteExcel.new( 'chart_bar.xls' )
worksheet = workbook.add_worksheet
bold = workbook.add_format( :bold => 1 )
# Add the worksheet data that the charts will refer to.
- headings = [ 'Number', 'Sample 1', 'Sample 2' ];
+ headings = [ 'Number', 'Sample 1', 'Sample 2' ]
data = [
[ 2, 3, 4, 5, 6, 7 ],
[ 1, 4, 5, 2, 1, 5 ],
[ 3, 6, 7, 5, 4, 3 ],
- ];
+ ]
worksheet.write( 'A1', headings, bold )
worksheet.write( 'A2', data )
# Create a new chart object. In this case an embedded chart.
@@ -5506,16 +5506,16 @@
workbook = WriteExcel.new( 'chart_column.xls' )
worksheet = workbook.add_worksheet
bold = workbook.add_format( :bold => 1 )
# Add the worksheet data that the charts will refer to.
- headings = [ 'Number', 'Sample 1', 'Sample 2' ];
+ headings = [ 'Number', 'Sample 1', 'Sample 2' ]
data = [
[ 2, 3, 4, 5, 6, 7 ],
[ 1, 4, 5, 2, 1, 5 ],
[ 3, 6, 7, 5, 4, 3 ],
- ];
+ ]
worksheet.write( 'A1', headings, bold )
worksheet.write( 'A2', data )
# Create a new chart object. In this case an embedded chart.
@@ -5566,15 +5566,15 @@
workbook = WriteExcel.new( 'chart_line.xls' )
worksheet = workbook.add_worksheet
bold = workbook.add_format( :bold => 1 )
# Add the worksheet data that the charts will refer to.
- headings = [ 'Number', 'Sample 1', 'Sample 2' ];
+ headings = [ 'Number', 'Sample 1', 'Sample 2' ]
data = [
[ 2, 3, 4, 5, 6, 7 ],
[ 1, 4, 5, 2, 1, 5 ],
[ 3, 6, 7, 5, 4, 3 ],
- ];
+ ]
worksheet.write( 'A1', headings, bold )
worksheet.write( 'A2', data )
# Create a new chart object. In this case an embedded chart.