diff --git a/Changes b/Changes index dd43701..f6b9663 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,36 @@ Revision history for Perl module Spreadsheet::WriteExcel. + +2.20 October 6 2007 - Major + + + + Added autofilter() and filter_column() method and + autofilter.pl example. + + + Added embed_chart() method to allow extracted chart + templates to be embedded in a worksheet. + Added demo4.pl and demo5.pl examples. + + + Added the insert_image() method and proper Excel 97 + style image handling for PNG and BMP. + Images now work with Gnumeric and OpenOffice. + insert_bitmap() is now deprecated. + + ! Made pane split optional when calling freeze_panes(). + Also renamed thaw_panes() as split_panes(). The old + method name is still available, but deprected.. + + ! Renamed write_unicode() and write_unicode_le() methods + to the more explicit write_utf16be_string() and + write_utf16le_string(). The old method names are + still available, but deprected. + + +2.19 June 14 2007 - Major + + + Beta testing only. Not release to CPAN. + + 2.18 January 18 2007 - Minor ! Correct invalid user set_column() calls to prevent diff --git a/MANIFEST b/MANIFEST index 598030a..07b53ea 100644 --- a/MANIFEST +++ b/MANIFEST @@ -29,6 +29,9 @@ t/21_escher.t t/22_mso_drawing_group.t t/23_note.t t/24_txo.t +t/26_autofilter.t +t/27_autofilter.t +t/28_autofilter.t doc/index.html doc/WriteExcel.html @@ -54,6 +57,7 @@ doc/tpj0503-0004-05.gif doc/win32ole.gif examples/README +examples/autofilter.pl examples/autofit.pl examples/bigfile.pl examples/bug_report.pl @@ -95,7 +99,7 @@ examples/panes.pl examples/protection.pl examples/regions.pl examples/repeat.pl -examples/republic.bmp +examples/republic.png examples/right_to_left.pl examples/row_wrap.pl examples/sales.pl @@ -107,7 +111,6 @@ examples/stocks.pl examples/tab2xls.pl examples/tab_colors.pl examples/textwrap.pl -examples/unicode.pl examples/unicode_2022_jp.pl examples/unicode_2022_jp.txt examples/unicode_8859_11.pl @@ -121,7 +124,6 @@ examples/unicode_cp1251.txt examples/unicode_cp1256.pl examples/unicode_cp1256.txt examples/unicode_cyrillic.pl -examples/unicode_japan.pl examples/unicode_koi8r.pl examples/unicode_koi8r.txt examples/unicode_list.pl @@ -129,6 +131,8 @@ examples/unicode_polish_utf8.pl examples/unicode_polish_utf8.txt examples/unicode_shift_jis.pl examples/unicode_shift_jis.txt +examples/unicode_utf16.pl +examples/unicode_utf16_japan.pl examples/win32ole.pl examples/writeA1.pl examples/write_arrays.pl @@ -145,8 +149,12 @@ charts/charts.txt charts/demo1.pl charts/demo2.pl charts/demo3.pl +charts/demo4.pl +charts/demo5.pl charts/Chart1.xls charts/Chart2.xls charts/Chart3.xls +charts/Chart4.xls +charts/Chart5.xls bin/chartex diff --git a/META.yml b/META.yml index 3d4161d..5a11506 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ name: Spreadsheet-WriteExcel abstract: Write to a cross platform Excel binary file -version: 2.18 +version: 2.20 version_from: lib/Spreadsheet/WriteExcel.pm installdirs: site requires: diff --git a/Makefile.PL b/Makefile.PL index 82ef8f7..d07f301 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -13,7 +13,7 @@ WriteMakefile( 'NEEDS_LINKING' => 0, 'PREREQ_PM' => { Parse::RecDescent => 0, File::Temp => 0, - OLE::Storage_Lite => 0.14 + OLE::Storage_Lite => 0.14, }, 'dist' => { COMPRESS => 'gzip --best', SUFFIX => 'gz' }, 'EXE_FILES' => ['bin/chartex'], diff --git a/bin/chartex b/bin/chartex index cc81440..22fb193 100644 --- a/bin/chartex +++ b/bin/chartex @@ -5,7 +5,7 @@ # chartex - A utility to extract charts from an Excel file for # insertion into a Spreadsheet::WriteExcel file. # -# reverse('©'), September 2004, John McNamara, jmcnamara@cpan.org +# reverse('©'), September 2007, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # @@ -25,7 +25,8 @@ my $chart_index = 1; my $sheet_index = -1; my @sheetnames; my @exrefs; - +my $depth_count = 0; +my $max_font = 0; # # Do the Getopt and Pod::Usage routines. @@ -109,29 +110,76 @@ while (read $tmpfile, $header, 4) { my $filename = sprintf "%s%02d.bin", $chart_name, $chart_index; open CHART, ">$filename" or die "Couldn't open $filename: $!"; binmode CHART; - printf "\nExtracting \"%s\" to %s", $sheetnames[$sheet_index], - $filename; + + my $sheet_name = $sheetnames[$sheet_index]; + $sheet_name .= ' embedded' if $depth_count; + + printf "\nExtracting \%s\ to %s", $sheet_name, $filename; $in_chart = 1; $chart_index++; } - $sheet_index++; + $depth_count++; + } + + + # FBI, Chart fonts + if ($record == 0x1060) { + + my $index = substr $data, 8, 2, ''; + $index = unpack 'v', $index; + + # Ignore the inbuilt fonts. + if ($index >= 5) { + $max_font = $index if $index > $max_font; + + # Shift index past S::WE fonts + $index += 2; + } + + $data .= pack 'v', $index; + } + + # FONTX, Chart fonts + if ($record == 0x1026) { + + my $index = unpack 'v', $data; + + # Ignore the inbuilt fonts. + if ($index >= 5) { + $max_font = $index if $index > $max_font; + + # Shift index past S::WE fonts + $index += 2; + } + + $data = pack 'v', $index; } + + if ($in_chart) { print CHART $header, $data; } + # EOF if ($record == 0x000A) { $in_chart = 0; + $depth_count--; + $sheet_index++ if $depth_count == 0; +; } } - -print "\n\n", ('=' x 60), "\n"; -print "Add the following near the start of your program.\n"; -print "Change variable name \$worksheet if required.\n\n"; +if ($chart_index > 1) { + print "\n\n"; + print "Add the following near the start of your program\n"; + print "and change the variable names if required.\n\n"; +} +else { + print "\nNo charts found in workbook\n"; +} for my $aref (@exrefs) { my $sheet1 = $sheetnames[$aref->[1]]; @@ -148,9 +196,19 @@ for my $aref (@exrefs) { $range = "'$range'" if $range =~ /[^\w:]/; - print " \$worksheet->store_formula(\"=$range!A1\");\n"; + print " \$worksheet->store_formula('=$range!A1');\n"; } +print "\n"; + +for my $i (5 .. $max_font) { + + printf " my \$chart_font_%d = \$workbook->add_format(font_only => 1);\n", + $i -4; + +} + + @@ -213,7 +271,7 @@ John McNamara jmcnamara@cpan.org =head1 VERSION -Version 0.01. +Version 0.02. =head1 COPYRIGHT diff --git a/charts/Chart1.xls b/charts/Chart1.xls index 0b3b726..f7d698e 100644 Binary files a/charts/Chart1.xls and b/charts/Chart1.xls differ diff --git a/charts/Chart2.xls b/charts/Chart2.xls index 0a0b29d..3d4a4e4 100644 Binary files a/charts/Chart2.xls and b/charts/Chart2.xls differ diff --git a/charts/Chart3.xls b/charts/Chart3.xls index 58ff348..862b4d1 100644 Binary files a/charts/Chart3.xls and b/charts/Chart3.xls differ diff --git a/charts/Chart4.xls b/charts/Chart4.xls new file mode 100644 index 0000000..b756be9 Binary files /dev/null and b/charts/Chart4.xls differ diff --git a/charts/Chart5.xls b/charts/Chart5.xls new file mode 100644 index 0000000..612cccf Binary files /dev/null and b/charts/Chart5.xls differ diff --git a/charts/README b/charts/README index c99ba43..1fe3114 100644 --- a/charts/README +++ b/charts/README @@ -12,10 +12,14 @@ The files are as follows: demo1.pl A demo of a line chart. demo2.pl A demo of a pie chart. demo3.pl A demo of a Open-High-Low-Close stock chart. + demo4.pl A demo of a Open-High-Low-Close stock chart (embedded). + demo5.pl A demo of a line chart (embedded). Chart1.xls A template for use with demo1.pl. Chart2.xls A template for use with demo2.pl. Chart3.xls A template for use with demo3.pl. + Chart4.xls A template for use with demo4.pl. + Chart5.xls A template for use with demo5.pl. * If you performed a normal installation then the chartex utility should be installed to your 'somepath/perl/bin' directory and @@ -33,6 +37,12 @@ You can run the examples as follows: perl chartex.pl -c=demo3 Chart3.xls perl demo3.pl + perl chartex.pl -c=demo4 Chart4.xls + perl demo4.pl + + perl chartex.pl -c=demo5 Chart5.xls + perl demo5.pl + See charts.txt for further details of how to include externally generated charts in a Spreadsheet::WriteExcel file. diff --git a/charts/chartex.pl b/charts/chartex.pl index 091ddb1..2dd2330 100644 --- a/charts/chartex.pl +++ b/charts/chartex.pl @@ -5,7 +5,7 @@ # chartex - A utility to extract charts from an Excel file for # insertion into a Spreadsheet::WriteExcel file. # -# reverse('©'), September 2004, John McNamara, jmcnamara@cpan.org +# reverse('©'), September 2007, John McNamara, jmcnamara@cpan.org # # Documentation after __END__ # @@ -25,7 +25,8 @@ my $sheet_index = -1; my @sheetnames; my @exrefs; - +my $depth_count = 0; +my $max_font = 0; # # Do the Getopt and Pod::Usage routines. @@ -109,29 +110,76 @@ my $filename = sprintf "%s%02d.bin", $chart_name, $chart_index; open CHART, ">$filename" or die "Couldn't open $filename: $!"; binmode CHART; - printf "\nExtracting \"%s\" to %s", $sheetnames[$sheet_index], - $filename; + + my $sheet_name = $sheetnames[$sheet_index]; + $sheet_name .= ' embedded' if $depth_count; + + printf "\nExtracting \%s\ to %s", $sheet_name, $filename; $in_chart = 1; $chart_index++; } - $sheet_index++; + $depth_count++; + } + + + # FBI, Chart fonts + if ($record == 0x1060) { + + my $index = substr $data, 8, 2, ''; + $index = unpack 'v', $index; + + # Ignore the inbuilt fonts. + if ($index >= 5) { + $max_font = $index if $index > $max_font; + + # Shift index past S::WE fonts + $index += 2; + } + + $data .= pack 'v', $index; + } + + # FONTX, Chart fonts + if ($record == 0x1026) { + + my $index = unpack 'v', $data; + + # Ignore the inbuilt fonts. + if ($index >= 5) { + $max_font = $index if $index > $max_font; + + # Shift index past S::WE fonts + $index += 2; + } + + $data = pack 'v', $index; } + + if ($in_chart) { print CHART $header, $data; } + # EOF if ($record == 0x000A) { $in_chart = 0; + $depth_count--; + $sheet_index++ if $depth_count == 0; +; } } - -print "\n\n", ('=' x 60), "\n"; -print "Add the following near the start of your program.\n"; -print "Change variable name \$worksheet if required.\n\n"; +if ($chart_index > 1) { + print "\n\n"; + print "Add the following near the start of your program\n"; + print "and change the variable names if required.\n\n"; +} +else { + print "\nNo charts found in workbook\n"; +} for my $aref (@exrefs) { my $sheet1 = $sheetnames[$aref->[1]]; @@ -151,6 +199,16 @@ print " \$worksheet->store_formula('=$range!A1');\n"; } +print "\n"; + +for my $i (5 .. $max_font) { + + printf " my \$chart_font_%d = \$workbook->add_format(font_only => 1);\n", + $i -4; + +} + + @@ -213,7 +271,7 @@ =head1 AUTHOR =head1 VERSION -Version 0.01. +Version 0.02. =head1 COPYRIGHT diff --git a/charts/demo1.pl b/charts/demo1.pl index e541ae7..1d05d5e 100644 --- a/charts/demo1.pl +++ b/charts/demo1.pl @@ -30,9 +30,9 @@ # Add some extra formats to cover formats used in the charts. -$workbook->add_format(color => 1); -$workbook->add_format(color => 2); -$workbook->add_format(color => 3); +my $chart_font_1 = $workbook->add_format(font_only => 1); +my $chart_font_2 = $workbook->add_format(font_only => 1); +my $chart_font_3 = $workbook->add_format(font_only => 1); # Add all other formats (if any). diff --git a/charts/demo2.pl b/charts/demo2.pl index e22c9f1..68c81b4 100644 --- a/charts/demo2.pl +++ b/charts/demo2.pl @@ -30,10 +30,11 @@ # Add some extra formats to cover formats used in the charts. -$workbook->add_format(color => 1, bold => 1); -$workbook->add_format(color => 2); -$workbook->add_format(color => 3); - +my $chart_font_1 = $workbook->add_format(font_only => 1); +my $chart_font_2 = $workbook->add_format(font_only => 1); +my $chart_font_3 = $workbook->add_format(font_only => 1); +my $chart_font_4 = $workbook->add_format(font_only => 1); +my $chart_font_5 = $workbook->add_format(font_only => 1); # Add all other formats. my $bold = $workbook->add_format(bold => 1); diff --git a/charts/demo3.pl b/charts/demo3.pl index d67375c..e6bfbf3 100644 --- a/charts/demo3.pl +++ b/charts/demo3.pl @@ -30,11 +30,11 @@ # Add some extra formats to cover formats used in the charts. -$workbook->add_format(color => 1); -$workbook->add_format(color => 2); -$workbook->add_format(color => 3, bold => 1); -$workbook->add_format(color => 4); - +my $chart_font_1 = $workbook->add_format(font_only => 1); +my $chart_font_2 = $workbook->add_format(font_only => 1); +my $chart_font_3 = $workbook->add_format(font_only => 1); +my $chart_font_4 = $workbook->add_format(font_only => 1); +my $chart_font_5 = $workbook->add_format(font_only => 1); # Add all other formats. my $bold = $workbook->add_format(bold => 1); @@ -47,7 +47,7 @@ $worksheet->write('A1', 'Date', $bold); $worksheet->write('B1', 'Open', $bold); $worksheet->write('C1', 'High', $bold); -$worksheet->write('D1', 'Low', $bold); +$worksheet->write('D1', 'Low', $bold); $worksheet->write('E1', 'Close', $bold); diff --git a/charts/demo4.pl b/charts/demo4.pl new file mode 100644 index 0000000..6ad6f72 --- /dev/null +++ b/charts/demo4.pl @@ -0,0 +1,109 @@ +#!/usr/bin/perl -w + +############################################################################### +# +# Simple example of how to embed an externally created chart into a +# Spreadsheet:: WriteExcel worksheet. +# +# +# This example adds an "Open-high-low-close" stock chart extracted from the +# file Chart3.xls as follows: +# +# perl chartex.pl -c=demo4 Chart4.xls +# +# reverse('©'), September 2007, John McNamara, jmcnamara@cpan.org +# + +use strict; +use Spreadsheet::WriteExcel; + +my $workbook = Spreadsheet::WriteExcel->new("demo4.xls"); +my $worksheet = $workbook->add_worksheet(); + + +# Add the chart extracted using the chartex utility +$worksheet->embed_chart('G2', 'demo401.bin', 3, 3, 1.08, 1.21); + + +# Add some extra formats to cover formats used in the charts. +my $chart_font_1 = $workbook->add_format(font_only => 1); +my $chart_font_2 = $workbook->add_format(font_only => 1, bold => 1); +my $chart_font_3 = $workbook->add_format(font_only => 1); +my $chart_font_4 = $workbook->add_format(font_only => 1); + +# Add all other formats. +my $bold = $workbook->add_format(bold => 1); +my $date_format = $workbook->add_format(num_format => 'dd/mm/yyyy'); + + +# Adjust column widths and add some headers +$worksheet->set_column('A:A', 12); + +$worksheet->write('A1', 'Date', $bold); +$worksheet->write('B1', 'Open', $bold); +$worksheet->write('C1', 'High', $bold); +$worksheet->write('D1', 'Low', $bold); +$worksheet->write('E1', 'Close', $bold); + + +# Add data to range that the chart refers to. +my @dates = ( + + "2004-08-19T", + "2004-08-20T", + "2004-08-23T", + "2004-08-24T", + "2004-08-25T", + "2004-08-26T", + "2004-08-27T", + "2004-08-30T", + "2004-08-31T", + "2004-09-01T", + "2004-09-02T", + "2004-09-03T", + "2004-09-07T", + "2004-09-08T", + "2004-09-09T", + "2004-09-10T", + "2004-09-13T", + "2004-09-14T", + "2004-09-15T", + "2004-09-16T", + "2004-09-17T", + "2004-09-20T", + "2004-09-21T", +); + +# Open-High-Low-Close prices +my @prices = ( + + [100.00, 104.06, 95.96, 100.34], + [101.01, 109.08, 100.50, 108.31], + [110.75, 113.48, 109.05, 109.40], + [111.24, 111.60, 103.57, 104.87], + [104.96, 108.00, 103.88, 106.00], + [104.95, 107.95, 104.66, 107.91], + [108.10, 108.62, 105.69, 106.15], + [105.28, 105.49, 102.01, 102.01], + [102.30, 103.71, 102.16, 102.37], + [102.70, 102.97, 99.67, 100.25], + [ 99.19, 102.37, 98.94, 101.51], + [100.95, 101.74, 99.32, 100.01], + [101.01, 102.00, 99.61, 101.58], + [100.74, 103.03, 100.50, 102.30], + [102.53, 102.71, 101.00, 102.31], + [101.60, 106.56, 101.30, 105.33], + [106.63, 108.41, 106.46, 107.50], + [107.45, 112.00, 106.79, 111.49], + [110.56, 114.23, 110.20, 112.00], + [112.34, 115.80, 111.65, 113.97], + [114.42, 117.49, 113.55, 117.49], + [116.95, 121.60, 116.77, 119.36], + [119.81, 120.42, 117.51, 117.84], +); + + + +my $row = 1; +$worksheet->write_date_time($row++, 0, $_, $date_format) for @dates; +$worksheet->write_col('B2', \@prices); diff --git a/charts/demo5.pl b/charts/demo5.pl new file mode 100644 index 0000000..c289a43 --- /dev/null +++ b/charts/demo5.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +############################################################################### +# +# Simple example of how to embed an externally created chart into a +# Spreadsheet:: WriteExcel worksheet. +# +# +# This example adds a line chart extracted from the file Chart1.xls as follows: +# +# perl chartex.pl -c=demo5 Chart5.xls +# +# +# reverse('©'), September 2007, John McNamara, jmcnamara@cpan.org +# + +use strict; +use Spreadsheet::WriteExcel; + +my $workbook = Spreadsheet::WriteExcel->new('demo5.xls'); +my $worksheet = $workbook->add_worksheet(); + + +# Embed a chart extracted using the chartex utility +$worksheet->embed_chart('D3', 'demo501.bin'); + + +# Add some extra formats to cover formats used in the charts. +my $chart_font_1 = $workbook->add_format(font_only => 1); +my $chart_font_2 = $workbook->add_format(font_only => 1); + +# Add all other formats (if any). + + +# Add data to range that the chart refers to. +my @nums = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ); +my @squares = (0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100); + +$worksheet->write_col('A1', \@nums ); +$worksheet->write_col('B1', \@squares); + diff --git a/doc/WriteExcel.html b/doc/WriteExcel.html index 610675e..4b8c397 100644 --- a/doc/WriteExcel.html +++ b/doc/WriteExcel.html @@ -63,8 +63,8 @@
-This document refers to version 2.18 of Spreadsheet::WriteExcel, released -January 18, 2007. +This document refers to version 2.20 of Spreadsheet::WriteExcel, released +October 6, 2007.
@@ -344,7 +347,7 @@
This will create an Excel file called perl.xls
with a single worksheet and the text "Hi Excel!"
in the relevant cell. And that's it. Okay, so there is actually a zeroth
-step as well, but use module
goes without saying. There are also more than 70 examples that come with
+step as well, but use module
goes without saying. There are also more than 80 examples that come with
the distribution and which you can use to get you started. See EXAMPLES.
Note about the requirement for binmode()
: An Excel file is comprised of binary data. Therefore, if you are using a
filehandle you should ensure that you binmode()
it prior to passing it to new()
.You should do this regardless of whether you are on a Windows platform or
-not. This applies especially to users of perl 5.8 on systems where utf8 is
-likely to be in operation such as RedHat Linux 9. If your program, either
-intentionally or not, writes UTF8 data to a filehandle that is passed to new()
it will corrupt the Excel file that is created.
+not. This applies especially to users of perl 5.8 on systems where UTF-8
is likely to be in operation such as RedHat Linux 9. If your program,
+either intentionally or not, writes UTF-8
data to a filehandle that is passed to new()
it will corrupt the Excel file that is created.
@@ -719,7 +721,7 @@
-On systems with perl 5.8
and later the add_worksheet()
method will also handle strings in Perl's utf8
format.
+On systems with perl 5.8
and later the add_worksheet()
method will also handle strings in <UTF-8> format.
@@ -728,8 +730,7 @@
-On earlier Perl systems your can specify UTF-16BE worksheet names using an
-additional encoding parameter:
+On earlier Perl systems your can specify UTF-16BE
worksheet names using an additional encoding parameter:
@@ -920,7 +921,7 @@
-See also DATES IN EXCEL for more information about working with Excel's date system. +See also DATES AND TIME IN EXCEL for more information about working with Excel's date system.
@@ -974,8 +975,8 @@
@@ -1223,7 +1225,7 @@
-On systems with perl 5.8
and later the write()
method will also handle Unicode strings in Perl's utf8
format.
+On systems with perl 5.8
and later the write()
method will also handle Unicode strings in UTF-8
format.
@@ -1283,7 +1285,7 @@
-On systems with perl 5.8
and later the write()
method will also handle strings in Perl's utf8
format. With older perls you can also write Unicode in UTF16
format via the write_unicode()
method. See also the unicode_*.pl
programs in the examples directory of the distro.
+On systems with perl 5.8
and later the write()
method will also handle strings in UTF-8
format. With older perls you can also write Unicode in UTF16
format via the write_utf16be_string()
method. See also the unicode_*.pl
programs in the examples directory of the distro.
@@ -1315,25 +1317,15 @@
-This method is used to write Unicode strings to a cell in Excel. It is
-functionally the same as the write_string()
method except that the string should be in UTF-16 Unicode format.
+This method is used to write UTF-16BE
strings to a cell in Excel. It is functionally the same as the write_string()
method except that the string should be in UTF-16BE
Unicode format. It is generally easier, when using Spreadsheet::WriteExcel,
+to write unicode strings in UTF-8
format, see UNICODE IN EXCEL. The write_utf16be_string()
method is mainly of use in versions of perl prior to 5.8.
-Note: on systems with perl 5.8
and later the write()
and write_string()
methods will also handle strings in Perl's utf8
format. With older perls you must use the write_unicode()
method.
-
-
-The Unicode format required by Excel is UTF-16. Additionally Spreadsheet::WriteExcel
requires that the 16-bit characters are in big-endian order. This is
-generally referred to as UTF-16BE. To write UTF-16 strings in little-endian
-format use the write_unicode_le()
method.
-
-
-The following is a simple example showing how to write some Unicode
-strings:
+The following is a simple example showing how to write some Unicode strings
+in UTF-16BE
format:
@@ -1350,7 +1342,7 @@
- my $workbook = Spreadsheet::WriteExcel->new('unicode.xls'); + my $workbook = Spreadsheet::WriteExcel->new('utf_16_be.xls'); my $worksheet = $workbook->add_worksheet();@@ -1375,20 +1367,20 @@
- $worksheet->write_unicode('A3', $smiley, $big_font); + $worksheet->write_utf16be_string('A3', $smiley, $big_font);
# Write a phrase in Cyrillic using a hex-encoded string # - my $uni_str = pack "H*", "042d0442043e0020044404400430043704300020043d" . - "043000200440044304410441043a043e043c0021"; + my $str = pack "H*", "042d0442043e0020044404400430043704300020043d" . + "043000200440044304410441043a043e043c0021";
- $worksheet->write_unicode('A5', $uni_str); + $worksheet->write_utf16be_string('A5', $str);
@@ -1401,64 +1393,11 @@
- $worksheet->write_unicode('A7', $utf16); -- -
-The following is an example of creating an Excel file with some Japanese
-text. You will need to have a Unicode font installed, such as Arial Unicode MS
, to view the results:
-
-
-
- #!/usr/bin/perl -w -- -
-
- use strict; - use Spreadsheet::WriteExcel; -- -
-
- my $workbook = Spreadsheet::WriteExcel->new('unicode.xls'); - my $worksheet = $workbook->add_worksheet(); -- -
-
- # It is only required to specify a Unicode font via add_format() if - # you are using Excel 97. For Excel 2000+ the text will display - # with the default font (if you have Unicode fonts installed). - # - my $uni_font = $workbook->add_format(font => 'Arial Unicode MS'); -- -
-
- my $kanji = pack 'n*', 0x65e5, 0x672c; - my $katakana = pack 'n*', 0xff86, 0xff8e, 0xff9d; - my $hiragana = pack 'n*', 0x306b, 0x307b, 0x3093; -- -
-
- $worksheet->write_unicode('A1', $kanji, $uni_font); - $worksheet->write_unicode('A2', $katakana, $uni_font); - $worksheet->write_unicode('A3', $hiragana, $uni_font); -- -
-
- $worksheet->write('B1', 'Kanji'); - $worksheet->write('B2', 'Katakana'); - $worksheet->write('B3', 'Hiragana'); + $worksheet->write_utf16be_string('A7', $utf16);
-Note: You can convert ascii encodings to the required UTF-16BE format using
-one of the many Unicode modules on CPAN. For example Unicode::Map
and Unicode::String
: UTF-16BE format using one of the many Unicode modules on CPAN. For example Unicode::Map
and Unicode::String
: http://search.cpan.org/author/MSCHWARTZ/Unicode-Map/Map.pm
and http://search.cpan.org/author/GAAS/Unicode-String/String.pm
@@ -1470,6 +1409,14 @@
+UTF-16BE
is the format most often returned by Perl
modules that generate UTF-16
. To write UTF-16
strings in little-endian format use the write_utf16be_string_le()
method below.
+
+
+The write_utf16be_string()
method was previously called write_unicode()
. That, overly general, name is still supported but deprecated.
+
See also the unicode_*.pl
programs in the examples directory of the distro.
@@ -1477,27 +1424,21 @@
-This method is the same as write_unicode()
except that the string should be 16-bit characters in little-endian format.
-This is generally referred to as UTF-16LE.
+This method is the same as write_utf16be()
except that the string should be 16-bit characters in little-endian format.
+This is generally referred to as UTF-16LE
. See UNICODE IN EXCEL.
-UTF-16 data can be changed from little-endian to big-endian format (and
+UTF-16
data can be changed from little-endian to big-endian format (and
vice-versa) as follows:
- $utf16 = pack "n*", unpack "v*", $utf16; + $utf16be = pack "n*", unpack "v*", $utf16le;- -
-Note, it is slightly faster to write little-endian data via
-write_unicode_le()
than it is to write big-endian data via
-write_unicode().
-
-A date should always have a $format
, otherwise it will appear as a number, see DATES IN EXCEL and CELL FORMATTING. Here is a typical example:
+A date should always have a $format
, otherwise it will appear as a number, see DATES AND TIME IN EXCEL and CELL FORMATTING. Here is a typical example:
@@ -2373,11 +2314,6 @@
-NOTE: This method is currently incompatible with insert_bitmap()
. You can use either method but not both in the same workbook. This will be
-fixed soon.
-
-
The write_comment()
method is used to add a comment to a cell. A cell comment is indicated in
Excel by a small red triangle in the upper right-hand corner of the cell.
Moving the cursor over the red triangle will reveal the comment.
@@ -2404,7 +2340,7 @@
-On systems with perl 5.8
and later the write_comment()
method will also handle strings in Perl's utf8
format.
+On systems with perl 5.8
and later the write_comment()
method will also handle strings in UTF-8
format.
@@ -2451,8 +2387,7 @@
-This option is used to indicate that the comment string is encoded as
-UTF-16BE.
+This option is used to indicate that the comment string is encoded as UTF-16BE
.
@@ -2467,7 +2402,7 @@
If you wish to use Unicode characters in the comment string then the
-preferred method is to use perl 5.8 and UTF-8 strings.
+preferred method is to use perl 5.8 and UTF-8
strings, see UNICODE IN EXCEL.
-This option is used to indicate that the author string is encoded as
-UTF-16BE.
+This option is used to indicate that the author string is encoded as UTF-16BE
.
-The method is use as follows. say you wished to write 7 digit ID numbers as -a string so that any leading zeros were preserved*, you could do something -like the following: +The method is used as follows. say you wished to write 7 digit ID numbers +as a string so that any leading zeros were preserved*, you could do +something like the following:
@@ -2812,36 +2746,18 @@
-NOTE: This method is currently incompatible with write_comment()
. You can use either method but not both in the same workbook. This will be
-fixed soon.
-
-
-NOTE: The images inserted using this method do not display in OpenOffice.org or -Gnumeric. This is related to the previous note and will also be fixed soon. - -
+
-This method can be used to insert a bitmap into a worksheet. The bitmap
-must be a 24 bit, true colour, bitmap. No other format is supported. The $x
, $y
, $scale_x
and $scale_y
parameters are optional.
+This method can be used to insert a image into a worksheet. The image can
+be in PNG or BMP format. The $x
, $y
, $scale_x
and $scale_y
parameters are optional.
- $worksheet1->insert_bitmap('A1', 'perl.bmp'); - $worksheet2->insert_bitmap('A1', '../images/perl.bmp'); - $worksheet3->insert_bitmap('A1', '.c:\images\perl.bmp'); + $worksheet1->insert_image('A1', 'perl.bmp'); + $worksheet2->insert_image('A1', '../images/perl.bmp'); + $worksheet3->insert_image('A1', '.c:\images\perl.bmp');- -
-Note: you must call set_row()
or set_column()
before insert_bitmap()
if you wish to change the default dimensions of any of the rows or columns
-that the images occupies. The height of a row can also change if you use a
-font that is larger than the default. This in turn will affect the scaling
-of your image. To avoid this you should explicitly set the height of the
-row using set_row()
if it contains a font size that will change the row height.
-
The parameters $x
and $y
can be used to specify an offset from the top left hand corner of the cell
@@ -2850,7 +2766,7 @@
- $worksheet1->insert_bitmap('A1', 'perl.bmp', 32, 10); + $worksheet1->insert_image('A1', 'perl.bmp', 32, 10);
@@ -2888,29 +2804,85 @@
# Scale the inserted image: width x 2.0, height x 0.8 - $worksheet->insert_bitmap('A1', 'perl.bmp', 0, 0, 2, 0.8); + $worksheet->insert_image('A1', 'perl.bmp', 0, 0, 2, 0.8); ++ +
+See also the images.pl
program in the examples
directory of the distro.
+
+
+Note: you must call set_row()
or set_column()
before insert_image()
if you wish to change the default dimensions of any of the rows or columns
+that the image occupies. The height of a row can also change if you use a
+font that is larger than the default. This in turn will affect the scaling
+of your image. To avoid this you should explicitly set the height of the
+row using set_row()
if it contains a font size that will change the row height.
+
+
+BMP images must be 24 bit, true colour, bitmaps. In general it is best to
+avoid BMP images since they aren't compressed. The older insert_bitmap()
method is still supported but deprecated.
+
+
+
+This method can be used to insert a chart into a worksheet. The chart must
+first be extracted from an existing Excel file. See the separate Charts
documentation.
+
+
+Here is an example: + +
++
+ $worksheet->embed_chart('B2', 'sales_chart.bin');
-Note: although Excel allows you to import several graphics formats such as
-gif, jpeg, png and eps these are converted internally into a proprietary
-format. One of the few non-proprietary formats that Excel supports is 24
-bit, true colour, bitmaps. Therefore if you wish to use images in any other
-format you must first use an external application such as the ImageMagick convert utility to convert them to 24 bit bitmaps.
+The $x
, $y
, $scale_x
and $scale_y
parameters are optional.
+
+
+The parameters $x
and $y
can be used to specify an offset from the top left hand corner of the cell
+specified by $row
and $col
. The offset values are in pixels. See the insert_image
method above for more information on sizes.
- convert test.png test.bmp + $worksheet1->embed_chart('B2', 'sales_chart.bin', 3, 3);
-A later release will support the use of file handles and pre-encoded bitmap
-strings.
+The parameters $scale_x
and $scale_y
can be used to scale the inserted image horizontally and vertically:
-See also the images.pl
program in the examples
directory of the distro.
+
+ # Scale the width by 120% and the height by 150% + $worksheet->embed_chart('B2', 'sales_chart.bin', 0, 0, 1.2, 1.5); ++ +
+The easiest way to calculate the required scaling is to create a test chart +worksheet with Spreadsheet::WriteExcel. Then open the file, select the +chart and drag the corner to get the required size. While holding down the +mouse the scale of the resized chart is shown to the left of the formula +bar. + +
+
+See also the example programs in the charts
directory of the distro.
+
+
+Note: you must call set_row()
or set_column()
before embed_chart()
if you wish to change the default dimensions of any of the rows or columns
+that the chart occupies. The height of a row can also change if you use a
+font that is larger than the default. This in turn will affect the scaling
+of your chart. To avoid this you should explicitly set the height of the
+row using set_row()
if it contains a font size that will change the row height.
@@ -2926,6 +2898,11 @@
+For reasons related to the design of Spreadsheet::WriteExcel and to the
+internals of Excel there is no set_name()
method. The only way to set the worksheet name is via the add_worksheet()
method.
+
This is similar to the Excel VBA activate method. More than one worksheet
-can be selected via the select()
method, however only one worksheet can be active. The default value is the
-first worksheet.
+can be selected via the select()
method, see below, however only one worksheet can be active.
+
+
+The default active worksheet is the first worksheet.
@@ -2971,7 +2951,7 @@
A selected worksheet has its tab highlighted. Selecting worksheets is a way
of grouping them together so that, for example, several worksheets could be
-printed in one go. A worksheet that has been activated via the activate()
method will also appear as selected. You probably won't need to use the select()
method very often.
+printed in one go. A worksheet that has been activated via the activate()
method will also appear as selected.
@@ -2983,7 +2963,7 @@
- $worksheet->hide(); + $worksheet2->hide();
@@ -2993,8 +2973,16 @@
A hidden worksheet can not be activated or selected so this method is
-mutually exclusive with the activate()
and select()
methods.
+mutually exclusive with the activate()
and select()
methods. In addition, since the first worksheet will default to being the
+active worksheet, you cannot hide the first worksheet without activating
+another sheet:
+
+
+ $worksheet2->activate(); + $worksheet1->hide(); +
This method can be used to divide a worksheet into horizontal or vertical
regions known as panes. This method is different from the freeze_panes()
method in that the splits between the panes will be visible to the user and
@@ -3469,9 +3457,9 @@
- $worksheet->thaw_panes(12.75, 0, 1, 0); # First row - $worksheet->thaw_panes(0, 8.43, 0, 1); # First column - $worksheet->thaw_panes(12.75, 8.43, 1, 1); # First row and column + $worksheet->split_panes(12.75, 0, 1, 0); # First row + $worksheet->split_panes(0, 8.43, 0, 1); # First column + $worksheet->split_panes(12.75, 8.43, 1, 1); # First row and column
@@ -3481,6 +3469,11 @@
See also the freeze_panes()
method and the panes.pl
program in the examples
directory of the distribution.
+
+Note: This split_panes()
method was called thaw_panes()
in older versions. The older name is still available for backwards
+compatiblity.
+
-On systems with perl 5.8
and later the merge_range()
method will also handle strings in Perl's utf8
format.
+On systems with perl 5.8
and later the merge_range()
method will also handle strings in UTF-8
format.
@@ -3540,8 +3533,7 @@
-On earlier Perl systems your can specify UTF-16BE worksheet names using an
-additional encoding parameter:
+On earlier Perl systems your can specify UTF-16BE
worksheet names using an additional encoding parameter:
@@ -3631,6 +3623,180 @@
See the tab_colors.pl
program in the examples directory of the distro.
+
+
+This method allows an autofilter to be added to a worksheet. An autofilter +is a way of adding drop down lists to the headers of a 2D range of +worksheet data. This is turn allow users to filter the data based on simple +criteria so that some data is highlighted and some is hidden. + +
++To add an autofilter to a worksheet: + +
++
+ $worksheet->autofilter(0, 0, 10, 3); + $worksheet->autofilter('A1:D11'); # Same as above in A1 notation. ++ +
+Filter conditions can be applied using the filter_column()
method.
+
+
+See the autofilter.pl
program in the examples directory of the distro for a more detailed
+example.
+
+
+
+The filter_column
method can be used to filter columns in a autofilter range based on simple
+conditions.
+
+
+NOTE: It isn't sufficient to just specify the filter condition. You must also
+hide any rows that don't match the filter condition. Rows are hidden using
+the set_row()
visible
parameter. Spreadsheet::WriteExcel
cannot do this automatically since it isn't part of the file format. See
+the autofilter.pl
program in the examples directory of the distro for an example.
+
+
+The conditions for the filter are specified using simple expressions: + +
++
+ $worksheet->filter_column('A', 'x > 2000'); + $worksheet->filter_column('B', 'x > 2000 and x < 5000'); ++ +
+The $column
parameter can either be a zero indexed column number or a string column
+name.
+
+
+The following operators are available: + +
++
+ Operator Synonyms + == = eq =~ + != <> ne != + > + < + >= + <= ++ +
+
+ and && + or || ++ +
+The operator synonyms are just syntactic sugar to make you more comfortable +using the expressions. It is important to remember that the expressions +will be interpreted by Excel and not by perl. + +
+
+An expression can comprise a single statement or two statements separated
+by the and
and or
operators. For example:
+
+
+
+ 'x < 2000' + 'x > 2000' + 'x == 2000' + 'x > 2000 and x < 5000' + 'x == 2000 or x == 5000' ++ +
+Filtering of blank or non-blank data can be achieved by using a value of Blanks
or NonBlanks
in the expression:
+
+
+
+ 'x == Blanks' + 'x == NonBlanks' ++ +
+Top 10 style filters can be specified using a expression like the +following: + +
++
+ Top|Bottom 1-500 Items|% ++ +
+For example: + +
++
+ 'Top 10 Items' + 'Bottom 5 Items' + 'Top 25 %' + 'Bottom 50 %' ++ +
+Excel also allows some simple string matching operations: + +
++
+ 'x =~ b*' # begins with b + 'x !~ b*' # doesn't begin with b + 'x =~ *b' # ends with b + 'x !~ *b' # doesn't end with b + 'x =~ *b*' # contains b + 'x !~ *b*' # doesn't contains b ++ +
+You can also use *
to match any character or number and ?
to match any single character or number. No other regular expression
+quantifier is supported by Excel's filters. Excel's regular expression
+characters can be escaped using ~
.
+
+
+The placeholder variable x
in the above examples can be replaced by any simple string. The actual
+placeholder name is ignored internally so the following are all equivalent:
+
+
+
+ 'x < 2000' + 'col < 2000' + 'Price < 2000' ++ +
+Also, note that a filter condition can only be applied to a column in a
+range specified by the autofilter()
Worksheet method.
+
+
+See the autofilter.pl
program in the examples directory of the distro for a more detailed
+example.
+
-On systems with perl 5.8
and later the set_header()
method can also handle Unicode strings in Perl's utf8
format.
+On systems with perl 5.8
and later the set_header()
method can also handle Unicode strings in UTF-8
format.
@@ -5102,7 +5268,7 @@
-The number system used for dates is described in DATES IN EXCEL. +The number system used for dates is described in DATES AND TIME IN EXCEL.
@@ -5587,21 +5753,83 @@
Default state: Border is off Default action: Set border type 1 - Valid args: 0 No border - 1 Thin single border - 2 Medium single border - 3 Dashed border - 4 Dotted border - 5 Thick single border - 6 Double line border - 7 Hair border + Valid args: 0-13, See below.
A cell border is comprised of a border on the bottom, top, left and right.
-These can be set to the same value using set_border()
or individually using the relevant method calls shown above. Examples of
-the available border styles are shown in the 'Borders' worksheet created by
-formats.pl.
+These can be set to the same value using set_border()
or individually using the relevant method calls shown above.
+
+
+The following shows the border styles sorted by Spreadsheet::WriteExcel +index number: + +
++
+ Index Name Weight Style + ===== ============= ====== =========== + 0 None 0 + 1 Continuous 1 ----------- + 2 Continuous 2 ----------- + 3 Dash 1 - - - - - - + 4 Dot 1 . . . . . . + 5 Continuous 3 ----------- + 6 Double 3 =========== + 7 Continuous 0 ----------- + 8 Dash 2 - - - - - - + 9 Dash Dot 1 - . - . - . + 10 Dash Dot 2 - . - . - . + 11 Dash Dot Dot 1 - . . - . . + 12 Dash Dot Dot 2 - . . - . . + 13 SlantDash Dot 2 / - . / - . ++ +
+The following shows the borders sorted by style: + +
++
+ Name Weight Style Index + ============= ====== =========== ===== + Continuous 0 ----------- 7 + Continuous 1 ----------- 1 + Continuous 2 ----------- 2 + Continuous 3 ----------- 5 + Dash 1 - - - - - - 3 + Dash 2 - - - - - - 8 + Dash Dot 1 - . - . - . 9 + Dash Dot 2 - . - . - . 10 + Dash Dot Dot 1 - . . - . . 11 + Dash Dot Dot 2 - . . - . . 12 + Dot 1 . . . . . . 4 + Double 3 =========== 6 + None 0 0 + SlantDash Dot 2 / - . / - . 13 ++ +
+The following shows the borders in the order shown in the Excel Dialog. + +
++
+ Index Style Index Style + ===== ===== ===== ===== + 0 None 12 - . . - . . + 7 ----------- 13 / - . / - . + 4 . . . . . . 10 - . - . - . + 11 - . . - . . 8 - - - - - - + 9 - . - . - . 2 ----------- + 3 - - - - - - 5 ----------- + 1 ----------- 6 =========== ++ +
+Examples of the available border styles are shown in the 'Borders' +worksheet created by formats.pl.
@@ -5663,6 +5891,105 @@
+
+For a more general introduction to Unicode handling in Perl see perlunitut and perluniintro. + +
+
+When using Spreadsheet::WriteExcel
the best and easiest way to write unicode strings to an Excel file is to
+use UTF-8
encoded strings and perl 5.8 (or later). The module also allows you to
+write unicode strings using older perls but it generally requires more
+work, as explained below.
+
+
+Internally, Excel encodes unicode data as UTF-16LE
(where LE means little-endian). If you are using perl 5.8+ then
+Spreadsheet::WriteExcel will convert UTF-8
strings to UTF-16LE
when required. No further intervention is required from the programmer, for
+example:
+
+
+
+ # perl 5.8+ example: + my $smiley = "\x{263A}"; ++ +
+
+ $worksheet->write('A1', 'Hello world'); + $worksheet->write('A2', $smiley); ++ +
+Spreadsheet::WriteExcel also lets you write unicode data as UTF-16
. Since the majority of CPAN modules default to UTF-16BE
(big-endian) Spreadsheet::WriteExcel also uses UTF-16BE
and converts it internally to UTF-16LE
:
+
+
+
+ # perl 5.005 example: + my $smiley = pack "n", 0x263A; ++ +
+
+ $worksheet->write ('A3', 'Hello world'); + $worksheet->write_utf16be_string('A4', $smiley); ++ +
+Although the above examples look similar there is an important difference.
+With uft8
and perl 5.8+ Spreadsheet::WriteExcel treats UTF-8
strings in exactly the same way as any other string. However, with UTF16
data we need to distinguish it from other strings either by calling a
+separate function or by passing an additional flag to indicate the data
+type.
+
+
+If you are dealing with non-ASCII character sets then your data probably
+won't be in UTF-8
to begin with. However, perl 5.8+ provides useful tools in the guise of the Encode
module to help you to convert to the required UTF-8
format. For example:
+
+
+
+ use Encode 'decode'; ++ +
+
+ my $string = 'some string with koi8-r characters'; + $string = decode('koi8-r', $string); # koi8-r to utf8 ++ +
+Alternatively you can read data from an encoded file and convert it to UTF-8
as you read it in:
+
+
+
+ my $file = 'unicode_koi8r.txt'; + open FH, '<:encoding(koi8-r)', $file or die "Couldn't open $file: $!\n"; ++ +
+
+ my $row = 0; + while (<FH>) { + # Data read in is now in utf8 format. + chomp; + $worksheet->write($row++, 0, $_); + } ++ +
+These methodologies are explained in more detail in perlunitut, perluniintro and perlunicode. + +
+
+See also the unicode_*.pl
programs in the examples directory of the distro.
+
Dates and times in Excel are represented by real numbers, for example "Jan 1 2001 12:30 AM" is represented by the number 36892.521. @@ -6743,7 +7070,8 @@
Advanced ======== - autofit.pl Simuluate Excel's autofit for colums widths. + autofilter.pl Examples of worksheet autofilters. + autofit.pl Simulate Excel's autofit for column widths. bigfile.pl Write past the 7MB limit with OLE::Storage_Lite. cgi.pl A simple CGI program. chess.pl An example of formatting using properties. @@ -6794,9 +7122,9 @@Additional Examples
Unicode ======= - unicode.pl Simple example of using Unicode UTF16 strings. - unicode_japan.pl Write Japanese Unicode strings using UTF16. - unicode_cyrillic.pl Write Russian cyrillic strings using UTF8. + unicode_utf16.pl Simple example of using Unicode UTF16 strings. + unicode_utf16_japan.pl Write Japanese Unicode strings using UTF-16. + unicode_cyrillic.pl Write Russian cyrillic strings using UTF-8. unicode_list.pl List the chars in a Unicode font. unicode_2022_jp.pl Japanese: ISO-2022-JP to utf8 in perl 5.8. unicode_8859_11.pl Thai: ISO-8859_11 to utf8 in perl 5.8. @@ -6994,8 +7322,7 @@DIAGNOSTICS
This error generally means that the Excel file has been corrupted. There are two likely causes of this: the file was FTPed in ASCII mode instead of -binary mode or else the file was created with UTF8 data returned by an XML -parser. See Warning about XML::Parser and Perl 5.6 for further details. +binary mode or else the file was created with
UTF-8
data returned by an XML parser. See Warning about XML::Parser and perl 5.6 for further details.
This module allows you to turn a simple XML file into an Excel file using -Spreadsheet::WriteExcel as a backend. The format of the XML file is defined -by a supplied DTD: http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromXML @@ -7286,25 +7613,24 @@
You must be careful when using Spreadsheet::WriteExcel in conjunction with
-Perl 5.6 and XML::Parser (and other XML parsers) due to the fact that the
-data returned by the parser is generally in UTF8 format.
+perl 5.6 and XML::Parser (and other XML parsers) due to the fact that the
+data returned by the parser is generally in UTF-8
format.
-When UTF8 strings are added to Spreadsheet::WriteExcel's internal data it
-causes the generated Excel file to become corrupt.
+When UTF-8
strings are added to Spreadsheet::WriteExcel's internal data it causes the
+generated Excel file to become corrupt.
-Note, this doesn't affect Perl 5.005 (which doesn't try to handle UTF8) or
-5.8 (which handles it correctly).
+Note, this doesn't affect perl 5.005 (which doesn't try to handle UTF-8
) or 5.8 (which handles it correctly).
-To avoid this problem you should upgrade to Perl 5.8, if possible, or else +To avoid this problem you should upgrade to perl 5.8, if possible, or else you should convert the output data from XML::Parser to ASCII or ISO-8859-1 using one of the following methods: @@ -7328,8 +7654,8 @@
-XML and UTF8 data on Perl 5.6 can cause Excel files created by
-Spreadsheet::WriteExcel to become corrupt. See Warning about XML::Parser and Perl 5.6 for further details.
+XML and UTF-8
data on perl 5.6 can cause Excel files created by Spreadsheet::WriteExcel
+to become corrupt. See Warning about XML::Parser and perl 5.6 for further details.
@@ -7352,20 +7678,11 @@
-OpenOffice.org: Images are not displayed. Some formatting is not displayed -correctly. - -
--Gnumeric: Images are not displayed. Some formatting is not displayed -correctly. URLs are not displayed as links. Page setup may cause Gnumeric -to crash. +OpenOffice.org: No known issues in this release.
-The lack of a portable way of writing a little-endian 64 bit IEEE float. -There is beta code available to fix this. Let me know if you wish to test -it on your platform. +Gnumeric: No known issues in this release.
@@ -7380,8 +7697,7 @@
Also, here are some of the most requested features that probably won't get @@ -7450,7 +7766,7 @@
If you'd care to donate to the Spreadsheet::WriteExcel project, you can do so via PayPal: @@ -7503,7 +7819,7 @@
-"Reading and writing Excel files with Perl" by Teodor Zlatanov, atIBM +"Reading and writing Excel files with Perl" by Teodor Zlatanov, at IBM developerWorks: http://www-106.ibm.com/developerworks/library/l-pexcel/ @@ -7530,7 +7846,7 @@
The following people contributed to the debugging and testing of Spreadsheet::WriteExcel: @@ -7566,6 +7882,11 @@
+Many thanks to Cassens Transport who sponsored the development of the +embedded charts and autofilters. +
Additional thanks to Takanori Kawai for translating the documentation into @@ -7617,31 +7938,37 @@
-John McNamara jmcnamara@cpan.org +Either the Perl Artistic Licence http://dev.perl.org/licenses/artistic.html +or the GPL http://www.opensource.org/licenses/gpl-license.php +
-
- I was nineteen when I came to town, they called it the Summer of Love - They were burning babies, burning flags. The hawks against the doves - I took a job in the steamie down on Cauldrum Street - And I fell in love with a laundry girl who was working next to me -+
+John McNamara jmcnamara@cpan.org +
- Oh she was a rare thing, fine as a bee's wing - So fine a breath of wind might blow her away - She was a lost child, oh she was running wild - She said "As long as there's no price on love, I'll stay. - And you wouldn't want me any other way" + This, no song of an ingenue, + This, no ballad of innocence; + This, the rhyme of a lady who + Followed ever her natural bents. + This, a solo of sapience, + This, a chantey of sophistry, + This, the sum of experiments, + I loved them until they loved me.
- -- Richard Thompson + -- Dorothy Parker
diff --git a/examples/README b/examples/README
index 9aa50d0..ee41600 100644
--- a/examples/README
+++ b/examples/README
@@ -14,7 +14,8 @@ stats.pl Basic formulas and functions.
Advanced
========
-autofit.pl Simuluate Excel's autofit for colums widths.
+autofilter.pl Examples of worksheet autofilters.
+autofit.pl Simulate Excel's autofit for column widths.
bigfile.pl Write past the 7MB limit with OLE::Storage_Lite.
cgi.pl A simple CGI program.
chess.pl An example of formatting using properties.
@@ -63,9 +64,9 @@ write_to_scalar.pl Example of writing an Excel file to a Perl scalar.
Unicode
=======
-unicode.pl Simple example of using Unicode UTF16 strings.
-unicode_japan.pl Write Japanese Unicode strings using UTF16.
-unicode_cyrillic.pl Write Russian cyrillic strings using UTF8.
+unicode_utf16.pl Simple example of using Unicode UTF16 strings.
+unicode_utf16_japan.pl Write Japanese Unicode strings using UTF-16.
+unicode_cyrillic.pl Write Russian cyrillic strings using UTF-8.
unicode_list.pl List the chars in a Unicode font.
unicode_2022_jp.pl Japanese: ISO-2022-JP to utf8 in perl 5.8.
unicode_8859_11.pl Thai: ISO-8859_11 to utf8 in perl 5.8.
@@ -91,4 +92,4 @@ Developer
=========
convertA1.pl Helper functions for dealing with A1 notation.
function_locale.pl Add non-English function names to Formula.pm.
-writeA1.pl Example of how to extend the module.
+writeA1.pl Example of how to extend the module.
\ No newline at end of file
diff --git a/examples/autofilter.pl b/examples/autofilter.pl
new file mode 100644
index 0000000..5917df8
--- /dev/null
+++ b/examples/autofilter.pl
@@ -0,0 +1,266 @@
+#!/usr/bin/perl -w
+
+#######################################################################
+#
+# Example of how to create autofilters with Spreadsheet::WriteExcel.
+#
+# reverse('©'), September 2007, John McNamara, jmcnamara@cpan.org
+#
+
+use strict;
+use Spreadsheet::WriteExcel;
+
+my $workbook = Spreadsheet::WriteExcel->new('autofilter.xls');
+
+die "Couldn't create new Excel file: $!.\n" unless defined $workbook;
+
+my $worksheet1 = $workbook->add_worksheet();
+my $worksheet2 = $workbook->add_worksheet();
+my $worksheet3 = $workbook->add_worksheet();
+my $worksheet4 = $workbook->add_worksheet();
+my $worksheet5 = $workbook->add_worksheet();
+my $worksheet6 = $workbook->add_worksheet();
+
+my $bold = $workbook->add_format(bold => 1);
+
+
+# Extract the data embedded at the end of this file.
+my @headings = split ' ', ;
+my @data;
+push @data, [split] while ;
+
+
+# Set up several sheets with the same data.
+for my $worksheet ($workbook->sheets()) {
+ $worksheet->set_column('A:D', 12);
+ $worksheet->set_row(0, 20, $bold);
+ $worksheet->write('A1', \@headings);
+}
+
+
+###############################################################################
+#
+# Example 1. Autofilter without conditions.
+#
+
+$worksheet1->autofilter('A1:D51');
+$worksheet1->write('A2', [[@data]]);
+
+
+###############################################################################
+#
+#
+# Example 2. Autofilter with a filter condition in the first column.
+#
+
+# The range in this example is the same as above but in row-column notation.
+$worksheet2->autofilter(0, 0, 50, 3);
+
+# The placeholder "Region" in the filter is ignored and can be any string
+# that adds clarity to the expression.
+#
+$worksheet2->filter_column(0, 'Region eq East');
+
+#
+# Hide the rows that don't match the filter criteria.
+#
+my $row = 1;
+
+for my $row_data (@data) {
+ my $region = $row_data->[0];
+
+ if ($region eq 'East') {
+ # Row is visible.
+ }
+ else {
+ # Hide row.
+ $worksheet2->set_row($row, undef, undef, 1);
+ }
+
+ $worksheet2->write($row++, 0, $row_data);
+}
+
+
+###############################################################################
+#
+#
+# Example 3. Autofilter with a dual filter condition in one of the columns.
+#
+
+$worksheet3->autofilter('A1:D51');
+
+$worksheet3->filter_column('A', 'x eq East or x eq South');
+
+#
+# Hide the rows that don't match the filter criteria.
+#
+$row = 1;
+
+for my $row_data (@data) {
+ my $region = $row_data->[0];
+
+ if ($region eq 'East' or $region eq 'South') {
+ # Row is visible.
+ }
+ else {
+ # Hide row.
+ $worksheet3->set_row($row, undef, undef, 1);
+ }
+
+ $worksheet3->write($row++, 0, $row_data);
+}
+
+
+###############################################################################
+#
+#
+# Example 4. Autofilter with filter conditions in two columns.
+#
+
+$worksheet4->autofilter('A1:D51');
+
+$worksheet4->filter_column('A', 'x eq East');
+$worksheet4->filter_column('C', 'x > 3000 and x < 8000' );
+
+#
+# Hide the rows that don't match the filter criteria.
+#
+$row = 1;
+
+for my $row_data (@data) {
+ my $region = $row_data->[0];
+ my $volume = $row_data->[2];
+
+ if ($region eq 'East' and
+ $volume > 3000 and $volume < 8000
+ )
+ {
+ # Row is visible.
+ }
+ else {
+ # Hide row.
+ $worksheet4->set_row($row, undef, undef, 1);
+ }
+
+ $worksheet4->write($row++, 0, $row_data);
+}
+
+
+###############################################################################
+#
+#
+# Example 5. Autofilter with filter for blanks.
+#
+
+# Create a blank cell in our test data.
+$data[5]->[0] = '';
+
+
+$worksheet5->autofilter('A1:D51');
+$worksheet5->filter_column('A', 'x == Blanks');
+
+#
+# Hide the rows that don't match the filter criteria.
+#
+$row = 1;
+
+for my $row_data (@data) {
+ my $region = $row_data->[0];
+
+ if ($region eq '')
+ {
+ # Row is visible.
+ }
+ else {
+ # Hide row.
+ $worksheet5->set_row($row, undef, undef, 1);
+ }
+
+ $worksheet5->write($row++, 0, $row_data);
+}
+
+
+###############################################################################
+#
+#
+# Example 6. Autofilter with filter for non-blanks.
+#
+
+
+$worksheet6->autofilter('A1:D51');
+$worksheet6->filter_column('A', 'x == NonBlanks');
+
+#
+# Hide the rows that don't match the filter criteria.
+#
+$row = 1;
+
+for my $row_data (@data) {
+ my $region = $row_data->[0];
+
+ if ($region ne '')
+ {
+ # Row is visible.
+ }
+ else {
+ # Hide row.
+ $worksheet6->set_row($row, undef, undef, 1);
+ }
+
+ $worksheet6->write($row++, 0, $row_data);
+}
+
+
+
+__DATA__
+Region Item Volume Month
+East Apple 9000 July
+East Apple 5000 July
+South Orange 9000 September
+North Apple 2000 November
+West Apple 9000 November
+South Pear 7000 October
+North Pear 9000 August
+West Orange 1000 December
+West Grape 1000 November
+South Pear 10000 April
+West Grape 6000 January
+South Orange 3000 May
+North Apple 3000 December
+South Apple 7000 February
+West Grape 1000 December
+East Grape 8000 February
+South Grape 10000 June
+West Pear 7000 December
+South Apple 2000 October
+East Grape 7000 December
+North Grape 6000 April
+East Pear 8000 February
+North Apple 7000 August
+North Orange 7000 July
+North Apple 6000 June
+South Grape 8000 September
+West Apple 3000 October
+South Orange 10000 November
+West Grape 4000 July
+North Orange 5000 August
+East Orange 1000 November
+East Orange 4000 October
+North Grape 5000 August
+East Apple 1000 December
+South Apple 10000 March
+East Grape 7000 October
+West Grape 1000 September
+East Grape 10000 October
+South Orange 8000 March
+North Apple 4000 July
+South Orange 5000 July
+West Apple 4000 June
+East Apple 5000 April
+North Pear 3000 August
+East Grape 9000 November
+North Orange 8000 October
+East Apple 10000 June
+South Pear 1000 December
+North Grape 10000 July
+East Grape 6000 February
diff --git a/examples/bug_report.pl b/examples/bug_report.pl
index df3138d..370eaee 100644
--- a/examples/bug_report.pl
+++ b/examples/bug_report.pl
@@ -105,10 +105,13 @@
my @modules = qw(
Spreadsheet::WriteExcel
+ Spreadsheet::ParseExcel
+ OLE::Storage_Lite
Parse::RecDescent
File::Temp
- OLE::Storage_Lite
- IO::Stringy
+ Digest::MD4
+ Digest::Perl::MD4
+ Digest::MD5
);
diff --git a/examples/demo.pl b/examples/demo.pl
index fecfd5e..1edf1f5 100644
--- a/examples/demo.pl
+++ b/examples/demo.pl
@@ -62,7 +62,7 @@
$worksheet->write('A3', "Formatted text");
$worksheet->write('B3', "Hello Excel", $text_format);
$worksheet->write('A4', "Unicode text");
-$worksheet->write_unicode('B4', $unicode);
+$worksheet->write_utf16be_string('B4', $unicode);
#######################################################################
#
@@ -102,7 +102,7 @@
# Images
#
$worksheet->write('A10', "Images");
-$worksheet->insert_bitmap('B10', 'republic.bmp', 16, 8);
+$worksheet->insert_image('B10', 'republic.png', 16, 8);
#######################################################################
diff --git a/examples/formats.pl b/examples/formats.pl
index dd12387..bba616c 100644
--- a/examples/formats.pl
+++ b/examples/formats.pl
@@ -295,7 +295,7 @@ sub borders {
$worksheet->write(0, 5, "The style is highlighted in red for ", $heading);
$worksheet->write(1, 5, "emphasis, the default color is black.", $heading);
- for my $i (0..7){
+ for my $i (0..13){
my $format = $workbook->add_format();
$format->set_border($i);
$format->set_border_color('red');
@@ -307,9 +307,10 @@ sub borders {
$worksheet->write((2*($i+1)), 3, "Border", $format);
}
- $worksheet->write(18, 0, "Diag type", $heading);
- $worksheet->write(18, 1, "Index", $heading);
- $worksheet->write(18, 3, "Style", $heading);
+ $worksheet->write(30, 0, "Diag type", $heading);
+ $worksheet->write(30, 1, "Index", $heading);
+ $worksheet->write(30, 3, "Style", $heading);
+ $worksheet->write(30, 5, "Diagonal Boder styles", $heading);
for my $i (1..3){
my $format = $workbook->add_format();
@@ -318,10 +319,10 @@ sub borders {
$format->set_diag_color('red');
$format->set_align('center');
- $worksheet->write((2*($i+9)), 0, $i, $center);
- $worksheet->write((2*($i+9)), 1, sprintf("0x%02X", 1), $center);
+ $worksheet->write((2*($i+15)), 0, $i, $center);
+ $worksheet->write((2*($i+15)), 1, sprintf("0x%02X", $i), $center);
- $worksheet->write((2*($i+9)), 3, "Border", $format);
+ $worksheet->write((2*($i+15)), 3, "Border", $format);
}
}
diff --git a/examples/hide_sheet.pl b/examples/hide_sheet.pl
index b821b1b..5a1dd63 100644
--- a/examples/hide_sheet.pl
+++ b/examples/hide_sheet.pl
@@ -18,9 +18,9 @@
# Sheet2 won't be visible until it is unhidden in Excel.
$worksheet2->hide();
-$worksheet1->write(0, 0, "Hello");
-$worksheet2->write(0, 0, "Hello");
-$worksheet3->write(0, 0, "Hello");
+$worksheet1->write(0, 0, 'Sheet2 is hidden');
+$worksheet2->write(0, 0, 'How did you find me?');
+$worksheet3->write(0, 0, 'Sheet2 is hidden');
__END__
diff --git a/examples/images.pl b/examples/images.pl
index a05cbd4..be5e91a 100644
--- a/examples/images.pl
+++ b/examples/images.pl
@@ -3,7 +3,7 @@
#######################################################################
#
# Example of how to insert images into an Excel worksheet using the
-# Spreadsheet::WriteExcel insert_bitmap() method.
+# Spreadsheet::WriteExcel insert_image() method.
#
# reverse('©'), October 2001, John McNamara, jmcnamara@cpan.org
#
@@ -20,22 +20,22 @@
# Insert a basic image
$worksheet1->write('A10', "Image inserted into worksheet.");
-$worksheet1->insert_bitmap('A1', 'republic.bmp');
+$worksheet1->insert_image('A1', 'republic.png');
# Insert an image with an offset
$worksheet2->write('A10', "Image inserted with an offset.");
-$worksheet2->insert_bitmap('A1', 'republic.bmp', 32, 10);
+$worksheet2->insert_image('A1', 'republic.png', 32, 10);
# Insert a scaled image
$worksheet3->write('A10', "Image scaled: width x 2, height x 0.8.");
-$worksheet3->insert_bitmap('A1', 'republic.bmp', 0, 0, 2, 0.8);
+$worksheet3->insert_image('A1', 'republic.png', 0, 0, 2, 0.8);
# Insert an image over varied column and row sizes
# This does not require any additional work
# Set the cols and row sizes
-# NOTE: you must do this before you call insert_bitmap()
+# NOTE: you must do this before you call insert_image()
$worksheet4->set_column('A:A', 5);
$worksheet4->set_column('B:B', undef, undef, 1); # Hidden
$worksheet4->set_column('C:D', 10);
@@ -43,7 +43,7 @@
$worksheet4->set_row(3, 5);
$worksheet4->write('A10', "Image inserted over scaled rows and columns.");
-$worksheet4->insert_bitmap('A1', 'republic.bmp');
+$worksheet4->insert_image('A1', 'republic.png');
diff --git a/examples/panes.pl b/examples/panes.pl
index a444368..5e9548e 100644
--- a/examples/panes.pl
+++ b/examples/panes.pl
@@ -17,18 +17,17 @@
my $worksheet3 = $workbook->add_worksheet('Panes 3');
my $worksheet4 = $workbook->add_worksheet('Panes 4');
-# Frozen panes
+# Freeze panes
$worksheet1->freeze_panes(1, 0); # 1 row
+
$worksheet2->freeze_panes(0, 1); # 1 column
$worksheet3->freeze_panes(1, 1); # 1 row and column
-# Un-frozen panes. The divisions must be specified in terms of row and column
-# dimensions. The default row height is 12.75 and the default column width
-# is 8.43
+# Split panes.
+# The divisions must be specified in terms of row and column dimensions.
+# The default row height is 12.75 and the default column width is 8.43
#
-$worksheet4->thaw_panes(12.75, 8.43, 1, 1); # 1 row and column
-
-
+$worksheet4->split_panes(12.75, 8.43, 1, 1); # 1 row and column
#######################################################################
diff --git a/examples/republic.bmp b/examples/republic.bmp
deleted file mode 100644
index 7b761af..0000000
Binary files a/examples/republic.bmp and /dev/null differ
diff --git a/examples/republic.png b/examples/republic.png
new file mode 100644
index 0000000..68c036a
Binary files /dev/null and b/examples/republic.png differ
diff --git a/examples/unicode_2022_jp.pl b/examples/unicode_2022_jp.pl
index f40fb19..60951ae 100644
--- a/examples/unicode_2022_jp.pl
+++ b/examples/unicode_2022_jp.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_8859_11.pl b/examples/unicode_8859_11.pl
index 2e2183e..7ccd6b2 100644
--- a/examples/unicode_8859_11.pl
+++ b/examples/unicode_8859_11.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_8859_7.pl b/examples/unicode_8859_7.pl
index 9c849b8..c126e15 100644
--- a/examples/unicode_8859_7.pl
+++ b/examples/unicode_8859_7.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_big5.pl b/examples/unicode_big5.pl
index e00d2fa..4a680aa 100644
--- a/examples/unicode_big5.pl
+++ b/examples/unicode_big5.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_cp1251.pl b/examples/unicode_cp1251.pl
index 86ea063..94ae8f0 100644
--- a/examples/unicode_cp1251.pl
+++ b/examples/unicode_cp1251.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_cp1256.pl b/examples/unicode_cp1256.pl
index b04f385..543c36d 100644
--- a/examples/unicode_cp1256.pl
+++ b/examples/unicode_cp1256.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_cyrillic.pl b/examples/unicode_cyrillic.pl
index eef131e..59124db 100644
--- a/examples/unicode_cyrillic.pl
+++ b/examples/unicode_cyrillic.pl
@@ -11,8 +11,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_koi8r.pl b/examples/unicode_koi8r.pl
index ec450f2..c071fdf 100644
--- a/examples/unicode_koi8r.pl
+++ b/examples/unicode_koi8r.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_list.pl b/examples/unicode_list.pl
index 89f7a04..656e1a3 100644
--- a/examples/unicode_list.pl
+++ b/examples/unicode_list.pl
@@ -37,7 +37,7 @@
sprintf('0x%04X', $char), $courier);
}
else {
- $worksheet->write_unicode($row, $col,
+ $worksheet->write_utf16be_string($row, $col,
pack('n', $char++), $uni_font);
}
}
diff --git a/examples/unicode_polish_utf8.pl b/examples/unicode_polish_utf8.pl
index f55c26d..1eeb2e5 100644
--- a/examples/unicode_polish_utf8.pl
+++ b/examples/unicode_polish_utf8.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode_shift_jis.pl b/examples/unicode_shift_jis.pl
index 60049b4..5a8aed2 100644
--- a/examples/unicode_shift_jis.pl
+++ b/examples/unicode_shift_jis.pl
@@ -14,8 +14,8 @@
# Perl 5.8 or later is required for proper utf8 handling. For older perl
-# versions you should use UTF16 and the write_unicode() method.
-# See the write_unicode section of the Spreadsheet::WriteExcel docs.
+# versions you should use UTF16 and the write_utf16be_string() method.
+# See the write_utf16be_string section of the Spreadsheet::WriteExcel docs.
#
require 5.008;
diff --git a/examples/unicode.pl b/examples/unicode_utf16.pl
similarity index 76%
rename from examples/unicode.pl
rename to examples/unicode_utf16.pl
index 4fd19f8..8da3634 100644
--- a/examples/unicode.pl
+++ b/examples/unicode_utf16.pl
@@ -15,7 +15,7 @@
use Spreadsheet::WriteExcel;
-my $workbook = Spreadsheet::WriteExcel->new('unicode.xls');
+my $workbook = Spreadsheet::WriteExcel->new('unicode_utf16.xls');
my $worksheet = $workbook->add_worksheet();
@@ -23,17 +23,17 @@
my $smiley = pack "n", 0x263a;
my $big_font = $workbook->add_format(size => 40);
-$worksheet->write_unicode('A3', $smiley, $big_font);
+$worksheet->write_utf16be_string('A3', $smiley, $big_font);
# Write a phrase in Cyrillic
my $uni_str = pack "H*", "042d0442043e002004440440043004370430002004".
"3d043000200440044304410441043a043e043c0021";
-$worksheet->write_unicode('A5', $uni_str);
+$worksheet->write_utf16be_string('A5', $uni_str);
-$worksheet->write_unicode('A7', pack "H*", "0074006500730074");
+$worksheet->write_utf16be_string('A7', pack "H*", "0074006500730074");
diff --git a/examples/unicode_japan.pl b/examples/unicode_utf16_japan.pl
similarity index 79%
rename from examples/unicode_japan.pl
rename to examples/unicode_utf16_japan.pl
index 8004190..860bc24 100644
--- a/examples/unicode_japan.pl
+++ b/examples/unicode_utf16_japan.pl
@@ -19,7 +19,7 @@
use Spreadsheet::WriteExcel;
-my $workbook = Spreadsheet::WriteExcel->new('japan.xls');
+my $workbook = Spreadsheet::WriteExcel->new('unicode_utf16_japan.xls');
my $worksheet = $workbook->add_worksheet();
@@ -34,9 +34,9 @@
-$worksheet->write_unicode('A1', $kanji, $uni_font);
-$worksheet->write_unicode('A2', $katakana, $uni_font);
-$worksheet->write_unicode('A3', $hiragana, $uni_font);
+$worksheet->write_utf16be_string('A1', $kanji, $uni_font);
+$worksheet->write_utf16be_string('A2', $katakana, $uni_font);
+$worksheet->write_utf16be_string('A3', $hiragana, $uni_font);
$worksheet->write('B1', 'Kanji');
diff --git a/lib/Spreadsheet/WriteExcel.pm b/lib/Spreadsheet/WriteExcel.pm
index aa7a052..5ac4171 100644
--- a/lib/Spreadsheet/WriteExcel.pm
+++ b/lib/Spreadsheet/WriteExcel.pm
@@ -6,7 +6,7 @@ package Spreadsheet::WriteExcel;
#
# Spreadsheet::WriteExcel - Write to a cross-platform Excel binary file.
#
-# Copyright 2000-2006, John McNamara, jmcnamara@cpan.org
+# Copyright 2000-2007, John McNamara, jmcnamara@cpan.org
#
# Documentation after __END__
#
@@ -21,7 +21,7 @@ use Spreadsheet::WriteExcel::Workbook;
use vars qw($VERSION @ISA);
@ISA = qw(Spreadsheet::WriteExcel::Workbook Exporter);
-$VERSION = '2.18'; # Action Packed, 18th January 2007.
+$VERSION = '2.20'; # La Bruni.
@@ -63,7 +63,7 @@ Spreadsheet::WriteExcel - Write to a cross-platform Excel binary file.
=head1 VERSION
-This document refers to version 2.18 of Spreadsheet::WriteExcel, released January 18, 2007.
+This document refers to version 2.20 of Spreadsheet::WriteExcel, released October 6, 2007.
@@ -129,7 +129,7 @@ Like this:
$worksheet = $workbook->add_worksheet(); # Step 2
$worksheet->write('A1', "Hi Excel!"); # Step 3
-This will create an Excel file called C