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&#39;t change to a number when edited - format1 = workbook.add_format(num_format =&#62; &#39;@&#39;) + format1 = workbook.add_format(:num_format =&#62; &#39;@&#39;) worksheet.write_string(&#39;A2&#39;, &#39;01209&#39;, format1) </pre> <p>See also the note about <a href="#Cell_notation" class="podlinkpod" >&#34;Cell notation&#34;</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&#39;, &#39;gawk&#39;, &#39;mawk&#39;] + array = [&#39;awk&#39;, &#39;gawk&#39;, &#39;mawk&#39;] 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" >&#34;DATES AND TIME IN EXCEL&#34;</a> and <a href="#CELL_FORMATTING" class="podlinkpod" >&#34;CELL FORMATTING&#34;</a>. Here is a typical example:</p> <pre> - date_format = workbook.add_format(num_format =&#62; &#39;mm/dd/yy&#39;) + date_format = workbook.add_format(:num_format =&#62; &#39;mm/dd/yy&#39;) worksheet.write_date_time(&#39;A1&#39;, &#39;2004-05-13T23:20&#39;, 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 &#39;n&#39;, 0x263a; # UTF-16BE Smiley symbol + comment = [0x263a].pack('n') # UTF-16BE Smiley symbol worksheet.write_comment(&#39;C3&#39;, comment, :encoding =&#62; 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 =&#62; &#39;Chart::Line&#39;, :embedded =&#62; true ) + chart = workbook.add_chart( :type =&#62; &#39;Chart::Line&#39;, :embedded =&#62; 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&#39;s <code>locked</code> and <code>hidden</code> properties if they have been set. A &#34;locked&#34; cell cannot be edited. A &#34;hidden&#34; cell will display the results of a formula but not the formula itself. In Excel a cell&#39;s locked property is on by default.</p> <pre> # Set some format properties - unlocked = workbook.add_format(locked =&#62; 0) - hidden = workbook.add_format(hidden =&#62; 1) + unlocked = workbook.add_format(:locked =&#62; 0) + hidden = workbook.add_format(:hidden =&#62; 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 =&#62; 6, - valign =&#62; &#39;vcenter&#39;, - align =&#62; &#39;center&#39;, + :border =&#62; 6, + :valign =&#62; &#39;vcenter&#39;, + :align =&#62; &#39;center&#39;, ) worksheet.merge_range(&#39;B3:D4&#39;, &#39;Vertical and horizontal&#39;, format) </pre> @@ -2590,21 +2590,21 @@ >set_landscape</a></h2> <p>This method is used to set the orientation of a worksheet&#39;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&#39;s printed page to portrait. The default worksheet orientation is portrait, so you won&#39;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 =&#62; 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 =&#62; 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 =&#62; 1, color =&#62; &#39;red&#39;) + format.set_format_properties(:bold =&#62; 1, :color =&#62; &#39;red&#39;) </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 =&#62; 1, color =&#62; &#39;red&#39;) + format = workbook.add_format(:bold =&#62; 1, :color =&#62; &#39;red&#39;) </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(&#39;green&#39;) worksheet.write(&#39;A1&#39;, &#39;Ray&#39;, 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 &#39;n&#39;, 0x263A; + utf16be_name = [0x263a].pack('n') chart.set_title( - name =&#62; utf16be_name, - name_encoding =&#62; 1, + :name =&#62; utf16be_name, + :name_encoding =&#62; 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(&#39;A1&#39;, number) # 39506.5 - format2 = workbook.add_format(num_format =&#62; &#39;dd/mm/yy&#39;) + format2 = workbook.add_format(:num_format =&#62; &#39;dd/mm/yy&#39;) worksheet.write(&#39;A2&#39;, number , format2) # 28/02/08 - format3 = workbook.add_format(num_format =&#62; &#39;mm/dd/yy&#39;) + format3 = workbook.add_format(:num_format =&#62; &#39;mm/dd/yy&#39;) worksheet.write(&#39;A3&#39;, number , format3) # 02/28/08 - format4 = workbook.add_format(num_format =&#62; &#39;d-m-yyyy&#39;) + format4 = workbook.add_format(:num_format =&#62; &#39;d-m-yyyy&#39;) worksheet.write(&#39;A4&#39;, number , format4) # 28-2-2008 - format5 = workbook.add_format(num_format =&#62; &#39;dd/mm/yy hh:mm&#39;) + format5 = workbook.add_format(:num_format =&#62; &#39;dd/mm/yy hh:mm&#39;) worksheet.write(&#39;A5&#39;, number , format5) # 28/02/08 12:00 - format6 = workbook.add_format(num_format =&#62; &#39;d mmm yyyy&#39;) + format6 = workbook.add_format(:num_format =&#62; &#39;d mmm yyyy&#39;) worksheet.write(&#39;A6&#39;, number , format6) # 28 Feb 2008 - format7 = workbook.add_format(num_format =&#62; &#39;mmm d yyyy hh:mm AM/PM&#39;) + format7 = workbook.add_format(:num_format =&#62; &#39;mmm d yyyy hh:mm AM/PM&#39;) worksheet.write(&#39;A7&#39;, 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(&#39;example.xls&#39;) worksheet = workbook.add_worksheet # Set the default format for dates. - date_format = workbook.add_format(num_format =&#62; &#39;mmm d yyyy&#39;) + date_format = workbook.add_format(:num_format =&#62; &#39;mmm d yyyy&#39;) # Increase column width to improve visibility of data. worksheet.set_column(&#39;A:C&#39;, 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 =&#62; &#39;value&#39;, ... })</a></h2> +>data_validation(row, col, { :parameter =&#62; &#39;value&#39;, ... })</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.