1Spreadsheet::WriteExcelU(s3e)r Contributed Perl DocumentaStpiroenadsheet::WriteExcel(3)
2
3
4

NAME

6       Spreadsheet::WriteExcel - Write to a cross-platform Excel binary file.
7

VERSION

9       This document refers to version 2.36 of Spreadsheet::WriteExcel,
10       released January 21, 2010.
11

SYNOPSIS

13       To write a string, a formatted string, a number and a formula to the
14       first worksheet in an Excel workbook called perl.xls:
15
16           use Spreadsheet::WriteExcel;
17
18           # Create a new Excel workbook
19           my $workbook = Spreadsheet::WriteExcel->new('perl.xls');
20
21           # Add a worksheet
22           $worksheet = $workbook->add_worksheet();
23
24           #  Add and define a format
25           $format = $workbook->add_format(); # Add a format
26           $format->set_bold();
27           $format->set_color('red');
28           $format->set_align('center');
29
30           # Write a formatted and unformatted string, row and column notation.
31           $col = $row = 0;
32           $worksheet->write($row, $col, 'Hi Excel!', $format);
33           $worksheet->write(1,    $col, 'Hi Excel!');
34
35           # Write a number and a formula using A1 notation
36           $worksheet->write('A3', 1.2345);
37           $worksheet->write('A4', '=SIN(PI()/4)');
38

DESCRIPTION

40       The Spreadsheet::WriteExcel Perl module can be used to create a cross-
41       platform Excel binary file. Multiple worksheets can be added to a
42       workbook and formatting can be applied to cells. Text, numbers,
43       formulas, hyperlinks, images and charts can be written to the cells.
44
45       The file produced by this module is compatible with Excel 97, 2000,
46       2002, 2003 and 2007.
47
48       The module will work on the majority of Windows, UNIX and Mac
49       platforms. Generated files are also compatible with the Linux/UNIX
50       spreadsheet applications Gnumeric and OpenOffice.org.
51
52       This module cannot be used to write to an existing Excel file (See
53       "MODIFYING AND REWRITING EXCEL FILES").
54

QUICK START

56       Spreadsheet::WriteExcel tries to provide an interface to as many of
57       Excel's features as possible. As a result there is a lot of
58       documentation to accompany the interface and it can be difficult at
59       first glance to see what it important and what is not. So for those of
60       you who prefer to assemble Ikea furniture first and then read the
61       instructions, here are three easy steps:
62
63       1. Create a new Excel workbook (i.e. file) using "new()".
64
65       2. Add a worksheet to the new workbook using "add_worksheet()".
66
67       3. Write to the worksheet using "write()".
68
69       Like this:
70
71           use Spreadsheet::WriteExcel;                             # Step 0
72
73           my $workbook = Spreadsheet::WriteExcel->new('perl.xls'); # Step 1
74           $worksheet   = $workbook->add_worksheet();               # Step 2
75           $worksheet->write('A1', 'Hi Excel!');                    # Step 3
76
77       This will create an Excel file called "perl.xls" with a single
78       worksheet and the text 'Hi Excel!' in the relevant cell. And that's it.
79       Okay, so there is actually a zeroth step as well, but "use module" goes
80       without saying. There are also more than 80 examples that come with the
81       distribution and which you can use to get you started. See EXAMPLES.
82
83       Those of you who read the instructions first and assemble the furniture
84       afterwards will know how to proceed. ;-)
85

WORKBOOK METHODS

87       The Spreadsheet::WriteExcel module provides an object oriented
88       interface to a new Excel workbook. The following methods are available
89       through a new workbook.
90
91           new()
92           add_worksheet()
93           add_format()
94           add_chart()
95           add_chart_ext()
96           close()
97           compatibility_mode()
98           set_properties()
99           define_name()
100           set_tempdir()
101           set_custom_color()
102           sheets()
103           set_1904()
104           set_codepage()
105
106       If you are unfamiliar with object oriented interfaces or the way that
107       they are implemented in Perl have a look at "perlobj" and "perltoot" in
108       the main Perl documentation.
109
110   new()
111       A new Excel workbook is created using the "new()" constructor which
112       accepts either a filename or a filehandle as a parameter. The following
113       example creates a new Excel file based on a filename:
114
115           my $workbook  = Spreadsheet::WriteExcel->new('filename.xls');
116           my $worksheet = $workbook->add_worksheet();
117           $worksheet->write(0, 0, 'Hi Excel!');
118
119       Here are some other examples of using "new()" with filenames:
120
121           my $workbook1 = Spreadsheet::WriteExcel->new($filename);
122           my $workbook2 = Spreadsheet::WriteExcel->new('/tmp/filename.xls');
123           my $workbook3 = Spreadsheet::WriteExcel->new("c:\\tmp\\filename.xls");
124           my $workbook4 = Spreadsheet::WriteExcel->new('c:\tmp\filename.xls');
125
126       The last two examples demonstrates how to create a file on DOS or
127       Windows where it is necessary to either escape the directory separator
128       "\" or to use single quotes to ensure that it isn't interpolated. For
129       more information  see "perlfaq5: Why can't I use "C:\temp\foo" in DOS
130       paths?".
131
132       The "new()" constructor returns a Spreadsheet::WriteExcel object that
133       you can use to add worksheets and store data. It should be noted that
134       although "my" is not specifically required it defines the scope of the
135       new workbook variable and, in the majority of cases, ensures that the
136       workbook is closed properly without explicitly calling the "close()"
137       method.
138
139       If the file cannot be created, due to file permissions or some other
140       reason,  "new" will return "undef". Therefore, it is good practice to
141       check the return value of "new" before proceeding. As usual the Perl
142       variable $! will be set if there is a file creation error. You will
143       also see one of the warning messages detailed in DIAGNOSTICS:
144
145           my $workbook  = Spreadsheet::WriteExcel->new('protected.xls');
146           die "Problems creating new Excel file: $!" unless defined $workbook;
147
148       You can also pass a valid filehandle to the "new()" constructor. For
149       example in a CGI program you could do something like this:
150
151           binmode(STDOUT);
152           my $workbook  = Spreadsheet::WriteExcel->new(\*STDOUT);
153
154       The requirement for "binmode()" is explained below.
155
156       For CGI programs you can also use the special Perl filename '-' which
157       will redirect the output to STDOUT:
158
159           my $workbook  = Spreadsheet::WriteExcel->new('-');
160
161       See also, the "cgi.pl" program in the "examples" directory of the
162       distro.
163
164       However, this special case will not work in "mod_perl" programs where
165       you will have to do something like the following:
166
167           # mod_perl 1
168           ...
169           tie *XLS, 'Apache';
170           binmode(XLS);
171           my $workbook  = Spreadsheet::WriteExcel->new(\*XLS);
172           ...
173
174           # mod_perl 2
175           ...
176           tie *XLS => $r;  # Tie to the Apache::RequestRec object
177           binmode(*XLS);
178           my $workbook  = Spreadsheet::WriteExcel->new(\*XLS);
179           ...
180
181       See also, the "mod_perl1.pl" and "mod_perl2.pl" programs in the
182       "examples" directory of the distro.
183
184       Filehandles can also be useful if you want to stream an Excel file over
185       a socket or if you want to store an Excel file in a scalar.
186
187       For example here is a way to write an Excel file to a scalar with "perl
188       5.8":
189
190           #!/usr/bin/perl -w
191
192           use strict;
193           use Spreadsheet::WriteExcel;
194
195           # Requires perl 5.8 or later
196           open my $fh, '>', \my $str or die "Failed to open filehandle: $!";
197
198           my $workbook  = Spreadsheet::WriteExcel->new($fh);
199           my $worksheet = $workbook->add_worksheet();
200
201           $worksheet->write(0, 0,  'Hi Excel!');
202
203           $workbook->close();
204
205           # The Excel file in now in $str. Remember to binmode() the output
206           # filehandle before printing it.
207           binmode STDOUT;
208           print $str;
209
210       See also the "write_to_scalar.pl" and "filehandle.pl" programs in the
211       "examples" directory of the distro.
212
213       Note about the requirement for "binmode()". An Excel file is comprised
214       of binary data. Therefore, if you are using a filehandle you should
215       ensure that you "binmode()" it prior to passing it to "new()".You
216       should do this regardless of whether you are on a Windows platform or
217       not. This applies especially to users of perl 5.8 on systems where
218       "UTF-8" is likely to be in operation such as RedHat Linux 9. If your
219       program, either intentionally or not, writes "UTF-8" data to a
220       filehandle that is passed to "new()" it will corrupt the Excel file
221       that is created.
222
223       You don't have to worry about "binmode()" if you are using filenames
224       instead of filehandles. Spreadsheet::WriteExcel performs the
225       "binmode()" internally when it converts the filename to a filehandle.
226       For more information about "binmode()" see "perlfunc" and "perlopentut"
227       in the main Perl documentation.
228
229   add_worksheet($sheetname, $utf_16_be)
230       At least one worksheet should be added to a new workbook. A worksheet
231       is used to write data into cells:
232
233           $worksheet1 = $workbook->add_worksheet();           # Sheet1
234           $worksheet2 = $workbook->add_worksheet('Foglio2');  # Foglio2
235           $worksheet3 = $workbook->add_worksheet('Data');     # Data
236           $worksheet4 = $workbook->add_worksheet();           # Sheet4
237
238       If $sheetname is not specified the default Excel convention will be
239       followed, i.e. Sheet1, Sheet2, etc. The $utf_16_be parameter is
240       optional, see below.
241
242       The worksheet name must be a valid Excel worksheet name, i.e. it cannot
243       contain any of the following characters, "[ ] : * ? / \" and it must be
244       less than 32 characters. In addition, you cannot use the same, case
245       insensitive, $sheetname for more than one worksheet.
246
247       On systems with "perl 5.8" and later the "add_worksheet()" method will
248       also handle strings in "UTF-8" format.
249
250           $worksheet = $workbook->add_worksheet("\x{263a}"); # Smiley
251
252       On earlier Perl systems your can specify "UTF-16BE" worksheet names
253       using an additional optional parameter:
254
255           my $name = pack 'n', 0x263a;
256           $worksheet = $workbook->add_worksheet($name, 1);   # Smiley
257
258   add_format(%properties)
259       The "add_format()" method can be used to create new Format objects
260       which are used to apply formatting to a cell. You can either define the
261       properties at creation time via a hash of property values or later via
262       method calls.
263
264           $format1 = $workbook->add_format(%props); # Set properties at creation
265           $format2 = $workbook->add_format();       # Set properties later
266
267       See the "CELL FORMATTING" section for more details about Format
268       properties and how to set them.
269
270   add_chart(%properties)
271       This method is use to create a new chart either as a standalone
272       worksheet (the default) or as an embeddable object that can be inserted
273       into a worksheet via the "insert_chart()" Worksheet method.
274
275           my $chart = $workbook->add_chart( type => 'column' );
276
277       The properties that can be set are:
278
279           type     (required)
280           name     (optional)
281           embedded (optional)
282
283       ·   "type"
284
285           This is a required parameter. It defines the type of chart that
286           will be created.
287
288               my $chart = $workbook->add_chart( type => 'line' );
289
290           The available types are:
291
292               area
293               bar
294               column
295               line
296               pie
297               scatter
298               stock
299
300       ·   "name"
301
302           Set the name for the chart sheet. The name property is optional and
303           if it isn't supplied will default to "Chart1 .. n". The name must
304           be a valid Excel worksheet name. See "add_worksheet()" for more
305           details on valid sheet names. The "name" property can be omitted
306           for embedded charts.
307
308               my $chart = $workbook->add_chart( type => 'line', name => 'Results Chart' );
309
310       ·   "embedded"
311
312           Specifies that the Chart object will be inserted in a worksheet via
313           the "insert_chart()" Worksheet method. It is an error to try insert
314           a Chart that doesn't have this flag set.
315
316               my $chart = $workbook->add_chart( type => 'line', embedded => 1 );
317
318               # Configure the chart.
319               ...
320
321               # Insert the chart into the a worksheet.
322               $worksheet->insert_chart( 'E2', $chart );
323
324       See Spreadsheet::WriteExcel::Chart for details on how to configure the
325       chart object once it is created. See also the "chart_*.pl" programs in
326       the examples directory of the distro.
327
328   add_chart_ext($chart_data, $chartname)
329       This method is use to include externally generated charts in a
330       Spreadsheet::WriteExcel file.
331
332           my $chart = $workbook->add_chart_ext('chart01.bin', 'Chart1');
333
334       This feature is semi-deprecated in favour of the "native" charts
335       created using "add_chart()". Read "external_charts.txt" (or ".pod") in
336       the external_charts directory of the distro for a full explanation.
337
338   close()
339       In general your Excel file will be closed automatically when your
340       program ends or when the Workbook object goes out of scope, however the
341       "close()" method can be used to explicitly close an Excel file.
342
343           $workbook->close();
344
345       An explicit "close()" is required if the file must be closed prior to
346       performing some external action on it such as copying it, reading its
347       size or attaching it to an email.
348
349       In addition, "close()" may be required to prevent perl's garbage
350       collector from disposing of the Workbook, Worksheet and Format objects
351       in the wrong order. Situations where this can occur are:
352
353       ·   If "my()" was not used to declare the scope of a workbook variable
354           created using "new()".
355
356       ·   If the "new()", "add_worksheet()" or "add_format()" methods are
357           called in subroutines.
358
359       The reason for this is that Spreadsheet::WriteExcel relies on Perl's
360       "DESTROY" mechanism to trigger destructor methods in a specific
361       sequence. This may not happen in cases where the Workbook, Worksheet
362       and Format variables are not lexically scoped or where they have
363       different lexical scopes.
364
365       In general, if you create a file with a size of 0 bytes or you fail to
366       create a file you need to call "close()".
367
368       The return value of "close()" is the same as that returned by perl when
369       it closes the file created by "new()". This allows you to handle error
370       conditions in the usual way:
371
372           $workbook->close() or die "Error closing file: $!";
373
374   compatibility_mode()
375       This method is used to improve compatibility with third party
376       applications that read Excel files.
377
378           $workbook->compatibility_mode();
379
380       An Excel file is comprised of binary records that describe properties
381       of a spreadsheet. Excel is reasonably liberal about this and, outside
382       of a core subset, it doesn't require every possible record to be
383       present when it reads a file. This is also true of Gnumeric and
384       OpenOffice.Org Calc.
385
386       Spreadsheet::WriteExcel takes advantage of this fact to omit some
387       records in order to minimise the amount of data stored in memory and to
388       simplify and speed up the writing of files. However, some third party
389       applications that read Excel files often expect certain records to be
390       present. In "compatibility mode" Spreadsheet::WriteExcel writes these
391       records and tries to be as close to an Excel generated file as
392       possible.
393
394       Applications that require "compatibility_mode()" are Apache POI, Apple
395       Numbers, and Quickoffice on Nokia, Palm and other devices. You should
396       also use "compatibility_mode()" if your Excel file will be used as an
397       external data source by another Excel file.
398
399       If you encounter other situations that require "compatibility_mode()",
400       please let me know.
401
402       It should be noted that "compatibility_mode()" requires additional data
403       to be stored in memory and additional processing. This incurs a memory
404       and speed penalty and may not be suitable for very large files (>20MB).
405
406       You must call "compatibility_mode()" before calling "add_worksheet()".
407
408   set_properties()
409       The "set_properties" method can be used to set the document properties
410       of the Excel file created by "Spreadsheet::WriteExcel". These
411       properties are visible when you use the "File->Properties" menu option
412       in Excel and are also available to external applications that read or
413       index windows files.
414
415       The properties should be passed as a hash of values as follows:
416
417           $workbook->set_properties(
418               title    => 'This is an example spreadsheet',
419               author   => 'John McNamara',
420               comments => 'Created with Perl and Spreadsheet::WriteExcel',
421           );
422
423       The properties that can be set are:
424
425           title
426           subject
427           author
428           manager
429           company
430           category
431           keywords
432           comments
433
434       User defined properties are not supported due to effort required.
435
436       In perl 5.8+ you can also pass UTF-8 strings as properties. See
437       "UNICODE IN EXCEL".
438
439           my $smiley = chr 0x263A;
440
441           $workbook->set_properties(
442               subject => "Happy now? $smiley",
443           );
444
445       With older versions of perl you can use a module to convert a non-ASCII
446       string to a binary representation of UTF-8 and then pass an additional
447       "utf8" flag to "set_properties()":
448
449           my $smiley = pack 'H*', 'E298BA';
450
451           $workbook->set_properties(
452               subject => "Happy now? $smiley",
453               utf8    => 1,
454           );
455
456       Usually Spreadsheet::WriteExcel allows you to use UTF-16 with pre 5.8
457       versions of perl. However, document properties don't support UTF-16 for
458       these type of strings.
459
460       In order to promote the usefulness of Perl and the
461       Spreadsheet::WriteExcel module consider adding a comment such as the
462       following when using document properties:
463
464           $workbook->set_properties(
465               ...,
466               comments => 'Created with Perl and Spreadsheet::WriteExcel',
467               ...,
468           );
469
470       This feature requires that the "OLE::Storage_Lite" module is installed
471       (which is usually the case for a standard Spreadsheet::WriteExcel
472       installation). However, this also means that the resulting OLE document
473       may possibly be buggy for files less than 7MB since it hasn't been as
474       rigorously tested in that domain. As a result of this "set_properties"
475       is currently incompatible with Gnumeric for files less than 7MB. This
476       is being investigated. If you encounter any problems with this features
477       let me know.
478
479       For convenience it is possible to pass either a hash or hash ref of
480       arguments to this method.
481
482       See also the "properties.pl" program in the examples directory of the
483       distro.
484
485   define_name()
486       This method is used to defined a name that can be used to represent a
487       value, a single cell or a range of cells in a workbook.
488
489           $workbook->define_name('Exchange_rate', '=0.96');
490           $workbook->define_name('Sales',         '=Sheet1!$G$1:$H$10');
491           $workbook->define_name('Sheet2!Sales',  '=Sheet2!$G$1:$G$10');
492
493       See the defined_name.pl program in the examples dir of the distro.
494
495       Note: This currently a beta feature. More documentation and examples
496       will be added.
497
498   set_tempdir()
499       For speed and efficiency "Spreadsheet::WriteExcel" stores worksheet
500       data in temporary files prior to assembling the final workbook.
501
502       If Spreadsheet::WriteExcel is unable to create these temporary files it
503       will store the required data in memory. This can be slow for large
504       files.
505
506       The problem occurs mainly with IIS on Windows although it could
507       feasibly occur on Unix systems as well. The problem generally occurs
508       because the default temp file directory is defined as "C:/" or some
509       other directory that IIS doesn't provide write access to.
510
511       To check if this might be a problem on a particular system you can run
512       a simple test program with "-w" or "use warnings". This will generate a
513       warning if the module cannot create the required temporary files:
514
515           #!/usr/bin/perl -w
516
517           use Spreadsheet::WriteExcel;
518
519           my $workbook  = Spreadsheet::WriteExcel->new('test.xls');
520           my $worksheet = $workbook->add_worksheet();
521
522       To avoid this problem the "set_tempdir()" method can be used to specify
523       a directory that is accessible for the creation of temporary files.
524
525       The "File::Temp" module is used to create the temporary files.
526       File::Temp uses "File::Spec" to determine an appropriate location for
527       these files such as "/tmp" or "c:\windows\temp". You can find out which
528       directory is used on your system as follows:
529
530           perl -MFile::Spec -le "print File::Spec->tmpdir"
531
532       Even if the default temporary file directory is accessible you may wish
533       to specify an alternative location for security or maintenance reasons:
534
535           $workbook->set_tempdir('/tmp/writeexcel');
536           $workbook->set_tempdir('c:\windows\temp\writeexcel');
537
538       The directory for the temporary file must exist, "set_tempdir()" will
539       not create a new directory.
540
541       One disadvantage of using the "set_tempdir()" method is that on some
542       Windows systems it will limit you to approximately 800 concurrent
543       tempfiles. This means that a single program running on one of these
544       systems will be limited to creating a total of 800 workbook and
545       worksheet objects. You can run multiple, non-concurrent programs to
546       work around this if necessary.
547
548   set_custom_color($index, $red, $green, $blue)
549       The "set_custom_color()" method can be used to override one of the
550       built-in palette values with a more suitable colour.
551
552       The value for $index should be in the range 8..63, see "COLOURS IN
553       EXCEL".
554
555       The default named colours use the following indices:
556
557            8   =>   black
558            9   =>   white
559           10   =>   red
560           11   =>   lime
561           12   =>   blue
562           13   =>   yellow
563           14   =>   magenta
564           15   =>   cyan
565           16   =>   brown
566           17   =>   green
567           18   =>   navy
568           20   =>   purple
569           22   =>   silver
570           23   =>   gray
571           33   =>   pink
572           53   =>   orange
573
574       A new colour is set using its RGB (red green blue) components. The
575       $red, $green and $blue values must be in the range 0..255. You can
576       determine the required values in Excel using the
577       "Tools->Options->Colors->Modify" dialog.
578
579       The "set_custom_color()" workbook method can also be used with a HTML
580       style "#rrggbb" hex value:
581
582           $workbook->set_custom_color(40, 255,  102,  0   ); # Orange
583           $workbook->set_custom_color(40, 0xFF, 0x66, 0x00); # Same thing
584           $workbook->set_custom_color(40, '#FF6600'       ); # Same thing
585
586           my $font = $workbook->add_format(color => 40); # Use the modified colour
587
588       The return value from "set_custom_color()" is the index of the colour
589       that was changed:
590
591           my $ferrari = $workbook->set_custom_color(40, 216, 12, 12);
592
593           my $format  = $workbook->add_format(
594                                               bg_color => $ferrari,
595                                               pattern  => 1,
596                                               border   => 1
597                                             );
598
599   sheets(0, 1, ...)
600       The "sheets()" method returns a list, or a sliced list, of the
601       worksheets in a workbook.
602
603       If no arguments are passed the method returns a list of all the
604       worksheets in the workbook. This is useful if you want to repeat an
605       operation on each worksheet:
606
607           foreach $worksheet ($workbook->sheets()) {
608              print $worksheet->get_name();
609           }
610
611       You can also specify a slice list to return one or more worksheet
612       objects:
613
614           $worksheet = $workbook->sheets(0);
615           $worksheet->write('A1', 'Hello');
616
617       Or since return value from "sheets()" is a reference to a worksheet
618       object you can write the above example as:
619
620           $workbook->sheets(0)->write('A1', 'Hello');
621
622       The following example returns the first and last worksheet in a
623       workbook:
624
625           foreach $worksheet ($workbook->sheets(0, -1)) {
626              # Do something
627           }
628
629       Array slices are explained in the perldata manpage.
630
631   set_1904()
632       Excel stores dates as real numbers where the integer part stores the
633       number of days since the epoch and the fractional part stores the
634       percentage of the day. The epoch can be either 1900 or 1904. Excel for
635       Windows uses 1900 and Excel for Macintosh uses 1904. However, Excel on
636       either platform will convert automatically between one system and the
637       other.
638
639       Spreadsheet::WriteExcel stores dates in the 1900 format by default. If
640       you wish to change this you can call the "set_1904()" workbook method.
641       You can query the current value by calling the "get_1904()" workbook
642       method. This returns 0 for 1900 and 1 for 1904.
643
644       See also "DATES AND TIME IN EXCEL" for more information about working
645       with Excel's date system.
646
647       In general you probably won't need to use "set_1904()".
648
649   set_codepage($codepage)
650       The default code page or character set used by Spreadsheet::WriteExcel
651       is ANSI. This is also the default used by Excel for Windows.
652       Occasionally however it may be necessary to change the code page via
653       the "set_codepage()" method.
654
655       Changing the code page may be required if your are using
656       Spreadsheet::WriteExcel on the Macintosh and you are using characters
657       outside the ASCII 128 character set:
658
659           $workbook->set_codepage(1); # ANSI, MS Windows
660           $workbook->set_codepage(2); # Apple Macintosh
661
662       The "set_codepage()" method is rarely required.
663

WORKSHEET METHODS

665       A new worksheet is created by calling the "add_worksheet()" method from
666       a workbook object:
667
668           $worksheet1 = $workbook->add_worksheet();
669           $worksheet2 = $workbook->add_worksheet();
670
671       The following methods are available through a new worksheet:
672
673           write()
674           write_number()
675           write_string()
676           write_utf16be_string()
677           write_utf16le_string()
678           keep_leading_zeros()
679           write_blank()
680           write_row()
681           write_col()
682           write_date_time()
683           write_url()
684           write_url_range()
685           write_formula()
686           store_formula()
687           repeat_formula()
688           write_comment()
689           show_comments()
690           add_write_handler()
691           insert_image()
692           insert_chart()
693           data_validation()
694           get_name()
695           activate()
696           select()
697           hide()
698           set_first_sheet()
699           protect()
700           set_selection()
701           set_row()
702           set_column()
703           outline_settings()
704           freeze_panes()
705           split_panes()
706           merge_range()
707           set_zoom()
708           right_to_left()
709           hide_zero()
710           set_tab_color()
711           autofilter()
712
713   Cell notation
714       Spreadsheet::WriteExcel supports two forms of notation to designate the
715       position of cells: Row-column notation and A1 notation.
716
717       Row-column notation uses a zero based index for both row and column
718       while A1 notation uses the standard Excel alphanumeric sequence of
719       column letter and 1-based row. For example:
720
721           (0, 0)      # The top left cell in row-column notation.
722           ('A1')      # The top left cell in A1 notation.
723
724           (1999, 29)  # Row-column notation.
725           ('AD2000')  # The same cell in A1 notation.
726
727       Row-column notation is useful if you are referring to cells
728       programmatically:
729
730           for my $i (0 .. 9) {
731               $worksheet->write($i, 0, 'Hello'); # Cells A1 to A10
732           }
733
734       A1 notation is useful for setting up a worksheet manually and for
735       working with formulas:
736
737           $worksheet->write('H1', 200);
738           $worksheet->write('H2', '=H1+1');
739
740       In formulas and applicable methods you can also use the "A:A" column
741       notation:
742
743           $worksheet->write('A1', '=SUM(B:B)');
744
745       The "Spreadsheet::WriteExcel::Utility" module that is included in the
746       distro contains helper functions for dealing with A1 notation, for
747       example:
748
749           use Spreadsheet::WriteExcel::Utility;
750
751           ($row, $col)    = xl_cell_to_rowcol('C2');  # (1, 2)
752           $str            = xl_rowcol_to_cell(1, 2);  # C2
753
754       For simplicity, the parameter lists for the worksheet method calls in
755       the following sections are given in terms of row-column notation. In
756       all cases it is also possible to use A1 notation.
757
758       Note: in Excel it is also possible to use a R1C1 notation. This is not
759       supported by Spreadsheet::WriteExcel.
760
761   write($row, $column, $token, $format)
762       Excel makes a distinction between data types such as strings, numbers,
763       blanks, formulas and hyperlinks. To simplify the process of writing
764       data the "write()" method acts as a general alias for several more
765       specific methods:
766
767           write_string()
768           write_number()
769           write_blank()
770           write_formula()
771           write_url()
772           write_row()
773           write_col()
774
775       The general rule is that if the data looks like a something then a
776       something is written. Here are some examples in both row-column and A1
777       notation:
778
779                                                             # Same as:
780           $worksheet->write(0, 0, 'Hello'                ); # write_string()
781           $worksheet->write(1, 0, 'One'                  ); # write_string()
782           $worksheet->write(2, 0,  2                     ); # write_number()
783           $worksheet->write(3, 0,  3.00001               ); # write_number()
784           $worksheet->write(4, 0,  ""                    ); # write_blank()
785           $worksheet->write(5, 0,  ''                    ); # write_blank()
786           $worksheet->write(6, 0,  undef                 ); # write_blank()
787           $worksheet->write(7, 0                         ); # write_blank()
788           $worksheet->write(8, 0,  'http://www.perl.com/'); # write_url()
789           $worksheet->write('A9',  'ftp://ftp.cpan.org/' ); # write_url()
790           $worksheet->write('A10', 'internal:Sheet1!A1'  ); # write_url()
791           $worksheet->write('A11', 'external:c:\foo.xls' ); # write_url()
792           $worksheet->write('A12', '=A3 + 3*A4'          ); # write_formula()
793           $worksheet->write('A13', '=SIN(PI()/4)'        ); # write_formula()
794           $worksheet->write('A14', \@array               ); # write_row()
795           $worksheet->write('A15', [\@array]             ); # write_col()
796
797           # And if the keep_leading_zeros property is set:
798           $worksheet->write('A16,  2                     ); # write_number()
799           $worksheet->write('A17,  02                    ); # write_string()
800           $worksheet->write('A18,  00002                 ); # write_string()
801
802       The "looks like" rule is defined by regular expressions:
803
804       "write_number()" if $token is a number based on the following regex:
805       "$token =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/".
806
807       "write_string()" if "keep_leading_zeros()" is set and $token is an
808       integer with leading zeros based on the following regex: "$token =~
809       /^0\d+$/".
810
811       "write_blank()" if $token is undef or a blank string: "undef", "" or
812       ''.
813
814       "write_url()" if $token is a http, https, ftp or mailto URL based on
815       the following regexes: "$token =~ m|^[fh]tt?ps?://|" or  "$token =~
816       m|^mailto:|".
817
818       "write_url()" if $token is an internal or external sheet reference
819       based on the following regex: "$token =~ m[^(in|ex)ternal:]".
820
821       "write_formula()" if the first character of $token is "=".
822
823       "write_row()" if $token is an array ref.
824
825       "write_col()" if $token is an array ref of array refs.
826
827       "write_string()" if none of the previous conditions apply.
828
829       The $format parameter is optional. It should be a valid Format object,
830       see "CELL FORMATTING":
831
832           my $format = $workbook->add_format();
833           $format->set_bold();
834           $format->set_color('red');
835           $format->set_align('center');
836
837           $worksheet->write(4, 0, 'Hello', $format); # Formatted string
838
839       The write() method will ignore empty strings or "undef" tokens unless a
840       format is also supplied. As such you needn't worry about special
841       handling for empty or "undef" values in your data. See also the
842       "write_blank()" method.
843
844       One problem with the "write()" method is that occasionally data looks
845       like a number but you don't want it treated as a number. For example,
846       zip codes or ID numbers often start with a leading zero. If you write
847       this data as a number then the leading zero(s) will be stripped. You
848       can change this default behaviour by using the "keep_leading_zeros()"
849       method. While this property is in place any integers with leading zeros
850       will be treated as strings and the zeros will be preserved. See the
851       "keep_leading_zeros()" section for a full discussion of this issue.
852
853       You can also add your own data handlers to the "write()" method using
854       "add_write_handler()".
855
856       On systems with "perl 5.8" and later the "write()" method will also
857       handle Unicode strings in "UTF-8" format.
858
859       The "write" methods return:
860
861           0 for success.
862          -1 for insufficient number of arguments.
863          -2 for row or column out of bounds.
864          -3 for string too long.
865
866   write_number($row, $column, $number, $format)
867       Write an integer or a float to the cell specified by $row and $column:
868
869           $worksheet->write_number(0, 0,  123456);
870           $worksheet->write_number('A2',  2.3451);
871
872       See the note about "Cell notation". The $format parameter is optional.
873
874       In general it is sufficient to use the "write()" method.
875
876   write_string($row, $column, $string, $format)
877       Write a string to the cell specified by $row and $column:
878
879           $worksheet->write_string(0, 0, 'Your text here' );
880           $worksheet->write_string('A2', 'or here' );
881
882       The maximum string size is 32767 characters. However the maximum string
883       segment that Excel can display in a cell is 1000. All 32767 characters
884       can be displayed in the formula bar.
885
886       The $format parameter is optional.
887
888       On systems with "perl 5.8" and later the "write()" method will also
889       handle strings in "UTF-8" format. With older perls you can also write
890       Unicode in "UTF16" format via the "write_utf16be_string()" method. See
891       also the "unicode_*.pl" programs in the examples directory of the
892       distro.
893
894       In general it is sufficient to use the "write()" method. However, you
895       may sometimes wish to use the "write_string()" method to write data
896       that looks like a number but that you don't want treated as a number.
897       For example, zip codes or phone numbers:
898
899           # Write as a plain string
900           $worksheet->write_string('A1', '01209');
901
902       However, if the user edits this string Excel may convert it back to a
903       number. To get around this you can use the Excel text format "@":
904
905           # Format as a string. Doesn't change to a number when edited
906           my $format1 = $workbook->add_format(num_format => '@');
907           $worksheet->write_string('A2', '01209', $format1);
908
909       See also the note about "Cell notation".
910
911   write_utf16be_string($row, $column, $string, $format)
912       This method is used to write "UTF-16BE" strings to a cell in Excel. It
913       is functionally the same as the "write_string()" method except that the
914       string should be in "UTF-16BE" Unicode format. It is generally easier,
915       when using Spreadsheet::WriteExcel, to write unicode strings in "UTF-8"
916       format, see "UNICODE IN EXCEL". The "write_utf16be_string()" method is
917       mainly of use in versions of perl prior to 5.8.
918
919       The following is a simple example showing how to write some Unicode
920       strings in "UTF-16BE" format:
921
922           #!/usr/bin/perl -w
923
924
925           use strict;
926           use Spreadsheet::WriteExcel;
927           use Unicode::Map();
928
929           my $workbook  = Spreadsheet::WriteExcel->new('utf_16_be.xls');
930           my $worksheet = $workbook->add_worksheet();
931
932           # Increase the column width for clarity
933           $worksheet->set_column('A:A', 25);
934
935
936           # Write a Unicode character
937           #
938           my $smiley = pack 'n', 0x263a;
939
940           # Increase the font size for legibility.
941           my $big_font = $workbook->add_format(size => 72);
942
943           $worksheet->write_utf16be_string('A3', $smiley, $big_font);
944
945
946
947           # Write a phrase in Cyrillic using a hex-encoded string
948           #
949           my $str = pack 'H*', '042d0442043e0020044404400430043704300020043d' .
950                                '043000200440044304410441043a043e043c0021';
951
952           $worksheet->write_utf16be_string('A5', $str);
953
954
955
956           # Map a string to UTF-16BE using an external module.
957           #
958           my $map   = Unicode::Map->new('ISO-8859-1');
959           my $utf16 = $map->to_unicode('Hello world!');
960
961           $worksheet->write_utf16be_string('A7', $utf16);
962
963       You can convert ASCII encodings to the required "UTF-16BE" format using
964       one of the many Unicode modules on CPAN. For example "Unicode::Map" and
965       "Unicode::String":
966       http://search.cpan.org/author/MSCHWARTZ/Unicode-Map/Map.pm
967       <http://search.cpan.org/author/MSCHWARTZ/Unicode-Map/Map.pm> and
968       http://search.cpan.org/author/GAAS/Unicode-String/String.pm
969       <http://search.cpan.org/author/GAAS/Unicode-String/String.pm>.
970
971       For a full list of the Perl Unicode modules see:
972       <http://search.cpan.org/search?query=unicode&mode=all>.
973
974       "UTF-16BE" is the format most often returned by "Perl" modules that
975       generate "UTF-16". To write "UTF-16" strings in little-endian format
976       use the "write_utf16be_string_le()" method below.
977
978       The "write_utf16be_string()" method was previously called
979       "write_unicode()". That, overly general, name is still supported but
980       deprecated.
981
982       See also the "unicode_*.pl" programs in the examples directory of the
983       distro.
984
985   write_utf16le_string($row, $column, $string, $format)
986       This method is the same as "write_utf16be()" except that the string
987       should be 16-bit characters in little-endian format. This is generally
988       referred to as "UTF-16LE". See "UNICODE IN EXCEL".
989
990       "UTF-16" data can be changed from little-endian to big-endian format
991       (and vice-versa) as follows:
992
993           $utf16be = pack 'n*', unpack 'v*', $utf16le;
994
995   keep_leading_zeros()
996       This method changes the default handling of integers with leading zeros
997       when using the "write()" method.
998
999       The "write()" method uses regular expressions to determine what type of
1000       data to write to an Excel worksheet. If the data looks like a number it
1001       writes a number using "write_number()". One problem with this approach
1002       is that occasionally data looks like a number but you don't want it
1003       treated as a number.
1004
1005       Zip codes and ID numbers, for example, often start with a leading zero.
1006       If you write this data as a number then the leading zero(s) will be
1007       stripped. This is the also the default behaviour when you enter data
1008       manually in Excel.
1009
1010       To get around this you can use one of three options. Write a formatted
1011       number, write the number as a string or use the "keep_leading_zeros()"
1012       method to change the default behaviour of "write()":
1013
1014           # Implicitly write a number, the leading zero is removed: 1209
1015           $worksheet->write('A1', '01209');
1016
1017           # Write a zero padded number using a format: 01209
1018           my $format1 = $workbook->add_format(num_format => '00000');
1019           $worksheet->write('A2', '01209', $format1);
1020
1021           # Write explicitly as a string: 01209
1022           $worksheet->write_string('A3', '01209');
1023
1024           # Write implicitly as a string: 01209
1025           $worksheet->keep_leading_zeros();
1026           $worksheet->write('A4', '01209');
1027
1028       The above code would generate a worksheet that looked like the
1029       following:
1030
1031            -----------------------------------------------------------
1032           |   |     A     |     B     |     C     |     D     | ...
1033            -----------------------------------------------------------
1034           | 1 |      1209 |           |           |           | ...
1035           | 2 |     01209 |           |           |           | ...
1036           | 3 | 01209     |           |           |           | ...
1037           | 4 | 01209     |           |           |           | ...
1038
1039       The examples are on different sides of the cells due to the fact that
1040       Excel displays strings with a left justification and numbers with a
1041       right justification by default. You can change this by using a format
1042       to justify the data, see "CELL FORMATTING".
1043
1044       It should be noted that if the user edits the data in examples "A3" and
1045       "A4" the strings will revert back to numbers. Again this is Excel's
1046       default behaviour. To avoid this you can use the text format "@":
1047
1048           # Format as a string (01209)
1049           my $format2 = $workbook->add_format(num_format => '@');
1050           $worksheet->write_string('A5', '01209', $format2);
1051
1052       The "keep_leading_zeros()" property is off by default. The
1053       "keep_leading_zeros()" method takes 0 or 1 as an argument. It defaults
1054       to 1 if an argument isn't specified:
1055
1056           $worksheet->keep_leading_zeros();  # Set on
1057           $worksheet->keep_leading_zeros(1); # Set on
1058           $worksheet->keep_leading_zeros(0); # Set off
1059
1060       See also the "add_write_handler()" method.
1061
1062   write_blank($row, $column, $format)
1063       Write a blank cell specified by $row and $column:
1064
1065           $worksheet->write_blank(0, 0, $format);
1066
1067       This method is used to add formatting to a cell which doesn't contain a
1068       string or number value.
1069
1070       Excel differentiates between an "Empty" cell and a "Blank" cell. An
1071       "Empty" cell is a cell which doesn't contain data whilst a "Blank" cell
1072       is a cell which doesn't contain data but does contain formatting. Excel
1073       stores "Blank" cells but ignores "Empty" cells.
1074
1075       As such, if you write an empty cell without formatting it is ignored:
1076
1077           $worksheet->write('A1',  undef, $format); # write_blank()
1078           $worksheet->write('A2',  undef         ); # Ignored
1079
1080       This seemingly uninteresting fact means that you can write arrays of
1081       data without special treatment for undef or empty string values.
1082
1083       See the note about "Cell notation".
1084
1085   write_row($row, $column, $array_ref, $format)
1086       The "write_row()" method can be used to write a 1D or 2D array of data
1087       in one go. This is useful for converting the results of a database
1088       query into an Excel worksheet. You must pass a reference to the array
1089       of data rather than the array itself. The "write()" method is then
1090       called for each element of the data. For example:
1091
1092           @array      = ('awk', 'gawk', 'mawk');
1093           $array_ref  = \@array;
1094
1095           $worksheet->write_row(0, 0, $array_ref);
1096
1097           # The above example is equivalent to:
1098           $worksheet->write(0, 0, $array[0]);
1099           $worksheet->write(0, 1, $array[1]);
1100           $worksheet->write(0, 2, $array[2]);
1101
1102       Note: For convenience the "write()" method behaves in the same way as
1103       "write_row()" if it is passed an array reference. Therefore the
1104       following two method calls are equivalent:
1105
1106           $worksheet->write_row('A1', $array_ref); # Write a row of data
1107           $worksheet->write(    'A1', $array_ref); # Same thing
1108
1109       As with all of the write methods the $format parameter is optional. If
1110       a format is specified it is applied to all the elements of the data
1111       array.
1112
1113       Array references within the data will be treated as columns. This
1114       allows you to write 2D arrays of data in one go. For example:
1115
1116           @eec =  (
1117                       ['maggie', 'milly', 'molly', 'may'  ],
1118                       [13,       14,      15,      16     ],
1119                       ['shell',  'star',  'crab',  'stone']
1120                   );
1121
1122           $worksheet->write_row('A1', \@eec);
1123
1124       Would produce a worksheet as follows:
1125
1126            -----------------------------------------------------------
1127           |   |    A    |    B    |    C    |    D    |    E    | ...
1128            -----------------------------------------------------------
1129           | 1 | maggie  | 13      | shell   | ...     |  ...    | ...
1130           | 2 | milly   | 14      | star    | ...     |  ...    | ...
1131           | 3 | molly   | 15      | crab    | ...     |  ...    | ...
1132           | 4 | may     | 16      | stone   | ...     |  ...    | ...
1133           | 5 | ...     | ...     | ...     | ...     |  ...    | ...
1134           | 6 | ...     | ...     | ...     | ...     |  ...    | ...
1135
1136       To write the data in a row-column order refer to the "write_col()"
1137       method below.
1138
1139       Any "undef" values in the data will be ignored unless a format is
1140       applied to the data, in which case a formatted blank cell will be
1141       written. In either case the appropriate row or column value will still
1142       be incremented.
1143
1144       To find out more about array references refer to "perlref" and
1145       "perlreftut" in the main Perl documentation. To find out more about 2D
1146       arrays or "lists of lists" refer to "perllol".
1147
1148       The "write_row()" method returns the first error encountered when
1149       writing the elements of the data or zero if no errors were encountered.
1150       See the return values described for the "write()" method above.
1151
1152       See also the "write_arrays.pl" program in the "examples" directory of
1153       the distro.
1154
1155       The "write_row()" method allows the following idiomatic conversion of a
1156       text file to an Excel file:
1157
1158           #!/usr/bin/perl -w
1159
1160           use strict;
1161           use Spreadsheet::WriteExcel;
1162
1163           my $workbook  = Spreadsheet::WriteExcel->new('file.xls');
1164           my $worksheet = $workbook->add_worksheet();
1165
1166           open INPUT, 'file.txt' or die "Couldn't open file: $!";
1167
1168           $worksheet->write($.-1, 0, [split]) while <INPUT>;
1169
1170   write_col($row, $column, $array_ref, $format)
1171       The "write_col()" method can be used to write a 1D or 2D array of data
1172       in one go. This is useful for converting the results of a database
1173       query into an Excel worksheet. You must pass a reference to the array
1174       of data rather than the array itself. The "write()" method is then
1175       called for each element of the data. For example:
1176
1177           @array      = ('awk', 'gawk', 'mawk');
1178           $array_ref  = \@array;
1179
1180           $worksheet->write_col(0, 0, $array_ref);
1181
1182           # The above example is equivalent to:
1183           $worksheet->write(0, 0, $array[0]);
1184           $worksheet->write(1, 0, $array[1]);
1185           $worksheet->write(2, 0, $array[2]);
1186
1187       As with all of the write methods the $format parameter is optional. If
1188       a format is specified it is applied to all the elements of the data
1189       array.
1190
1191       Array references within the data will be treated as rows. This allows
1192       you to write 2D arrays of data in one go. For example:
1193
1194           @eec =  (
1195                       ['maggie', 'milly', 'molly', 'may'  ],
1196                       [13,       14,      15,      16     ],
1197                       ['shell',  'star',  'crab',  'stone']
1198                   );
1199
1200           $worksheet->write_col('A1', \@eec);
1201
1202       Would produce a worksheet as follows:
1203
1204            -----------------------------------------------------------
1205           |   |    A    |    B    |    C    |    D    |    E    | ...
1206            -----------------------------------------------------------
1207           | 1 | maggie  | milly   | molly   | may     |  ...    | ...
1208           | 2 | 13      | 14      | 15      | 16      |  ...    | ...
1209           | 3 | shell   | star    | crab    | stone   |  ...    | ...
1210           | 4 | ...     | ...     | ...     | ...     |  ...    | ...
1211           | 5 | ...     | ...     | ...     | ...     |  ...    | ...
1212           | 6 | ...     | ...     | ...     | ...     |  ...    | ...
1213
1214       To write the data in a column-row order refer to the "write_row()"
1215       method above.
1216
1217       Any "undef" values in the data will be ignored unless a format is
1218       applied to the data, in which case a formatted blank cell will be
1219       written. In either case the appropriate row or column value will still
1220       be incremented.
1221
1222       As noted above the "write()" method can be used as a synonym for
1223       "write_row()" and "write_row()" handles nested array refs as columns.
1224       Therefore, the following two method calls are equivalent although the
1225       more explicit call to "write_col()" would be preferable for
1226       maintainability:
1227
1228           $worksheet->write_col('A1', $array_ref    ); # Write a column of data
1229           $worksheet->write(    'A1', [ $array_ref ]); # Same thing
1230
1231       To find out more about array references refer to "perlref" and
1232       "perlreftut" in the main Perl documentation. To find out more about 2D
1233       arrays or "lists of lists" refer to "perllol".
1234
1235       The "write_col()" method returns the first error encountered when
1236       writing the elements of the data or zero if no errors were encountered.
1237       See the return values described for the "write()" method above.
1238
1239       See also the "write_arrays.pl" program in the "examples" directory of
1240       the distro.
1241
1242   write_date_time($row, $col, $date_string, $format)
1243       The "write_date_time()" method can be used to write a date or time to
1244       the cell specified by $row and $column:
1245
1246           $worksheet->write_date_time('A1', '2004-05-13T23:20', $date_format);
1247
1248       The $date_string should be in the following format:
1249
1250           yyyy-mm-ddThh:mm:ss.sss
1251
1252       This conforms to an ISO8601 date but it should be noted that the full
1253       range of ISO8601 formats are not supported.
1254
1255       The following variations on the $date_string parameter are permitted:
1256
1257           yyyy-mm-ddThh:mm:ss.sss         # Standard format
1258           yyyy-mm-ddT                     # No time
1259                     Thh:mm:ss.sss         # No date
1260           yyyy-mm-ddThh:mm:ss.sssZ        # Additional Z (but not time zones)
1261           yyyy-mm-ddThh:mm:ss             # No fractional seconds
1262           yyyy-mm-ddThh:mm                # No seconds
1263
1264       Note that the "T" is required in all cases.
1265
1266       A date should always have a $format, otherwise it will appear as a
1267       number, see "DATES AND TIME IN EXCEL" and "CELL FORMATTING". Here is a
1268       typical example:
1269
1270           my $date_format = $workbook->add_format(num_format => 'mm/dd/yy');
1271           $worksheet->write_date_time('A1', '2004-05-13T23:20', $date_format);
1272
1273       Valid dates should be in the range 1900-01-01 to 9999-12-31, for the
1274       1900 epoch and 1904-01-01 to 9999-12-31, for the 1904 epoch. As with
1275       Excel, dates outside these ranges will be written as a string.
1276
1277       See also the date_time.pl program in the "examples" directory of the
1278       distro.
1279
1280   write_url($row, $col, $url, $label, $format)
1281       Write a hyperlink to a URL in the cell specified by $row and $column.
1282       The hyperlink is comprised of two elements: the visible label and the
1283       invisible link. The visible label is the same as the link unless an
1284       alternative label is specified. The parameters $label and the $format
1285       are optional and their position is interchangeable.
1286
1287       The label is written using the "write()" method. Therefore it is
1288       possible to write strings, numbers or formulas as labels.
1289
1290       There are four web style URI's supported: "http://", "https://",
1291       "ftp://" and  "mailto:":
1292
1293           $worksheet->write_url(0, 0,  'ftp://www.perl.org/'                  );
1294           $worksheet->write_url(1, 0,  'http://www.perl.com/', 'Perl home'    );
1295           $worksheet->write_url('A3',  'http://www.perl.com/', $format        );
1296           $worksheet->write_url('A4',  'http://www.perl.com/', 'Perl', $format);
1297           $worksheet->write_url('A5',  'mailto:jmcnamara@cpan.org'            );
1298
1299       There are two local URIs supported: "internal:" and "external:". These
1300       are used for hyperlinks to internal worksheet references or external
1301       workbook and worksheet references:
1302
1303           $worksheet->write_url('A6',  'internal:Sheet2!A1'                   );
1304           $worksheet->write_url('A7',  'internal:Sheet2!A1',   $format        );
1305           $worksheet->write_url('A8',  'internal:Sheet2!A1:B2'                );
1306           $worksheet->write_url('A9',  q{internal:'Sales Data'!A1}            );
1307           $worksheet->write_url('A10', 'external:c:\temp\foo.xls'             );
1308           $worksheet->write_url('A11', 'external:c:\temp\foo.xls#Sheet2!A1'   );
1309           $worksheet->write_url('A12', 'external:..\..\..\foo.xls'            );
1310           $worksheet->write_url('A13', 'external:..\..\..\foo.xls#Sheet2!A1'  );
1311           $worksheet->write_url('A13', 'external:\\\\NETWORK\share\foo.xls'   );
1312
1313       All of the these URI types are recognised by the "write()" method, see
1314       above.
1315
1316       Worksheet references are typically of the form "Sheet1!A1". You can
1317       also refer to a worksheet range using the standard Excel notation:
1318       "Sheet1!A1:B2".
1319
1320       In external links the workbook and worksheet name must be separated by
1321       the "#" character: "external:Workbook.xls#Sheet1!A1'".
1322
1323       You can also link to a named range in the target worksheet. For example
1324       say you have a named range called "my_name" in the workbook
1325       "c:\temp\foo.xls" you could link to it as follows:
1326
1327           $worksheet->write_url('A14', 'external:c:\temp\foo.xls#my_name');
1328
1329       Note, you cannot currently create named ranges with
1330       "Spreadsheet::WriteExcel".
1331
1332       Excel requires that worksheet names containing spaces or non
1333       alphanumeric characters are single quoted as follows "'Sales Data'!A1".
1334       If you need to do this in a single quoted string then you can either
1335       escape the single quotes "\'" or use the quote operator "q{}" as
1336       described in "perlop" in the main Perl documentation.
1337
1338       Links to network files are also supported. MS/Novell Network files
1339       normally begin with two back slashes as follows "\\NETWORK\etc". In
1340       order to generate this in a single or double quoted string you will
1341       have to escape the backslashes,  '\\\\NETWORK\etc'.
1342
1343       If you are using double quote strings then you should be careful to
1344       escape anything that looks like a metacharacter. For more information
1345       see "perlfaq5: Why can't I use "C:\temp\foo" in DOS paths?".
1346
1347       Finally, you can avoid most of these quoting problems by using forward
1348       slashes. These are translated internally to backslashes:
1349
1350           $worksheet->write_url('A14', "external:c:/temp/foo.xls"             );
1351           $worksheet->write_url('A15', 'external://NETWORK/share/foo.xls'     );
1352
1353       See also, the note about "Cell notation".
1354
1355   write_url_range($row1, $col1, $row2, $col2, $url, $string, $format)
1356       This method is essentially the same as the "write_url()" method
1357       described above. The main difference is that you can specify a link for
1358       a range of cells:
1359
1360           $worksheet->write_url(0, 0, 0, 3, 'ftp://www.perl.org/'              );
1361           $worksheet->write_url(1, 0, 0, 3, 'http://www.perl.com/', 'Perl home');
1362           $worksheet->write_url('A3:D3',    'internal:Sheet2!A1'               );
1363           $worksheet->write_url('A4:D4',    'external:c:\temp\foo.xls'         );
1364
1365       This method is generally only required when used in conjunction with
1366       merged cells. See the "merge_range()" method and the "merge" property
1367       of a Format object, "CELL FORMATTING".
1368
1369       There is no way to force this behaviour through the "write()" method.
1370
1371       The parameters $string and the $format are optional and their position
1372       is interchangeable. However, they are applied only to the first cell in
1373       the range.
1374
1375       See also, the note about "Cell notation".
1376
1377   write_formula($row, $column, $formula, $format, $value)
1378       Write a formula or function to the cell specified by $row and $column:
1379
1380           $worksheet->write_formula(0, 0, '=$B$3 + B4'  );
1381           $worksheet->write_formula(1, 0, '=SIN(PI()/4)');
1382           $worksheet->write_formula(2, 0, '=SUM(B1:B5)' );
1383           $worksheet->write_formula('A4', '=IF(A3>1,"Yes", "No")'   );
1384           $worksheet->write_formula('A5', '=AVERAGE(1, 2, 3, 4)'    );
1385           $worksheet->write_formula('A6', '=DATEVALUE("1-Jan-2001")');
1386
1387       See the note about "Cell notation". For more information about writing
1388       Excel formulas see "FORMULAS AND FUNCTIONS IN EXCEL"
1389
1390       See also the section "Improving performance when working with formulas"
1391       and the "store_formula()" and "repeat_formula()" methods.
1392
1393       If required, it is also possible to specify the calculated value of the
1394       formula. This is occasionally necessary when working with non-Excel
1395       applications that don't calculated the value of the formula. The
1396       calculated $value is added at the end of the argument list:
1397
1398           $worksheet->write('A1', '=2+2', $format, 4);
1399
1400       However, this probably isn't something that will ever need to do. If
1401       you do use this feature then do so with care.
1402
1403   store_formula($formula)
1404       The "store_formula()" method is used in conjunction with
1405       "repeat_formula()" to speed up the generation of repeated formulas. See
1406       "Improving performance when working with formulas" in "FORMULAS AND
1407       FUNCTIONS IN EXCEL".
1408
1409       The "store_formula()" method pre-parses a textual representation of a
1410       formula and stores it for use at a later stage by the
1411       "repeat_formula()" method.
1412
1413       "store_formula()" carries the same speed penalty as "write_formula()".
1414       However, in practice it will be used less frequently.
1415
1416       The return value of this method is a scalar that can be thought of as a
1417       reference to a formula.
1418
1419           my $sin = $worksheet->store_formula('=SIN(A1)');
1420           my $cos = $worksheet->store_formula('=COS(A1)');
1421
1422           $worksheet->repeat_formula('B1', $sin, $format, 'A1', 'A2');
1423           $worksheet->repeat_formula('C1', $cos, $format, 'A1', 'A2');
1424
1425       Although "store_formula()" is a worksheet method the return value can
1426       be used in any worksheet:
1427
1428           my $now = $worksheet->store_formula('=NOW()');
1429
1430           $worksheet1->repeat_formula('B1', $now);
1431           $worksheet2->repeat_formula('B1', $now);
1432           $worksheet3->repeat_formula('B1', $now);
1433
1434   repeat_formula($row, $col, $formula, $format, ($pattern => $replace, ...))
1435       The "repeat_formula()" method is used in conjunction with
1436       "store_formula()" to speed up the generation of repeated formulas.  See
1437       "Improving performance when working with formulas" in "FORMULAS AND
1438       FUNCTIONS IN EXCEL".
1439
1440       In many respects "repeat_formula()" behaves like "write_formula()"
1441       except that it is significantly faster.
1442
1443       The "repeat_formula()" method creates a new formula based on the pre-
1444       parsed tokens returned by "store_formula()". The new formula is
1445       generated by substituting $pattern, $replace pairs in the stored
1446       formula:
1447
1448           my $formula = $worksheet->store_formula('=A1 * 3 + 50');
1449
1450           for my $row (0..99) {
1451               $worksheet->repeat_formula($row, 1, $formula, $format, 'A1', 'A'.($row +1));
1452           }
1453
1454       It should be noted that "repeat_formula()" doesn't modify the tokens.
1455       In the above example the substitution is always made against the
1456       original token, "A1", which doesn't change.
1457
1458       As usual, you can use "undef" if you don't wish to specify a $format:
1459
1460           $worksheet->repeat_formula('B2', $formula, $format, 'A1', 'A2');
1461           $worksheet->repeat_formula('B3', $formula, undef,   'A1', 'A3');
1462
1463       The substitutions are made from left to right and you can use as many
1464       $pattern, $replace pairs as you need. However, each substitution is
1465       made only once:
1466
1467           my $formula = $worksheet->store_formula('=A1 + A1');
1468
1469           # Gives '=B1 + A1'
1470           $worksheet->repeat_formula('B1', $formula, undef, 'A1', 'B1');
1471
1472           # Gives '=B1 + B1'
1473           $worksheet->repeat_formula('B2', $formula, undef, ('A1', 'B1') x 2);
1474
1475       Since the $pattern is interpolated each time that it is used it is
1476       worth using the "qr" operator to quote the pattern. The "qr" operator
1477       is explained in the "perlop" man page.
1478
1479           $worksheet->repeat_formula('B1', $formula, $format, qr/A1/, 'A2');
1480
1481       Care should be taken with the values that are substituted. The formula
1482       returned by "repeat_formula()" contains several other tokens in
1483       addition to those in the formula and these might also match the
1484       pattern that you are trying to replace. In particular you should avoid
1485       substituting a single 0, 1, 2 or 3.
1486
1487       You should also be careful to avoid false matches. For example the
1488       following snippet is meant to change the stored formula in steps from
1489       "=A1 + SIN(A1)" to "=A10 + SIN(A10)".
1490
1491           my $formula = $worksheet->store_formula('=A1 + SIN(A1)');
1492
1493           for my $row (1 .. 10) {
1494               $worksheet->repeat_formula($row -1, 1, $formula, undef,
1495                                           qw/A1/, 'A' . $row,   #! Bad.
1496                                           qw/A1/, 'A' . $row    #! Bad.
1497                                         );
1498           }
1499
1500       However it contains a bug. In the last iteration of the loop when $row
1501       is 10 the following substitutions will occur:
1502
1503           s/A1/A10/;    changes    =A1 + SIN(A1)     to    =A10 + SIN(A1)
1504           s/A1/A10/;    changes    =A10 + SIN(A1)    to    =A100 + SIN(A1) # !!
1505
1506       The solution in this case is to use a more explicit match such as
1507       "qw/^A1$/":
1508
1509               $worksheet->repeat_formula($row -1, 1, $formula, undef,
1510                                           qw/^A1$/, 'A' . $row,
1511                                           qw/^A1$/, 'A' . $row
1512                                         );
1513
1514       Another similar problem occurs due to the fact that substitutions are
1515       made in order. For example the following snippet is meant to change the
1516       stored formula from "=A10 + A11"  to "=A11 + A12":
1517
1518           my $formula = $worksheet->store_formula('=A10 + A11');
1519
1520           $worksheet->repeat_formula('A1', $formula, undef,
1521                                       qw/A10/, 'A11',   #! Bad.
1522                                       qw/A11/, 'A12'    #! Bad.
1523                                     );
1524
1525       However, the actual substitution yields "=A12 + A11":
1526
1527           s/A10/A11/;    changes    =A10 + A11    to    =A11 + A11
1528           s/A11/A12/;    changes    =A11 + A11    to    =A12 + A11 # !!
1529
1530       The solution here would be to reverse the order of the substitutions or
1531       to start with a stored formula that won't yield a false match such as
1532       "=X10 + Y11":
1533
1534           my $formula = $worksheet->store_formula('=X10 + Y11');
1535
1536           $worksheet->repeat_formula('A1', $formula, undef,
1537                                       qw/X10/, 'A11',
1538                                       qw/Y11/, 'A12'
1539                                     );
1540
1541       If you think that you have a problem related to a false match you can
1542       check the tokens that you are substituting against as follows.
1543
1544           my $formula = $worksheet->store_formula('=A1*5+4');
1545           print "@$formula\n";
1546
1547       See also the "repeat.pl" program in the "examples" directory of the
1548       distro.
1549
1550   write_comment($row, $column, $string, ...)
1551       The "write_comment()" method is used to add a comment to a cell. A cell
1552       comment is indicated in Excel by a small red triangle in the upper
1553       right-hand corner of the cell. Moving the cursor over the red triangle
1554       will reveal the comment.
1555
1556       The following example shows how to add a comment to a cell:
1557
1558           $worksheet->write        (2, 2, 'Hello');
1559           $worksheet->write_comment(2, 2, 'This is a comment.');
1560
1561       As usual you can replace the $row and $column parameters with an "A1"
1562       cell reference. See the note about "Cell notation".
1563
1564           $worksheet->write        ('C3', 'Hello');
1565           $worksheet->write_comment('C3', 'This is a comment.');
1566
1567       On systems with "perl 5.8" and later the "write_comment()" method will
1568       also handle strings in "UTF-8" format.
1569
1570           $worksheet->write_comment('C3', "\x{263a}");       # Smiley
1571           $worksheet->write_comment('C4', 'Comment ca va?');
1572
1573       In addition to the basic 3 argument form of "write_comment()" you can
1574       pass in several optional key/value pairs to control the format of the
1575       comment. For example:
1576
1577           $worksheet->write_comment('C3', 'Hello', visible => 1, author => 'Perl');
1578
1579       Most of these options are quite specific and in general the default
1580       comment behaviour will be all that you need. However, should you need
1581       greater control over the format of the cell comment the following
1582       options are available:
1583
1584           encoding
1585           author
1586           author_encoding
1587           visible
1588           x_scale
1589           width
1590           y_scale
1591           height
1592           color
1593           start_cell
1594           start_row
1595           start_col
1596           x_offset
1597           y_offset
1598
1599       Option: encoding
1600           This option is used to indicate that the comment string is encoded
1601           as "UTF-16BE".
1602
1603               my $comment = pack 'n', 0x263a; # UTF-16BE Smiley symbol
1604
1605               $worksheet->write_comment('C3', $comment, encoding => 1);
1606
1607           If you wish to use Unicode characters in the comment string then
1608           the preferred method is to use perl 5.8 and "UTF-8" strings, see
1609           "UNICODE IN EXCEL".
1610
1611       Option: author
1612           This option is used to indicate who the author of the comment is.
1613           Excel displays the author of the comment in the status bar at the
1614           bottom of the worksheet. This is usually of interest in corporate
1615           environments where several people might review and provide comments
1616           to a workbook.
1617
1618               $worksheet->write_comment('C3', 'Atonement', author => 'Ian McEwan');
1619
1620       Option: author_encoding
1621           This option is used to indicate that the author string is encoded
1622           as "UTF-16BE".
1623
1624       Option: visible
1625           This option is used to make a cell comment visible when the
1626           worksheet is opened. The default behaviour in Excel is that
1627           comments are initially hidden. However, it is also possible in
1628           Excel to make individual or all comments visible. In
1629           Spreadsheet::WriteExcel individual comments can be made visible as
1630           follows:
1631
1632               $worksheet->write_comment('C3', 'Hello', visible => 1);
1633
1634           It is possible to make all comments in a worksheet visible using
1635           the "show_comments()" worksheet method (see below). Alternatively,
1636           if all of the cell comments have been made visible you can hide
1637           individual comments:
1638
1639               $worksheet->write_comment('C3', 'Hello', visible => 0);
1640
1641       Option: x_scale
1642           This option is used to set the width of the cell comment box as a
1643           factor of the default width.
1644
1645               $worksheet->write_comment('C3', 'Hello', x_scale => 2);
1646               $worksheet->write_comment('C4', 'Hello', x_scale => 4.2);
1647
1648       Option: width
1649           This option is used to set the width of the cell comment box
1650           explicitly in pixels.
1651
1652               $worksheet->write_comment('C3', 'Hello', width => 200);
1653
1654       Option: y_scale
1655           This option is used to set the height of the cell comment box as a
1656           factor of the default height.
1657
1658               $worksheet->write_comment('C3', 'Hello', y_scale => 2);
1659               $worksheet->write_comment('C4', 'Hello', y_scale => 4.2);
1660
1661       Option: height
1662           This option is used to set the height of the cell comment box
1663           explicitly in pixels.
1664
1665               $worksheet->write_comment('C3', 'Hello', height => 200);
1666
1667       Option: color
1668           This option is used to set the background colour of cell comment
1669           box. You can use one of the named colours recognised by
1670           Spreadsheet::WriteExcel or a colour index. See "COLOURS IN EXCEL".
1671
1672               $worksheet->write_comment('C3', 'Hello', color => 'green');
1673               $worksheet->write_comment('C4', 'Hello', color => 0x35);    # Orange
1674
1675       Option: start_cell
1676           This option is used to set the cell in which the comment will
1677           appear. By default Excel displays comments one cell to the right
1678           and one cell above the cell to which the comment relates. However,
1679           you can change this behaviour if you wish. In the following example
1680           the comment which would appear by default in cell "D2" is moved to
1681           "E2".
1682
1683               $worksheet->write_comment('C3', 'Hello', start_cell => 'E2');
1684
1685       Option: start_row
1686           This option is used to set the row in which the comment will
1687           appear. See the "start_cell" option above. The row is zero indexed.
1688
1689               $worksheet->write_comment('C3', 'Hello', start_row => 0);
1690
1691       Option: start_col
1692           This option is used to set the column in which the comment will
1693           appear. See the "start_cell" option above. The column is zero
1694           indexed.
1695
1696               $worksheet->write_comment('C3', 'Hello', start_col => 4);
1697
1698       Option: x_offset
1699           This option is used to change the x offset, in pixels, of a comment
1700           within a cell:
1701
1702               $worksheet->write_comment('C3', $comment, x_offset => 30);
1703
1704       Option: y_offset
1705           This option is used to change the y offset, in pixels, of a comment
1706           within a cell:
1707
1708               $worksheet->write_comment('C3', $comment, x_offset => 30);
1709
1710       You can apply as many of these options as you require.
1711
1712       Note about row height and comments. If you specify the height of a row
1713       that contains a comment then Spreadsheet::WriteExcel will adjust the
1714       height of the comment to maintain the default or user specified
1715       dimensions. However, the height of a row can also be adjusted
1716       automatically by Excel if the text wrap property is set or large fonts
1717       are used in the cell. This means that the height of the row is unknown
1718       to WriteExcel at run time and thus the comment box is stretched with
1719       the row. Use the "set_row()" method to specify the row height
1720       explicitly and avoid this problem.
1721
1722   show_comments()
1723       This method is used to make all cell comments visible when a worksheet
1724       is opened.
1725
1726       Individual comments can be made visible using the "visible" parameter
1727       of the "write_comment" method (see above):
1728
1729           $worksheet->write_comment('C3', 'Hello', visible => 1);
1730
1731       If all of the cell comments have been made visible you can hide
1732       individual comments as follows:
1733
1734           $worksheet->write_comment('C3', 'Hello', visible => 0);
1735
1736   add_write_handler($re, $code_ref)
1737       This method is used to extend the Spreadsheet::WriteExcel write()
1738       method to handle user defined data.
1739
1740       If you refer to the section on "write()" above you will see that it
1741       acts as an alias for several more specific "write_*" methods. However,
1742       it doesn't always act in exactly the way that you would like it to.
1743
1744       One solution is to filter the input data yourself and call the
1745       appropriate "write_*" method. Another approach is to use the
1746       "add_write_handler()" method to add your own automated behaviour to
1747       "write()".
1748
1749       The "add_write_handler()" method take two arguments, $re, a regular
1750       expression to match incoming data and $code_ref a callback function to
1751       handle the matched data:
1752
1753           $worksheet->add_write_handler(qr/^\d\d\d\d$/, \&my_write);
1754
1755       (In the these examples the "qr" operator is used to quote the regular
1756       expression strings, see perlop for more details).
1757
1758       The method is used as follows. say you wished to write 7 digit ID
1759       numbers as a string so that any leading zeros were preserved*, you
1760       could do something like the following:
1761
1762           $worksheet->add_write_handler(qr/^\d{7}$/, \&write_my_id);
1763
1764
1765           sub write_my_id {
1766               my $worksheet = shift;
1767               return $worksheet->write_string(@_);
1768           }
1769
1770       * You could also use the "keep_leading_zeros()" method for this.
1771
1772       Then if you call "write()" with an appropriate string it will be
1773       handled automatically:
1774
1775           # Writes 0000000. It would normally be written as a number; 0.
1776           $worksheet->write('A1', '0000000');
1777
1778       The callback function will receive a reference to the calling worksheet
1779       and all of the other arguments that were passed to "write()". The
1780       callback will see an @_ argument list that looks like the following:
1781
1782           $_[0]   A ref to the calling worksheet. *
1783           $_[1]   Zero based row number.
1784           $_[2]   Zero based column number.
1785           $_[3]   A number or string or token.
1786           $_[4]   A format ref if any.
1787           $_[5]   Any other arguments.
1788           ...
1789
1790           *  It is good style to shift this off the list so the @_ is the same
1791              as the argument list seen by write().
1792
1793       Your callback should "return()" the return value of the "write_*"
1794       method that was called or "undef" to indicate that you rejected the
1795       match and want "write()" to continue as normal.
1796
1797       So for example if you wished to apply the previous filter only to ID
1798       values that occur in the first column you could modify your callback
1799       function as follows:
1800
1801           sub write_my_id {
1802               my $worksheet = shift;
1803               my $col       = $_[1];
1804
1805               if ($col == 0) {
1806                   return $worksheet->write_string(@_);
1807               }
1808               else {
1809                   # Reject the match and return control to write()
1810                   return undef;
1811               }
1812           }
1813
1814       Now, you will get different behaviour for the first column and other
1815       columns:
1816
1817           $worksheet->write('A1', '0000000'); # Writes 0000000
1818           $worksheet->write('B1', '0000000'); # Writes 0
1819
1820       You may add more than one handler in which case they will be called in
1821       the order that they were added.
1822
1823       Note, the "add_write_handler()" method is particularly suited for
1824       handling dates.
1825
1826       See the "write_handler 1-4" programs in the "examples" directory for
1827       further examples.
1828
1829   insert_image($row, $col, $filename, $x, $y, $scale_x, $scale_y)
1830       This method can be used to insert a image into a worksheet. The image
1831       can be in PNG, JPEG or BMP format. The $x, $y, $scale_x and $scale_y
1832       parameters are optional.
1833
1834           $worksheet1->insert_image('A1', 'perl.bmp');
1835           $worksheet2->insert_image('A1', '../images/perl.bmp');
1836           $worksheet3->insert_image('A1', '.c:\images\perl.bmp');
1837
1838       The parameters $x and $y can be used to specify an offset from the top
1839       left hand corner of the cell specified by $row and $col. The offset
1840       values are in pixels.
1841
1842           $worksheet1->insert_image('A1', 'perl.bmp', 32, 10);
1843
1844       The default width of a cell is 63 pixels. The default height of a cell
1845       is 17 pixels. The pixels offsets can be calculated using the following
1846       relationships:
1847
1848           Wp = int(12We)   if We <  1
1849           Wp = int(7We +5) if We >= 1
1850           Hp = int(4/3He)
1851
1852           where:
1853           We is the cell width in Excels units
1854           Wp is width in pixels
1855           He is the cell height in Excels units
1856           Hp is height in pixels
1857
1858       The offsets can be greater than the width or height of the underlying
1859       cell. This can be occasionally useful if you wish to align two or more
1860       images relative to the same cell.
1861
1862       The parameters $scale_x and $scale_y can be used to scale the inserted
1863       image horizontally and vertically:
1864
1865           # Scale the inserted image: width x 2.0, height x 0.8
1866           $worksheet->insert_image('A1', 'perl.bmp', 0, 0, 2, 0.8);
1867
1868       See also the "images.pl" program in the "examples" directory of the
1869       distro.
1870
1871       Note: you must call "set_row()" or "set_column()" before
1872       "insert_image()" if you wish to change the default dimensions of any of
1873       the rows or columns that the image occupies. The height of a row can
1874       also change if you use a font that is larger than the default. This in
1875       turn will affect the scaling of your image. To avoid this you should
1876       explicitly set the height of the row using "set_row()" if it contains a
1877       font size that will change the row height.
1878
1879       BMP images must be 24 bit, true colour, bitmaps. In general it is best
1880       to avoid BMP images since they aren't compressed. The older
1881       "insert_bitmap()" method is still supported but deprecated.
1882
1883   insert_chart($row, $col, $chart, $x, $y, $scale_x, $scale_y)
1884       This method can be used to insert a Chart object into a worksheet. The
1885       Chart must be created by the "add_chart()" Workbook method  and it must
1886       have the "embedded" option set.
1887
1888           my $chart = $workbook->add_chart( type => 'line', embedded => 1 );
1889
1890           # Configure the chart.
1891           ...
1892
1893           # Insert the chart into the a worksheet.
1894           $worksheet->insert_chart('E2', $chart);
1895
1896       See "add_chart()" for details on how to create the Chart object and
1897       Spreadsheet::WriteExcel::Chart for details on how to configure it. See
1898       also the "chart_*.pl" programs in the examples directory of the distro.
1899
1900       The $x, $y, $scale_x and $scale_y parameters are optional.
1901
1902       The parameters $x and $y can be used to specify an offset from the top
1903       left hand corner of the cell specified by $row and $col. The offset
1904       values are in pixels. See the "insert_image" method above for more
1905       information on sizes.
1906
1907           $worksheet1->insert_chart('E2', $chart, 3, 3);
1908
1909       The parameters $scale_x and $scale_y can be used to scale the inserted
1910       image horizontally and vertically:
1911
1912           # Scale the width by 120% and the height by 150%
1913           $worksheet->insert_chart('E2', $chart, 0, 0, 1.2, 1.5);
1914
1915       The easiest way to calculate the required scaling is to create a test
1916       chart worksheet with Spreadsheet::WriteExcel. Then open the file,
1917       select the chart and drag the corner to get the required size. While
1918       holding down the mouse the scale of the resized chart is shown to the
1919       left of the formula bar.
1920
1921       Note: you must call "set_row()" or "set_column()" before
1922       "insert_chart()" if you wish to change the default dimensions of any of
1923       the rows or columns that the chart occupies. The height of a row can
1924       also change if you use a font that is larger than the default. This in
1925       turn will affect the scaling of your chart. To avoid this you should
1926       explicitly set the height of the row using "set_row()" if it contains a
1927       font size that will change the row height.
1928
1929   embed_chart($row, $col, $filename, $x, $y, $scale_x, $scale_y)
1930       This method can be used to insert a externally generated chart into a
1931       worksheet. The chart must first be extracted from an existing Excel
1932       file. This feature is semi-deprecated in favour of the "native" charts
1933       created using "add_chart()". Read "external_charts.txt" (or ".pod") in
1934       the external_charts directory of the distro for a full explanation.
1935
1936       Here is an example:
1937
1938           $worksheet->embed_chart('B2', 'sales_chart.bin');
1939
1940       The $x, $y, $scale_x and $scale_y parameters are optional. See
1941       "insert_chart()" above for details.
1942
1943   data_validation()
1944       The "data_validation()" method is used to construct an Excel data
1945       validation or to limit the user input to a dropdown list of values.
1946
1947           $worksheet->data_validation('B3',
1948               {
1949                   validate => 'integer',
1950                   criteria => '>',
1951                   value    => 100,
1952               });
1953
1954           $worksheet->data_validation('B5:B9',
1955               {
1956                   validate => 'list',
1957                   value    => ['open', 'high', 'close'],
1958               });
1959
1960       This method contains a lot of parameters and is described in detail in
1961       a separate section "DATA VALIDATION IN EXCEL".
1962
1963       See also the "data_validate.pl" program in the examples directory of
1964       the distro
1965
1966   get_name()
1967       The "get_name()" method is used to retrieve the name of a worksheet.
1968       For example:
1969
1970           foreach my $sheet ($workbook->sheets()) {
1971               print $sheet->get_name();
1972           }
1973
1974       For reasons related to the design of Spreadsheet::WriteExcel and to the
1975       internals of Excel there is no "set_name()" method. The only way to set
1976       the worksheet name is via the "add_worksheet()" method.
1977
1978   activate()
1979       The "activate()" method is used to specify which worksheet is initially
1980       visible in a multi-sheet workbook:
1981
1982           $worksheet1 = $workbook->add_worksheet('To');
1983           $worksheet2 = $workbook->add_worksheet('the');
1984           $worksheet3 = $workbook->add_worksheet('wind');
1985
1986           $worksheet3->activate();
1987
1988       This is similar to the Excel VBA activate method. More than one
1989       worksheet can be selected via the "select()" method, see below, however
1990       only one worksheet can be active.
1991
1992       The default active worksheet is the first worksheet.
1993
1994   select()
1995       The "select()" method is used to indicate that a worksheet is selected
1996       in a multi-sheet workbook:
1997
1998           $worksheet1->activate();
1999           $worksheet2->select();
2000           $worksheet3->select();
2001
2002       A selected worksheet has its tab highlighted. Selecting worksheets is a
2003       way of grouping them together so that, for example, several worksheets
2004       could be printed in one go. A worksheet that has been activated via the
2005       "activate()" method will also appear as selected.
2006
2007   hide()
2008       The "hide()" method is used to hide a worksheet:
2009
2010           $worksheet2->hide();
2011
2012       You may wish to hide a worksheet in order to avoid confusing a user
2013       with intermediate data or calculations.
2014
2015       A hidden worksheet can not be activated or selected so this method is
2016       mutually exclusive with the "activate()" and "select()" methods. In
2017       addition, since the first worksheet will default to being the active
2018       worksheet, you cannot hide the first worksheet without activating
2019       another sheet:
2020
2021           $worksheet2->activate();
2022           $worksheet1->hide();
2023
2024   set_first_sheet()
2025       The "activate()" method determines which worksheet is initially
2026       selected. However, if there are a large number of worksheets the
2027       selected worksheet may not appear on the screen. To avoid this you can
2028       select which is the leftmost visible worksheet using
2029       "set_first_sheet()":
2030
2031           for (1..20) {
2032               $workbook->add_worksheet;
2033           }
2034
2035           $worksheet21 = $workbook->add_worksheet();
2036           $worksheet22 = $workbook->add_worksheet();
2037
2038           $worksheet21->set_first_sheet();
2039           $worksheet22->activate();
2040
2041       This method is not required very often. The default value is the first
2042       worksheet.
2043
2044   protect($password)
2045       The "protect()" method is used to protect a worksheet from
2046       modification:
2047
2048           $worksheet->protect();
2049
2050       It can be turned off in Excel via the "Tools->Protection->Unprotect
2051       Sheet" menu command.
2052
2053       The "protect()" method also has the effect of enabling a cell's
2054       "locked" and "hidden" properties if they have been set. A "locked" cell
2055       cannot be edited. A "hidden" cell will display the results of a formula
2056       but not the formula itself. In Excel a cell's locked property is on by
2057       default.
2058
2059           # Set some format properties
2060           my $unlocked  = $workbook->add_format(locked => 0);
2061           my $hidden    = $workbook->add_format(hidden => 1);
2062
2063           # Enable worksheet protection
2064           $worksheet->protect();
2065
2066           # This cell cannot be edited, it is locked by default
2067           $worksheet->write('A1', '=1+2');
2068
2069           # This cell can be edited
2070           $worksheet->write('A2', '=1+2', $unlocked);
2071
2072           # The formula in this cell isn't visible
2073           $worksheet->write('A3', '=1+2', $hidden);
2074
2075       See also the "set_locked" and "set_hidden" format methods in "CELL
2076       FORMATTING".
2077
2078       You can optionally add a password to the worksheet protection:
2079
2080           $worksheet->protect('drowssap');
2081
2082       Note, the worksheet level password in Excel provides very weak
2083       protection. It does not encrypt your data in any way and it is very
2084       easy to deactivate. Therefore, do not use the above method if you wish
2085       to protect sensitive data or calculations. However, before you get
2086       worried, Excel's own workbook level password protection does provide
2087       strong encryption in Excel 97+. For technical reasons this will never
2088       be supported by "Spreadsheet::WriteExcel".
2089
2090   set_selection($first_row, $first_col, $last_row, $last_col)
2091       This method can be used to specify which cell or cells are selected in
2092       a worksheet. The most common requirement is to select a single cell, in
2093       which case $last_row and $last_col can be omitted. The active cell
2094       within a selected range is determined by the order in which $first and
2095       $last are specified. It is also possible to specify a cell or a range
2096       using A1 notation. See the note about "Cell notation".
2097
2098       Examples:
2099
2100           $worksheet1->set_selection(3, 3);       # 1. Cell D4.
2101           $worksheet2->set_selection(3, 3, 6, 6); # 2. Cells D4 to G7.
2102           $worksheet3->set_selection(6, 6, 3, 3); # 3. Cells G7 to D4.
2103           $worksheet4->set_selection('D4');       # Same as 1.
2104           $worksheet5->set_selection('D4:G7');    # Same as 2.
2105           $worksheet6->set_selection('G7:D4');    # Same as 3.
2106
2107       The default cell selections is (0, 0), 'A1'.
2108
2109   set_row($row, $height, $format, $hidden, $level, $collapsed)
2110       This method can be used to change the default properties of a row. All
2111       parameters apart from $row are optional.
2112
2113       The most common use for this method is to change the height of a row:
2114
2115           $worksheet->set_row(0, 20); # Row 1 height set to 20
2116
2117       If you wish to set the format without changing the height you can pass
2118       "undef" as the height parameter:
2119
2120           $worksheet->set_row(0, undef, $format);
2121
2122       The $format parameter will be applied to any cells in the row that
2123       don't  have a format. For example
2124
2125           $worksheet->set_row(0, undef, $format1);    # Set the format for row 1
2126           $worksheet->write('A1', 'Hello');           # Defaults to $format1
2127           $worksheet->write('B1', 'Hello', $format2); # Keeps $format2
2128
2129       If you wish to define a row format in this way you should call the
2130       method before any calls to "write()". Calling it afterwards will
2131       overwrite any format that was previously specified.
2132
2133       The $hidden parameter should be set to 1 if you wish to hide a row.
2134       This can be used, for example, to hide intermediary steps in a
2135       complicated calculation:
2136
2137           $worksheet->set_row(0, 20,    $format, 1);
2138           $worksheet->set_row(1, undef, undef,   1);
2139
2140       The $level parameter is used to set the outline level of the row.
2141       Outlines are described in "OUTLINES AND GROUPING IN EXCEL". Adjacent
2142       rows with the same outline level are grouped together into a single
2143       outline.
2144
2145       The following example sets an outline level of 1 for rows 1 and 2
2146       (zero-indexed):
2147
2148           $worksheet->set_row(1, undef, undef, 0, 1);
2149           $worksheet->set_row(2, undef, undef, 0, 1);
2150
2151       The $hidden parameter can also be used to hide collapsed outlined rows
2152       when used in conjunction with the $level parameter.
2153
2154           $worksheet->set_row(1, undef, undef, 1, 1);
2155           $worksheet->set_row(2, undef, undef, 1, 1);
2156
2157       For collapsed outlines you should also indicate which row has the
2158       collapsed "+" symbol using the optional $collapsed parameter.
2159
2160           $worksheet->set_row(3, undef, undef, 0, 0, 1);
2161
2162       For a more complete example see the "outline.pl" and
2163       "outline_collapsed.pl" programs in the examples directory of the
2164       distro.
2165
2166       Excel allows up to 7 outline levels. Therefore the $level parameter
2167       should be in the range "0 <= $level <= 7".
2168
2169   set_column($first_col, $last_col, $width, $format, $hidden, $level,
2170       $collapsed)
2171       This method can be used to change the default properties of a single
2172       column or a range of columns. All parameters apart from $first_col and
2173       $last_col are optional.
2174
2175       If "set_column()" is applied to a single column the value of $first_col
2176       and $last_col should be the same. In the case where $last_col is zero
2177       it is set to the same value as $first_col.
2178
2179       It is also possible, and generally clearer, to specify a column range
2180       using the form of A1 notation used for columns. See the note about
2181       "Cell notation".
2182
2183       Examples:
2184
2185           $worksheet->set_column(0, 0,  20); # Column  A   width set to 20
2186           $worksheet->set_column(1, 3,  30); # Columns B-D width set to 30
2187           $worksheet->set_column('E:E', 20); # Column  E   width set to 20
2188           $worksheet->set_column('F:H', 30); # Columns F-H width set to 30
2189
2190       The width corresponds to the column width value that is specified in
2191       Excel. It is approximately equal to the length of a string in the
2192       default font of Arial 10. Unfortunately, there is no way to specify
2193       "AutoFit" for a column in the Excel file format. This feature is only
2194       available at runtime from within Excel.
2195
2196       As usual the $format parameter is optional, for additional information,
2197       see "CELL FORMATTING". If you wish to set the format without changing
2198       the width you can pass "undef" as the width parameter:
2199
2200           $worksheet->set_column(0, 0, undef, $format);
2201
2202       The $format parameter will be applied to any cells in the column that
2203       don't  have a format. For example
2204
2205           $worksheet->set_column('A:A', undef, $format1); # Set format for col 1
2206           $worksheet->write('A1', 'Hello');               # Defaults to $format1
2207           $worksheet->write('A2', 'Hello', $format2);     # Keeps $format2
2208
2209       If you wish to define a column format in this way you should call the
2210       method before any calls to "write()". If you call it afterwards it
2211       won't have any effect.
2212
2213       A default row format takes precedence over a default column format
2214
2215           $worksheet->set_row(0, undef,        $format1); # Set format for row 1
2216           $worksheet->set_column('A:A', undef, $format2); # Set format for col 1
2217           $worksheet->write('A1', 'Hello');               # Defaults to $format1
2218           $worksheet->write('A2', 'Hello');               # Defaults to $format2
2219
2220       The $hidden parameter should be set to 1 if you wish to hide a column.
2221       This can be used, for example, to hide intermediary steps in a
2222       complicated calculation:
2223
2224           $worksheet->set_column('D:D', 20,    $format, 1);
2225           $worksheet->set_column('E:E', undef, undef,   1);
2226
2227       The $level parameter is used to set the outline level of the column.
2228       Outlines are described in "OUTLINES AND GROUPING IN EXCEL". Adjacent
2229       columns with the same outline level are grouped together into a single
2230       outline.
2231
2232       The following example sets an outline level of 1 for columns B to G:
2233
2234           $worksheet->set_column('B:G', undef, undef, 0, 1);
2235
2236       The $hidden parameter can also be used to hide collapsed outlined
2237       columns when used in conjunction with the $level parameter.
2238
2239           $worksheet->set_column('B:G', undef, undef, 1, 1);
2240
2241       For collapsed outlines you should also indicate which row has the
2242       collapsed "+" symbol using the optional $collapsed parameter.
2243
2244           $worksheet->set_column('H:H', undef, undef, 0, 0, 1);
2245
2246       For a more complete example see the "outline.pl" and
2247       "outline_collapsed.pl" programs in the examples directory of the
2248       distro.
2249
2250       Excel allows up to 7 outline levels. Therefore the $level parameter
2251       should be in the range "0 <= $level <= 7".
2252
2253   outline_settings($visible, $symbols_below, $symbols_right, $auto_style)
2254       The "outline_settings()" method is used to control the appearance of
2255       outlines in Excel. Outlines are described in "OUTLINES AND GROUPING IN
2256       EXCEL".
2257
2258       The $visible parameter is used to control whether or not outlines are
2259       visible. Setting this parameter to 0 will cause all outlines on the
2260       worksheet to be hidden. They can be unhidden in Excel by means of the
2261       "Show Outline Symbols" command button. The default setting is 1 for
2262       visible outlines.
2263
2264           $worksheet->outline_settings(0);
2265
2266       The $symbols_below parameter is used to control whether the row outline
2267       symbol will appear above or below the outline level bar. The default
2268       setting is 1 for symbols to appear below the outline level bar.
2269
2270       The "symbols_right" parameter is used to control whether the column
2271       outline symbol will appear to the left or the right of the outline
2272       level bar. The default setting is 1 for symbols to appear to the right
2273       of the outline level bar.
2274
2275       The $auto_style parameter is used to control whether the automatic
2276       outline generator in Excel uses automatic styles when creating an
2277       outline. This has no effect on a file generated by
2278       "Spreadsheet::WriteExcel" but it does have an effect on how the
2279       worksheet behaves after it is created. The default setting is 0 for
2280       "Automatic Styles" to be turned off.
2281
2282       The default settings for all of these parameters correspond to Excel's
2283       default parameters.
2284
2285       The worksheet parameters controlled by "outline_settings()" are rarely
2286       used.
2287
2288   freeze_panes($row, $col, $top_row, $left_col)
2289       This method can be used to divide a worksheet into horizontal or
2290       vertical regions known as panes and to also "freeze" these panes so
2291       that the splitter bars are not visible. This is the same as the
2292       "Window->Freeze Panes" menu command in Excel
2293
2294       The parameters $row and $col are used to specify the location of the
2295       split. It should be noted that the split is specified at the top or
2296       left of a cell and that the method uses zero based indexing. Therefore
2297       to freeze the first row of a worksheet it is necessary to specify the
2298       split at row 2 (which is 1 as the zero-based index). This might lead
2299       you to think that you are using a 1 based index but this is not the
2300       case.
2301
2302       You can set one of the $row and $col parameters as zero if you do not
2303       want either a vertical or horizontal split.
2304
2305       Examples:
2306
2307           $worksheet->freeze_panes(1, 0); # Freeze the first row
2308           $worksheet->freeze_panes('A2'); # Same using A1 notation
2309           $worksheet->freeze_panes(0, 1); # Freeze the first column
2310           $worksheet->freeze_panes('B1'); # Same using A1 notation
2311           $worksheet->freeze_panes(1, 2); # Freeze first row and first 2 columns
2312           $worksheet->freeze_panes('C2'); # Same using A1 notation
2313
2314       The parameters $top_row and $left_col are optional. They are used to
2315       specify the top-most or left-most visible row or column in the
2316       scrolling region of the panes. For example to freeze the first row and
2317       to have the scrolling region begin at row twenty:
2318
2319           $worksheet->freeze_panes(1, 0, 20, 0);
2320
2321       You cannot use A1 notation for the $top_row and $left_col parameters.
2322
2323       See also the "panes.pl" program in the "examples" directory of the
2324       distribution.
2325
2326   split_panes($y, $x, $top_row, $left_col)
2327       This method can be used to divide a worksheet into horizontal or
2328       vertical regions known as panes. This method is different from the
2329       "freeze_panes()" method in that the splits between the panes will be
2330       visible to the user and each pane will have its own scroll bars.
2331
2332       The parameters $y and $x are used to specify the vertical and
2333       horizontal position of the split. The units for $y and $x are the same
2334       as those used by Excel to specify row height and column width. However,
2335       the vertical and horizontal units are different from each other.
2336       Therefore you must specify the $y and $x parameters in terms of the row
2337       heights and column widths that you have set or the default values which
2338       are 12.75 for a row and  8.43 for a column.
2339
2340       You can set one of the $y and $x parameters as zero if you do not want
2341       either a vertical or horizontal split. The parameters $top_row and
2342       $left_col are optional. They are used to specify the top-most or left-
2343       most visible row or column in the bottom-right pane.
2344
2345       Example:
2346
2347           $worksheet->split_panes(12.75, 0,    1, 0); # First row
2348           $worksheet->split_panes(0,     8.43, 0, 1); # First column
2349           $worksheet->split_panes(12.75, 8.43, 1, 1); # First row and column
2350
2351       You cannot use A1 notation with this method.
2352
2353       See also the "freeze_panes()" method and the "panes.pl" program in the
2354       "examples" directory of the distribution.
2355
2356       Note: This "split_panes()" method was called "thaw_panes()" in older
2357       versions. The older name is still available for backwards
2358       compatibility.
2359
2360   merge_range($first_row, $first_col, $last_row, $last_col, $token, $format,
2361       $utf_16_be)
2362       Merging cells can be achieved by setting the "merge" property of a
2363       Format object, see "CELL FORMATTING". However, this only allows simple
2364       Excel5 style horizontal merging which Excel refers to as "center across
2365       selection".
2366
2367       The "merge_range()" method allows you to do Excel97+ style formatting
2368       where the cells can contain other types of alignment in addition to the
2369       merging:
2370
2371           my $format = $workbook->add_format(
2372                                               border  => 6,
2373                                               valign  => 'vcenter',
2374                                               align   => 'center',
2375                                             );
2376
2377           $worksheet->merge_range('B3:D4', 'Vertical and horizontal', $format);
2378
2379       WARNING. The format object that is used with a "merge_range()" method
2380       call is marked internally as being associated with a merged range. It
2381       is a fatal error to use a merged format in a non-merged cell. Instead
2382       you should use separate formats for merged and non-merged cells. This
2383       restriction will be removed in a future release.
2384
2385       The $utf_16_be parameter is optional, see below.
2386
2387       "merge_range()" writes its $token argument using the worksheet
2388       "write()" method. Therefore it will handle numbers, strings, formulas
2389       or urls as required.
2390
2391       Setting the "merge" property of the format isn't required when you are
2392       using "merge_range()". In fact using it will exclude the use of any
2393       other horizontal alignment option.
2394
2395       On systems with "perl 5.8" and later the "merge_range()" method will
2396       also handle strings in "UTF-8" format.
2397
2398           $worksheet->merge_range('B3:D4', "\x{263a}", $format); # Smiley
2399
2400       On earlier Perl systems your can specify "UTF-16BE" worksheet names
2401       using an additional optional parameter:
2402
2403           my $str = pack 'n', 0x263a;
2404           $worksheet->merge_range('B3:D4', $str, $format, 1); # Smiley
2405
2406       The full possibilities of this method are shown in the "merge3.pl" to
2407       "merge6.pl" programs in the "examples" directory of the distribution.
2408
2409   set_zoom($scale)
2410       Set the worksheet zoom factor in the range "10 <= $scale <= 400":
2411
2412           $worksheet1->set_zoom(50);
2413           $worksheet2->set_zoom(75);
2414           $worksheet3->set_zoom(300);
2415           $worksheet4->set_zoom(400);
2416
2417       The default zoom factor is 100. You cannot zoom to "Selection" because
2418       it is calculated by Excel at run-time.
2419
2420       Note, "set_zoom()" does not affect the scale of the printed page. For
2421       that you should use "set_print_scale()".
2422
2423   right_to_left()
2424       The "right_to_left()" method is used to change the default direction of
2425       the worksheet from left-to-right, with the A1 cell in the top left, to
2426       right-to-left, with the he A1 cell in the top right.
2427
2428           $worksheet->right_to_left();
2429
2430       This is useful when creating Arabic, Hebrew or other near or far
2431       eastern worksheets that use right-to-left as the default direction.
2432
2433   hide_zero()
2434       The "hide_zero()" method is used to hide any zero values that appear in
2435       cells.
2436
2437           $worksheet->hide_zero();
2438
2439       In Excel this option is found under Tools->Options->View.
2440
2441   set_tab_color()
2442       The "set_tab_color()" method is used to change the colour of the
2443       worksheet tab. This feature is only available in Excel 2002 and later.
2444       You can use one of the standard colour names provided by the Format
2445       object or a colour index. See "COLOURS IN EXCEL" and the
2446       "set_custom_color()" method.
2447
2448           $worksheet1->set_tab_color('red');
2449           $worksheet2->set_tab_color(0x0C);
2450
2451       See the "tab_colors.pl" program in the examples directory of the
2452       distro.
2453
2454   autofilter($first_row, $first_col, $last_row, $last_col)
2455       This method allows an autofilter to be added to a worksheet. An
2456       autofilter is a way of adding drop down lists to the headers of a 2D
2457       range of worksheet data. This is turn allow users to filter the data
2458       based on simple criteria so that some data is shown and some is hidden.
2459
2460       To add an autofilter to a worksheet:
2461
2462           $worksheet->autofilter(0, 0, 10, 3);
2463           $worksheet->autofilter('A1:D11');    # Same as above in A1 notation.
2464
2465       Filter conditions can be applied using the "filter_column()" method.
2466
2467       See the "autofilter.pl" program in the examples directory of the distro
2468       for a more detailed example.
2469
2470   filter_column($column, $expression)
2471       The "filter_column" method can be used to filter columns in a
2472       autofilter range based on simple conditions.
2473
2474       NOTE: It isn't sufficient to just specify the filter condition. You
2475       must also hide any rows that don't match the filter condition. Rows are
2476       hidden using the "set_row()" "visible" parameter.
2477       "Spreadsheet::WriteExcel" cannot do this automatically since it isn't
2478       part of the file format. See the "autofilter.pl" program in the
2479       examples directory of the distro for an example.
2480
2481       The conditions for the filter are specified using simple expressions:
2482
2483           $worksheet->filter_column('A', 'x > 2000');
2484           $worksheet->filter_column('B', 'x > 2000 and x < 5000');
2485
2486       The $column parameter can either be a zero indexed column number or a
2487       string column name.
2488
2489       The following operators are available:
2490
2491           Operator        Synonyms
2492              ==           =   eq  =~
2493              !=           <>  ne  !=
2494              >
2495              <
2496              >=
2497              <=
2498
2499              and          &&
2500              or           ||
2501
2502       The operator synonyms are just syntactic sugar to make you more
2503       comfortable using the expressions. It is important to remember that the
2504       expressions will be interpreted by Excel and not by perl.
2505
2506       An expression can comprise a single statement or two statements
2507       separated by the "and" and "or" operators. For example:
2508
2509           'x <  2000'
2510           'x >  2000'
2511           'x == 2000'
2512           'x >  2000 and x <  5000'
2513           'x == 2000 or  x == 5000'
2514
2515       Filtering of blank or non-blank data can be achieved by using a value
2516       of "Blanks" or "NonBlanks" in the expression:
2517
2518           'x == Blanks'
2519           'x == NonBlanks'
2520
2521       Top 10 style filters can be specified using a expression like the
2522       following:
2523
2524           Top|Bottom 1-500 Items|%
2525
2526       For example:
2527
2528           'Top    10 Items'
2529           'Bottom  5 Items'
2530           'Top    25 %'
2531           'Bottom 50 %'
2532
2533       Excel also allows some simple string matching operations:
2534
2535           'x =~ b*'   # begins with b
2536           'x !~ b*'   # doesn't begin with b
2537           'x =~ *b'   # ends with b
2538           'x !~ *b'   # doesn't end with b
2539           'x =~ *b*'  # contains b
2540           'x !~ *b*'  # doesn't contains b
2541
2542       You can also use "*" to match any character or number and "?" to match
2543       any single character or number. No other regular expression quantifier
2544       is supported by Excel's filters. Excel's regular expression characters
2545       can be escaped using "~".
2546
2547       The placeholder variable "x" in the above examples can be replaced by
2548       any simple string. The actual placeholder name is ignored internally so
2549       the following are all equivalent:
2550
2551           'x     < 2000'
2552           'col   < 2000'
2553           'Price < 2000'
2554
2555       Also, note that a filter condition can only be applied to a column in a
2556       range specified by the "autofilter()" Worksheet method.
2557
2558       See the "autofilter.pl" program in the examples directory of the distro
2559       for a more detailed example.
2560

PAGE SET-UP METHODS

2562       Page set-up methods affect the way that a worksheet looks when it is
2563       printed. They control features such as page headers and footers and
2564       margins. These methods are really just standard worksheet methods. They
2565       are documented here in a separate section for the sake of clarity.
2566
2567       The following methods are available for page set-up:
2568
2569           set_landscape()
2570           set_portrait()
2571           set_page_view()
2572           set_paper()
2573           center_horizontally()
2574           center_vertically()
2575           set_margins()
2576           set_header()
2577           set_footer()
2578           repeat_rows()
2579           repeat_columns()
2580           hide_gridlines()
2581           print_row_col_headers()
2582           print_area()
2583           print_across()
2584           fit_to_pages()
2585           set_start_page()
2586           set_print_scale()
2587           set_h_pagebreaks()
2588           set_v_pagebreaks()
2589
2590       A common requirement when working with Spreadsheet::WriteExcel is to
2591       apply the same page set-up features to all of the worksheets in a
2592       workbook. To do this you can use the "sheets()" method of the
2593       "workbook" class to access the array of worksheets in a workbook:
2594
2595           foreach $worksheet ($workbook->sheets()) {
2596              $worksheet->set_landscape();
2597           }
2598
2599   set_landscape()
2600       This method is used to set the orientation of a worksheet's printed
2601       page to landscape:
2602
2603           $worksheet->set_landscape(); # Landscape mode
2604
2605   set_portrait()
2606       This method is used to set the orientation of a worksheet's printed
2607       page to portrait. The default worksheet orientation is portrait, so you
2608       won't generally need to call this method.
2609
2610           $worksheet->set_portrait(); # Portrait mode
2611
2612   set_page_view()
2613       This method is used to display the worksheet in "Page View" mode. This
2614       is currently only supported by Mac Excel, where it is the default.
2615
2616           $worksheet->set_page_view();
2617
2618   set_paper($index)
2619       This method is used to set the paper format for the printed output of a
2620       worksheet. The following paper styles are available:
2621
2622           Index   Paper format            Paper size
2623           =====   ============            ==========
2624             0     Printer default         -
2625             1     Letter                  8 1/2 x 11 in
2626             2     Letter Small            8 1/2 x 11 in
2627             3     Tabloid                 11 x 17 in
2628             4     Ledger                  17 x 11 in
2629             5     Legal                   8 1/2 x 14 in
2630             6     Statement               5 1/2 x 8 1/2 in
2631             7     Executive               7 1/4 x 10 1/2 in
2632             8     A3                      297 x 420 mm
2633             9     A4                      210 x 297 mm
2634            10     A4 Small                210 x 297 mm
2635            11     A5                      148 x 210 mm
2636            12     B4                      250 x 354 mm
2637            13     B5                      182 x 257 mm
2638            14     Folio                   8 1/2 x 13 in
2639            15     Quarto                  215 x 275 mm
2640            16     -                       10x14 in
2641            17     -                       11x17 in
2642            18     Note                    8 1/2 x 11 in
2643            19     Envelope  9             3 7/8 x 8 7/8
2644            20     Envelope 10             4 1/8 x 9 1/2
2645            21     Envelope 11             4 1/2 x 10 3/8
2646            22     Envelope 12             4 3/4 x 11
2647            23     Envelope 14             5 x 11 1/2
2648            24     C size sheet            -
2649            25     D size sheet            -
2650            26     E size sheet            -
2651            27     Envelope DL             110 x 220 mm
2652            28     Envelope C3             324 x 458 mm
2653            29     Envelope C4             229 x 324 mm
2654            30     Envelope C5             162 x 229 mm
2655            31     Envelope C6             114 x 162 mm
2656            32     Envelope C65            114 x 229 mm
2657            33     Envelope B4             250 x 353 mm
2658            34     Envelope B5             176 x 250 mm
2659            35     Envelope B6             176 x 125 mm
2660            36     Envelope                110 x 230 mm
2661            37     Monarch                 3.875 x 7.5 in
2662            38     Envelope                3 5/8 x 6 1/2 in
2663            39     Fanfold                 14 7/8 x 11 in
2664            40     German Std Fanfold      8 1/2 x 12 in
2665            41     German Legal Fanfold    8 1/2 x 13 in
2666
2667       Note, it is likely that not all of these paper types will be available
2668       to the end user since it will depend on the paper formats that the
2669       user's printer supports. Therefore, it is best to stick to standard
2670       paper types.
2671
2672           $worksheet->set_paper(1); # US Letter
2673           $worksheet->set_paper(9); # A4
2674
2675       If you do not specify a paper type the worksheet will print using the
2676       printer's default paper.
2677
2678   center_horizontally()
2679       Center the worksheet data horizontally between the margins on the
2680       printed page:
2681
2682           $worksheet->center_horizontally();
2683
2684   center_vertically()
2685       Center the worksheet data vertically between the margins on the printed
2686       page:
2687
2688           $worksheet->center_vertically();
2689
2690   set_margins($inches)
2691       There are several methods available for setting the worksheet margins
2692       on the printed page:
2693
2694           set_margins()        # Set all margins to the same value
2695           set_margins_LR()     # Set left and right margins to the same value
2696           set_margins_TB()     # Set top and bottom margins to the same value
2697           set_margin_left();   # Set left margin
2698           set_margin_right();  # Set right margin
2699           set_margin_top();    # Set top margin
2700           set_margin_bottom(); # Set bottom margin
2701
2702       All of these methods take a distance in inches as a parameter. Note: 1
2703       inch = 25.4mm. ;-) The default left and right margin is 0.75 inch. The
2704       default top and bottom margin is 1.00 inch.
2705
2706   set_header($string, $margin)
2707       Headers and footers are generated using a $string which is a
2708       combination of plain text and control characters. The $margin parameter
2709       is optional.
2710
2711       The available control character are:
2712
2713           Control             Category            Description
2714           =======             ========            ===========
2715           &L                  Justification       Left
2716           &C                                      Center
2717           &R                                      Right
2718
2719           &P                  Information         Page number
2720           &N                                      Total number of pages
2721           &D                                      Date
2722           &T                                      Time
2723           &F                                      File name
2724           &A                                      Worksheet name
2725           &Z                                      Workbook path
2726
2727           &fontsize           Font                Font size
2728           &"font,style"                           Font name and style
2729           &U                                      Single underline
2730           &E                                      Double underline
2731           &S                                      Strikethrough
2732           &X                                      Superscript
2733           &Y                                      Subscript
2734
2735           &&                  Miscellaneous       Literal ampersand &
2736
2737       Text in headers and footers can be justified (aligned) to the left,
2738       center and right by prefixing the text with the control characters &L,
2739       &C and &R.
2740
2741       For example (with ASCII art representation of the results):
2742
2743           $worksheet->set_header('&LHello');
2744
2745            ---------------------------------------------------------------
2746           |                                                               |
2747           | Hello                                                         |
2748           |                                                               |
2749
2750
2751           $worksheet->set_header('&CHello');
2752
2753            ---------------------------------------------------------------
2754           |                                                               |
2755           |                          Hello                                |
2756           |                                                               |
2757
2758
2759           $worksheet->set_header('&RHello');
2760
2761            ---------------------------------------------------------------
2762           |                                                               |
2763           |                                                         Hello |
2764           |                                                               |
2765
2766       For simple text, if you do not specify any justification the text will
2767       be centred. However, you must prefix the text with &C if you specify a
2768       font name or any other formatting:
2769
2770           $worksheet->set_header('Hello');
2771
2772            ---------------------------------------------------------------
2773           |                                                               |
2774           |                          Hello                                |
2775           |                                                               |
2776
2777       You can have text in each of the justification regions:
2778
2779           $worksheet->set_header('&LCiao&CBello&RCielo');
2780
2781            ---------------------------------------------------------------
2782           |                                                               |
2783           | Ciao                     Bello                          Cielo |
2784           |                                                               |
2785
2786       The information control characters act as variables that Excel will
2787       update as the workbook or worksheet changes. Times and dates are in the
2788       users default format:
2789
2790           $worksheet->set_header('&CPage &P of &N');
2791
2792            ---------------------------------------------------------------
2793           |                                                               |
2794           |                        Page 1 of 6                            |
2795           |                                                               |
2796
2797
2798           $worksheet->set_header('&CUpdated at &T');
2799
2800            ---------------------------------------------------------------
2801           |                                                               |
2802           |                    Updated at 12:30 PM                        |
2803           |                                                               |
2804
2805       You can specify the font size of a section of the text by prefixing it
2806       with the control character &n where "n" is the font size:
2807
2808           $worksheet1->set_header('&C&30Hello Big'  );
2809           $worksheet2->set_header('&C&10Hello Small');
2810
2811       You can specify the font of a section of the text by prefixing it with
2812       the control sequence "&"font,style"" where "fontname" is a font name
2813       such as "Courier New" or "Times New Roman" and "style" is one of the
2814       standard Windows font descriptions: "Regular", "Italic", "Bold" or
2815       "Bold Italic":
2816
2817           $worksheet1->set_header('&C&"Courier New,Italic"Hello');
2818           $worksheet2->set_header('&C&"Courier New,Bold Italic"Hello');
2819           $worksheet3->set_header('&C&"Times New Roman,Regular"Hello');
2820
2821       It is possible to combine all of these features together to create
2822       sophisticated headers and footers. As an aid to setting up complicated
2823       headers and footers you can record a page set-up as a macro in Excel
2824       and look at the format strings that VBA produces. Remember however that
2825       VBA uses two double quotes "" to indicate a single double quote. For
2826       the last example above the equivalent VBA code looks like this:
2827
2828           .LeftHeader   = ""
2829           .CenterHeader = "&""Times New Roman,Regular""Hello"
2830           .RightHeader  = ""
2831
2832       To include a single literal ampersand "&" in a header or footer you
2833       should use a double ampersand "&&":
2834
2835           $worksheet1->set_header('&CCuriouser && Curiouser - Attorneys at Law');
2836
2837       As stated above the margin parameter is optional. As with the other
2838       margins the value should be in inches. The default header and footer
2839       margin is 0.50 inch. The header and footer margin size can be set as
2840       follows:
2841
2842           $worksheet->set_header('&CHello', 0.75);
2843
2844       The header and footer margins are independent of the top and bottom
2845       margins.
2846
2847       Note, the header or footer string must be less than 255 characters.
2848       Strings longer than this will not be written and a warning will be
2849       generated.
2850
2851       On systems with "perl 5.8" and later the "set_header()" method can also
2852       handle Unicode strings in "UTF-8" format.
2853
2854           $worksheet->set_header("&C\x{263a}")
2855
2856       See, also the "headers.pl" program in the "examples" directory of the
2857       distribution.
2858
2859   set_footer()
2860       The syntax of the "set_footer()" method is the same as "set_header()",
2861       see above.
2862
2863   repeat_rows($first_row, $last_row)
2864       Set the number of rows to repeat at the top of each printed page.
2865
2866       For large Excel documents it is often desirable to have the first row
2867       or rows of the worksheet print out at the top of each page. This can be
2868       achieved by using the "repeat_rows()" method. The parameters $first_row
2869       and $last_row are zero based. The $last_row parameter is optional if
2870       you only wish to specify one row:
2871
2872           $worksheet1->repeat_rows(0);    # Repeat the first row
2873           $worksheet2->repeat_rows(0, 1); # Repeat the first two rows
2874
2875   repeat_columns($first_col, $last_col)
2876       Set the columns to repeat at the left hand side of each printed page.
2877
2878       For large Excel documents it is often desirable to have the first
2879       column or columns of the worksheet print out at the left hand side of
2880       each page. This can be achieved by using the "repeat_columns()" method.
2881       The parameters $first_column and $last_column are zero based. The
2882       $last_column parameter is optional if you only wish to specify one
2883       column. You can also specify the columns using A1 column notation, see
2884       the note about "Cell notation".
2885
2886           $worksheet1->repeat_columns(0);     # Repeat the first column
2887           $worksheet2->repeat_columns(0, 1);  # Repeat the first two columns
2888           $worksheet3->repeat_columns('A:A'); # Repeat the first column
2889           $worksheet4->repeat_columns('A:B'); # Repeat the first two columns
2890
2891   hide_gridlines($option)
2892       This method is used to hide the gridlines on the screen and printed
2893       page. Gridlines are the lines that divide the cells on a worksheet.
2894       Screen and printed gridlines are turned on by default in an Excel
2895       worksheet. If you have defined your own cell borders you may wish to
2896       hide the default gridlines.
2897
2898           $worksheet->hide_gridlines();
2899
2900       The following values of $option are valid:
2901
2902           0 : Don't hide gridlines
2903           1 : Hide printed gridlines only
2904           2 : Hide screen and printed gridlines
2905
2906       If you don't supply an argument or use "undef" the default option is 1,
2907       i.e. only the printed gridlines are hidden.
2908
2909   print_row_col_headers()
2910       Set the option to print the row and column headers on the printed page.
2911
2912       An Excel worksheet looks something like the following;
2913
2914            ------------------------------------------
2915           |   |   A   |   B   |   C   |   D   |  ...
2916            ------------------------------------------
2917           | 1 |       |       |       |       |  ...
2918           | 2 |       |       |       |       |  ...
2919           | 3 |       |       |       |       |  ...
2920           | 4 |       |       |       |       |  ...
2921           |...|  ...  |  ...  |  ...  |  ...  |  ...
2922
2923       The headers are the letters and numbers at the top and the left of the
2924       worksheet. Since these headers serve mainly as a indication of position
2925       on the worksheet they generally do not appear on the printed page. If
2926       you wish to have them printed you can use the "print_row_col_headers()"
2927       method :
2928
2929           $worksheet->print_row_col_headers();
2930
2931       Do not confuse these headers with page headers as described in the
2932       "set_header()" section above.
2933
2934   print_area($first_row, $first_col, $last_row, $last_col)
2935       This method is used to specify the area of the worksheet that will be
2936       printed. All four parameters must be specified. You can also use A1
2937       notation, see the note about "Cell notation".
2938
2939           $worksheet1->print_area('A1:H20');    # Cells A1 to H20
2940           $worksheet2->print_area(0, 0, 19, 7); # The same
2941           $worksheet2->print_area('A:H');       # Columns A to H if rows have data
2942
2943   print_across()
2944       The "print_across" method is used to change the default print
2945       direction. This is referred to by Excel as the sheet "page order".
2946
2947           $worksheet->print_across();
2948
2949       The default page order is shown below for a worksheet that extends over
2950       4 pages. The order is called "down then across":
2951
2952           [1] [3]
2953           [2] [4]
2954
2955       However, by using the "print_across" method the print order will be
2956       changed to "across then down":
2957
2958           [1] [2]
2959           [3] [4]
2960
2961   fit_to_pages($width, $height)
2962       The "fit_to_pages()" method is used to fit the printed area to a
2963       specific number of pages both vertically and horizontally. If the
2964       printed area exceeds the specified number of pages it will be scaled
2965       down to fit. This guarantees that the printed area will always appear
2966       on the specified number of pages even if the page size or margins
2967       change.
2968
2969           $worksheet1->fit_to_pages(1, 1); # Fit to 1x1 pages
2970           $worksheet2->fit_to_pages(2, 1); # Fit to 2x1 pages
2971           $worksheet3->fit_to_pages(1, 2); # Fit to 1x2 pages
2972
2973       The print area can be defined using the "print_area()" method as
2974       described above.
2975
2976       A common requirement is to fit the printed output to n pages wide but
2977       have the height be as long as necessary. To achieve this set the
2978       $height to zero or leave it blank:
2979
2980           $worksheet1->fit_to_pages(1, 0); # 1 page wide and as long as necessary
2981           $worksheet2->fit_to_pages(1);    # The same
2982
2983       Note that although it is valid to use both "fit_to_pages()" and
2984       "set_print_scale()" on the same worksheet only one of these options can
2985       be active at a time. The last method call made will set the active
2986       option.
2987
2988       Note that "fit_to_pages()" will override any manual page breaks that
2989       are defined in the worksheet.
2990
2991   set_start_page($start_page)
2992       The "set_start_page()" method is used to set the number of the starting
2993       page when the worksheet is printed out. The default value is 1.
2994
2995           $worksheet->set_start_page(2);
2996
2997   set_print_scale($scale)
2998       Set the scale factor of the printed page. Scale factors in the range
2999       "10 <= $scale <= 400" are valid:
3000
3001           $worksheet1->set_print_scale(50);
3002           $worksheet2->set_print_scale(75);
3003           $worksheet3->set_print_scale(300);
3004           $worksheet4->set_print_scale(400);
3005
3006       The default scale factor is 100. Note, "set_print_scale()" does not
3007       affect the scale of the visible page in Excel. For that you should use
3008       "set_zoom()".
3009
3010       Note also that although it is valid to use both "fit_to_pages()" and
3011       "set_print_scale()" on the same worksheet only one of these options can
3012       be active at a time. The last method call made will set the active
3013       option.
3014
3015   set_h_pagebreaks(@breaks)
3016       Add horizontal page breaks to a worksheet. A page break causes all the
3017       data that follows it to be printed on the next page. Horizontal page
3018       breaks act between rows. To create a page break between rows 20 and 21
3019       you must specify the break at row 21. However in zero index notation
3020       this is actually row 20. So you can pretend for a small while that you
3021       are using 1 index notation:
3022
3023           $worksheet1->set_h_pagebreaks(20); # Break between row 20 and 21
3024
3025       The "set_h_pagebreaks()" method will accept a list of page breaks and
3026       you can call it more than once:
3027
3028           $worksheet2->set_h_pagebreaks( 20,  40,  60,  80, 100); # Add breaks
3029           $worksheet2->set_h_pagebreaks(120, 140, 160, 180, 200); # Add some more
3030
3031       Note: If you specify the "fit to page" option via the "fit_to_pages()"
3032       method it will override all manual page breaks.
3033
3034       There is a silent limitation of about 1000 horizontal page breaks per
3035       worksheet in line with an Excel internal limitation.
3036
3037   set_v_pagebreaks(@breaks)
3038       Add vertical page breaks to a worksheet. A page break causes all the
3039       data that follows it to be printed on the next page. Vertical page
3040       breaks act between columns. To create a page break between columns 20
3041       and 21 you must specify the break at column 21. However in zero index
3042       notation this is actually column 20. So you can pretend for a small
3043       while that you are using 1 index notation:
3044
3045           $worksheet1->set_v_pagebreaks(20); # Break between column 20 and 21
3046
3047       The "set_v_pagebreaks()" method will accept a list of page breaks and
3048       you can call it more than once:
3049
3050           $worksheet2->set_v_pagebreaks( 20,  40,  60,  80, 100); # Add breaks
3051           $worksheet2->set_v_pagebreaks(120, 140, 160, 180, 200); # Add some more
3052
3053       Note: If you specify the "fit to page" option via the "fit_to_pages()"
3054       method it will override all manual page breaks.
3055

CELL FORMATTING

3057       This section describes the methods and properties that are available
3058       for formatting cells in Excel. The properties of a cell that can be
3059       formatted include: fonts, colours, patterns, borders, alignment and
3060       number formatting.
3061
3062   Creating and using a Format object
3063       Cell formatting is defined through a Format object. Format objects are
3064       created by calling the workbook "add_format()" method as follows:
3065
3066           my $format1 = $workbook->add_format();       # Set properties later
3067           my $format2 = $workbook->add_format(%props); # Set at creation
3068
3069       The format object holds all the formatting properties that can be
3070       applied to a cell, a row or a column. The process of setting these
3071       properties is discussed in the next section.
3072
3073       Once a Format object has been constructed and it properties have been
3074       set it can be passed as an argument to the worksheet "write" methods as
3075       follows:
3076
3077           $worksheet->write(0, 0, 'One', $format);
3078           $worksheet->write_string(1, 0, 'Two', $format);
3079           $worksheet->write_number(2, 0, 3, $format);
3080           $worksheet->write_blank(3, 0, $format);
3081
3082       Formats can also be passed to the worksheet "set_row()" and
3083       "set_column()" methods to define the default property for a row or
3084       column.
3085
3086           $worksheet->set_row(0, 15, $format);
3087           $worksheet->set_column(0, 0, 15, $format);
3088
3089   Format methods and Format properties
3090       The following table shows the Excel format categories, the formatting
3091       properties that can be applied and the equivalent object method:
3092
3093           Category   Description       Property        Method Name
3094           --------   -----------       --------        -----------
3095           Font       Font type         font            set_font()
3096                      Font size         size            set_size()
3097                      Font color        color           set_color()
3098                      Bold              bold            set_bold()
3099                      Italic            italic          set_italic()
3100                      Underline         underline       set_underline()
3101                      Strikeout         font_strikeout  set_font_strikeout()
3102                      Super/Subscript   font_script     set_font_script()
3103                      Outline           font_outline    set_font_outline()
3104                      Shadow            font_shadow     set_font_shadow()
3105
3106           Number     Numeric format    num_format      set_num_format()
3107
3108           Protection Lock cells        locked          set_locked()
3109                      Hide formulas     hidden          set_hidden()
3110
3111           Alignment  Horizontal align  align           set_align()
3112                      Vertical align    valign          set_align()
3113                      Rotation          rotation        set_rotation()
3114                      Text wrap         text_wrap       set_text_wrap()
3115                      Justify last      text_justlast   set_text_justlast()
3116                      Center across     center_across   set_center_across()
3117                      Indentation       indent          set_indent()
3118                      Shrink to fit     shrink          set_shrink()
3119
3120           Pattern    Cell pattern      pattern         set_pattern()
3121                      Background color  bg_color        set_bg_color()
3122                      Foreground color  fg_color        set_fg_color()
3123
3124           Border     Cell border       border          set_border()
3125                      Bottom border     bottom          set_bottom()
3126                      Top border        top             set_top()
3127                      Left border       left            set_left()
3128                      Right border      right           set_right()
3129                      Border color      border_color    set_border_color()
3130                      Bottom color      bottom_color    set_bottom_color()
3131                      Top color         top_color       set_top_color()
3132                      Left color        left_color      set_left_color()
3133                      Right color       right_color     set_right_color()
3134
3135       There are two ways of setting Format properties: by using the object
3136       method interface or by setting the property directly. For example, a
3137       typical use of the method interface would be as follows:
3138
3139           my $format = $workbook->add_format();
3140           $format->set_bold();
3141           $format->set_color('red');
3142
3143       By comparison the properties can be set directly by passing a hash of
3144       properties to the Format constructor:
3145
3146           my $format = $workbook->add_format(bold => 1, color => 'red');
3147
3148       or after the Format has been constructed by means of the
3149       "set_format_properties()" method as follows:
3150
3151           my $format = $workbook->add_format();
3152           $format->set_format_properties(bold => 1, color => 'red');
3153
3154       You can also store the properties in one or more named hashes and pass
3155       them to the required method:
3156
3157           my %font    = (
3158                           font  => 'Arial',
3159                           size  => 12,
3160                           color => 'blue',
3161                           bold  => 1,
3162                         );
3163
3164           my %shading = (
3165                           bg_color => 'green',
3166                           pattern  => 1,
3167                         );
3168
3169
3170           my $format1 = $workbook->add_format(%font);           # Font only
3171           my $format2 = $workbook->add_format(%font, %shading); # Font and shading
3172
3173       The provision of two ways of setting properties might lead you to
3174       wonder which is the best way. The method mechanism may be better is you
3175       prefer setting properties via method calls (which the author did when
3176       they were code was first written) otherwise passing properties to the
3177       constructor has proved to be a little more flexible and self
3178       documenting in practice. An additional advantage of working with
3179       property hashes is that it allows you to share formatting between
3180       workbook objects as shown in the example above.
3181
3182       The Perl/Tk style of adding properties is also supported:
3183
3184           my %font    = (
3185                           -font      => 'Arial',
3186                           -size      => 12,
3187                           -color     => 'blue',
3188                           -bold      => 1,
3189                         );
3190
3191   Working with formats
3192       The default format is Arial 10 with all other properties off.
3193
3194       Each unique format in Spreadsheet::WriteExcel must have a corresponding
3195       Format object. It isn't possible to use a Format with a write() method
3196       and then redefine the Format for use at a later stage. This is because
3197       a Format is applied to a cell not in its current state but in its final
3198       state. Consider the following example:
3199
3200           my $format = $workbook->add_format();
3201           $format->set_bold();
3202           $format->set_color('red');
3203           $worksheet->write('A1', 'Cell A1', $format);
3204           $format->set_color('green');
3205           $worksheet->write('B1', 'Cell B1', $format);
3206
3207       Cell A1 is assigned the Format $format which is initially set to the
3208       colour red. However, the colour is subsequently set to green. When
3209       Excel displays Cell A1 it will display the final state of the Format
3210       which in this case will be the colour green.
3211
3212       In general a method call without an argument will turn a property on,
3213       for example:
3214
3215           my $format1 = $workbook->add_format();
3216           $format1->set_bold();  # Turns bold on
3217           $format1->set_bold(1); # Also turns bold on
3218           $format1->set_bold(0); # Turns bold off
3219

FORMAT METHODS

3221       The Format object methods are described in more detail in the following
3222       sections. In addition, there is a Perl program called "formats.pl" in
3223       the "examples" directory of the WriteExcel distribution. This program
3224       creates an Excel workbook called "formats.xls" which contains examples
3225       of almost all the format types.
3226
3227       The following Format methods are available:
3228
3229           set_font()
3230           set_size()
3231           set_color()
3232           set_bold()
3233           set_italic()
3234           set_underline()
3235           set_font_strikeout()
3236           set_font_script()
3237           set_font_outline()
3238           set_font_shadow()
3239           set_num_format()
3240           set_locked()
3241           set_hidden()
3242           set_align()
3243           set_rotation()
3244           set_text_wrap()
3245           set_text_justlast()
3246           set_center_across()
3247           set_indent()
3248           set_shrink()
3249           set_pattern()
3250           set_bg_color()
3251           set_fg_color()
3252           set_border()
3253           set_bottom()
3254           set_top()
3255           set_left()
3256           set_right()
3257           set_border_color()
3258           set_bottom_color()
3259           set_top_color()
3260           set_left_color()
3261           set_right_color()
3262
3263       The above methods can also be applied directly as properties. For
3264       example "$format->set_bold()" is equivalent to
3265       "$workbook->add_format(bold => 1)".
3266
3267   set_format_properties(%properties)
3268       The properties of an existing Format object can be also be set by means
3269       of "set_format_properties()":
3270
3271           my $format = $workbook->add_format();
3272           $format->set_format_properties(bold => 1, color => 'red');
3273
3274       However, this method is here mainly for legacy reasons. It is
3275       preferable to set the properties in the format constructor:
3276
3277           my $format = $workbook->add_format(bold => 1, color => 'red');
3278
3279   set_font($fontname)
3280           Default state:      Font is Arial
3281           Default action:     None
3282           Valid args:         Any valid font name
3283
3284       Specify the font used:
3285
3286           $format->set_font('Times New Roman');
3287
3288       Excel can only display fonts that are installed on the system that it
3289       is running on. Therefore it is best to use the fonts that come as
3290       standard such as 'Arial', 'Times New Roman' and 'Courier New'. See also
3291       the Fonts worksheet created by formats.pl
3292
3293   set_size()
3294           Default state:      Font size is 10
3295           Default action:     Set font size to 1
3296           Valid args:         Integer values from 1 to as big as your screen.
3297
3298       Set the font size. Excel adjusts the height of a row to accommodate the
3299       largest font size in the row. You can also explicitly specify the
3300       height of a row using the set_row() worksheet method.
3301
3302           my $format = $workbook->add_format();
3303           $format->set_size(30);
3304
3305   set_color()
3306           Default state:      Excels default color, usually black
3307           Default action:     Set the default color
3308           Valid args:         Integers from 8..63 or the following strings:
3309                               'black'
3310                               'blue'
3311                               'brown'
3312                               'cyan'
3313                               'gray'
3314                               'green'
3315                               'lime'
3316                               'magenta'
3317                               'navy'
3318                               'orange'
3319                               'pink'
3320                               'purple'
3321                               'red'
3322                               'silver'
3323                               'white'
3324                               'yellow'
3325
3326       Set the font colour. The "set_color()" method is used as follows:
3327
3328           my $format = $workbook->add_format();
3329           $format->set_color('red');
3330           $worksheet->write(0, 0, 'wheelbarrow', $format);
3331
3332       Note: The "set_color()" method is used to set the colour of the font in
3333       a cell. To set the colour of a cell use the "set_bg_color()" and
3334       "set_pattern()" methods.
3335
3336       For additional examples see the 'Named colors' and 'Standard colors'
3337       worksheets created by formats.pl in the examples directory.
3338
3339       See also "COLOURS IN EXCEL".
3340
3341   set_bold()
3342           Default state:      bold is off
3343           Default action:     Turn bold on
3344           Valid args:         0, 1 [1]
3345
3346       Set the bold property of the font:
3347
3348           $format->set_bold();  # Turn bold on
3349
3350       [1] Actually, values in the range 100..1000 are also valid. 400 is
3351       normal, 700 is bold and 1000 is very bold indeed. It is probably best
3352       to set the value to 1 and use normal bold.
3353
3354   set_italic()
3355           Default state:      Italic is off
3356           Default action:     Turn italic on
3357           Valid args:         0, 1
3358
3359       Set the italic property of the font:
3360
3361           $format->set_italic();  # Turn italic on
3362
3363   set_underline()
3364           Default state:      Underline is off
3365           Default action:     Turn on single underline
3366           Valid args:         0  = No underline
3367                               1  = Single underline
3368                               2  = Double underline
3369                               33 = Single accounting underline
3370                               34 = Double accounting underline
3371
3372       Set the underline property of the font.
3373
3374           $format->set_underline();   # Single underline
3375
3376   set_font_strikeout()
3377           Default state:      Strikeout is off
3378           Default action:     Turn strikeout on
3379           Valid args:         0, 1
3380
3381       Set the strikeout property of the font.
3382
3383   set_font_script()
3384           Default state:      Super/Subscript is off
3385           Default action:     Turn Superscript on
3386           Valid args:         0  = Normal
3387                               1  = Superscript
3388                               2  = Subscript
3389
3390       Set the superscript/subscript property of the font. This format is
3391       currently not very useful.
3392
3393   set_font_outline()
3394           Default state:      Outline is off
3395           Default action:     Turn outline on
3396           Valid args:         0, 1
3397
3398       Macintosh only.
3399
3400   set_font_shadow()
3401           Default state:      Shadow is off
3402           Default action:     Turn shadow on
3403           Valid args:         0, 1
3404
3405       Macintosh only.
3406
3407   set_num_format()
3408           Default state:      General format
3409           Default action:     Format index 1
3410           Valid args:         See the following table
3411
3412       This method is used to define the numerical format of a number in
3413       Excel. It controls whether a number is displayed as an integer, a
3414       floating point number, a date, a currency value or some other user
3415       defined format.
3416
3417       The numerical format of a cell can be specified by using a format
3418       string or an index to one of Excel's built-in formats:
3419
3420           my $format1 = $workbook->add_format();
3421           my $format2 = $workbook->add_format();
3422           $format1->set_num_format('d mmm yyyy'); # Format string
3423           $format2->set_num_format(0x0f);         # Format index
3424
3425           $worksheet->write(0, 0, 36892.521, $format1);      # 1 Jan 2001
3426           $worksheet->write(0, 0, 36892.521, $format2);      # 1-Jan-01
3427
3428       Using format strings you can define very sophisticated formatting of
3429       numbers.
3430
3431           $format01->set_num_format('0.000');
3432           $worksheet->write(0,  0, 3.1415926, $format01);    # 3.142
3433
3434           $format02->set_num_format('#,##0');
3435           $worksheet->write(1,  0, 1234.56,   $format02);    # 1,235
3436
3437           $format03->set_num_format('#,##0.00');
3438           $worksheet->write(2,  0, 1234.56,   $format03);    # 1,234.56
3439
3440           $format04->set_num_format('$0.00');
3441           $worksheet->write(3,  0, 49.99,     $format04);    # $49.99
3442
3443           # Note you can use other currency symbols such as the pound or yen as well.
3444           # Other currencies may require the use of Unicode.
3445
3446           $format07->set_num_format('mm/dd/yy');
3447           $worksheet->write(6,  0, 36892.521, $format07);    # 01/01/01
3448
3449           $format08->set_num_format('mmm d yyyy');
3450           $worksheet->write(7,  0, 36892.521, $format08);    # Jan 1 2001
3451
3452           $format09->set_num_format('d mmmm yyyy');
3453           $worksheet->write(8,  0, 36892.521, $format09);    # 1 January 2001
3454
3455           $format10->set_num_format('dd/mm/yyyy hh:mm AM/PM');
3456           $worksheet->write(9,  0, 36892.521, $format10);    # 01/01/2001 12:30 AM
3457
3458           $format11->set_num_format('0 "dollar and" .00 "cents"');
3459           $worksheet->write(10, 0, 1.87,      $format11);    # 1 dollar and .87 cents
3460
3461           # Conditional formatting
3462           $format12->set_num_format('[Green]General;[Red]-General;General');
3463           $worksheet->write(11, 0, 123,       $format12);    # > 0 Green
3464           $worksheet->write(12, 0, -45,       $format12);    # < 0 Red
3465           $worksheet->write(13, 0, 0,         $format12);    # = 0 Default colour
3466
3467           # Zip code
3468           $format13->set_num_format('00000');
3469           $worksheet->write(14, 0, '01209',   $format13);
3470
3471       The number system used for dates is described in "DATES AND TIME IN
3472       EXCEL".
3473
3474       The colour format should have one of the following values:
3475
3476           [Black] [Blue] [Cyan] [Green] [Magenta] [Red] [White] [Yellow]
3477
3478       Alternatively you can specify the colour based on a colour index as
3479       follows: "[Color n]", where n is a standard Excel colour index - 7. See
3480       the 'Standard colors' worksheet created by formats.pl.
3481
3482       For more information refer to the documentation on formatting in the
3483       "docs" directory of the Spreadsheet::WriteExcel distro, the Excel on-
3484       line help or
3485       http://office.microsoft.com/en-gb/assistance/HP051995001033.aspx
3486       <http://office.microsoft.com/en-gb/assistance/HP051995001033.aspx>.
3487
3488       You should ensure that the format string is valid in Excel prior to
3489       using it in WriteExcel.
3490
3491       Excel's built-in formats are shown in the following table:
3492
3493           Index   Index   Format String
3494           0       0x00    General
3495           1       0x01    0
3496           2       0x02    0.00
3497           3       0x03    #,##0
3498           4       0x04    #,##0.00
3499           5       0x05    ($#,##0_);($#,##0)
3500           6       0x06    ($#,##0_);[Red]($#,##0)
3501           7       0x07    ($#,##0.00_);($#,##0.00)
3502           8       0x08    ($#,##0.00_);[Red]($#,##0.00)
3503           9       0x09    0%
3504           10      0x0a    0.00%
3505           11      0x0b    0.00E+00
3506           12      0x0c    # ?/?
3507           13      0x0d    # ??/??
3508           14      0x0e    m/d/yy
3509           15      0x0f    d-mmm-yy
3510           16      0x10    d-mmm
3511           17      0x11    mmm-yy
3512           18      0x12    h:mm AM/PM
3513           19      0x13    h:mm:ss AM/PM
3514           20      0x14    h:mm
3515           21      0x15    h:mm:ss
3516           22      0x16    m/d/yy h:mm
3517           ..      ....    ...........
3518           37      0x25    (#,##0_);(#,##0)
3519           38      0x26    (#,##0_);[Red](#,##0)
3520           39      0x27    (#,##0.00_);(#,##0.00)
3521           40      0x28    (#,##0.00_);[Red](#,##0.00)
3522           41      0x29    _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)
3523           42      0x2a    _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)
3524           43      0x2b    _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
3525           44      0x2c    _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)
3526           45      0x2d    mm:ss
3527           46      0x2e    [h]:mm:ss
3528           47      0x2f    mm:ss.0
3529           48      0x30    ##0.0E+0
3530           49      0x31    @
3531
3532       For examples of these formatting codes see the 'Numerical formats'
3533       worksheet created by formats.pl. See also the number_formats1.html and
3534       the number_formats2.html documents in the "docs" directory of the
3535       distro.
3536
3537       Note 1. Numeric formats 23 to 36 are not documented by Microsoft and
3538       may differ in international versions.
3539
3540       Note 2. In Excel 5 the dollar sign appears as a dollar sign. In Excel
3541       97-2000 it appears as the defined local currency symbol.
3542
3543       Note 3. The red negative numeric formats display slightly differently
3544       in Excel 5 and Excel 97-2000.
3545
3546   set_locked()
3547           Default state:      Cell locking is on
3548           Default action:     Turn locking on
3549           Valid args:         0, 1
3550
3551       This property can be used to prevent modification of a cells contents.
3552       Following Excel's convention, cell locking is turned on by default.
3553       However, it only has an effect if the worksheet has been protected, see
3554       the worksheet "protect()" method.
3555
3556           my $locked  = $workbook->add_format();
3557           $locked->set_locked(1); # A non-op
3558
3559           my $unlocked = $workbook->add_format();
3560           $locked->set_locked(0);
3561
3562           # Enable worksheet protection
3563           $worksheet->protect();
3564
3565           # This cell cannot be edited.
3566           $worksheet->write('A1', '=1+2', $locked);
3567
3568           # This cell can be edited.
3569           $worksheet->write('A2', '=1+2', $unlocked);
3570
3571       Note: This offers weak protection even with a password, see the note in
3572       relation to the "protect()" method.
3573
3574   set_hidden()
3575           Default state:      Formula hiding is off
3576           Default action:     Turn hiding on
3577           Valid args:         0, 1
3578
3579       This property is used to hide a formula while still displaying its
3580       result. This is generally used to hide complex calculations from end
3581       users who are only interested in the result. It only has an effect if
3582       the worksheet has been protected, see the worksheet "protect()" method.
3583
3584           my $hidden = $workbook->add_format();
3585           $hidden->set_hidden();
3586
3587           # Enable worksheet protection
3588           $worksheet->protect();
3589
3590           # The formula in this cell isn't visible
3591           $worksheet->write('A1', '=1+2', $hidden);
3592
3593       Note: This offers weak protection even with a password, see the note in
3594       relation to the "protect()" method.
3595
3596   set_align()
3597           Default state:      Alignment is off
3598           Default action:     Left alignment
3599           Valid args:         'left'              Horizontal
3600                               'center'
3601                               'right'
3602                               'fill'
3603                               'justify'
3604                               'center_across'
3605
3606                               'top'               Vertical
3607                               'vcenter'
3608                               'bottom'
3609                               'vjustify'
3610
3611       This method is used to set the horizontal and vertical text alignment
3612       within a cell. Vertical and horizontal alignments can be combined. The
3613       method is used as follows:
3614
3615           my $format = $workbook->add_format();
3616           $format->set_align('center');
3617           $format->set_align('vcenter');
3618           $worksheet->set_row(0, 30);
3619           $worksheet->write(0, 0, 'X', $format);
3620
3621       Text can be aligned across two or more adjacent cells using the
3622       "center_across" property. However, for genuine merged cells it is
3623       better to use the "merge_range()" worksheet method.
3624
3625       The "vjustify" (vertical justify) option can be used to provide
3626       automatic text wrapping in a cell. The height of the cell will be
3627       adjusted to accommodate the wrapped text. To specify where the text
3628       wraps use the "set_text_wrap()" method.
3629
3630       For further examples see the 'Alignment' worksheet created by
3631       formats.pl.
3632
3633   set_center_across()
3634           Default state:      Center across selection is off
3635           Default action:     Turn center across on
3636           Valid args:         1
3637
3638       Text can be aligned across two or more adjacent cells using the
3639       "set_center_across()" method. This is an alias for the
3640       "set_align('center_across')" method call.
3641
3642       Only one cell should contain the text, the other cells should be blank:
3643
3644           my $format = $workbook->add_format();
3645           $format->set_center_across();
3646
3647           $worksheet->write(1, 1, 'Center across selection', $format);
3648           $worksheet->write_blank(1, 2, $format);
3649
3650       See also the "merge1.pl" to "merge6.pl" programs in the "examples"
3651       directory and the "merge_range()" method.
3652
3653   set_text_wrap()
3654           Default state:      Text wrap is off
3655           Default action:     Turn text wrap on
3656           Valid args:         0, 1
3657
3658       Here is an example using the text wrap property, the escape character
3659       "\n" is used to indicate the end of line:
3660
3661           my $format = $workbook->add_format();
3662           $format->set_text_wrap();
3663           $worksheet->write(0, 0, "It's\na bum\nwrap", $format);
3664
3665       Excel will adjust the height of the row to accommodate the wrapped
3666       text. A similar effect can be obtained without newlines using the
3667       "set_align('vjustify')" method. See the "textwrap.pl" program in the
3668       "examples" directory.
3669
3670   set_rotation()
3671           Default state:      Text rotation is off
3672           Default action:     None
3673           Valid args:         Integers in the range -90 to 90 and 270
3674
3675       Set the rotation of the text in a cell. The rotation can be any angle
3676       in the range -90 to 90 degrees.
3677
3678           my $format = $workbook->add_format();
3679           $format->set_rotation(30);
3680           $worksheet->write(0, 0, 'This text is rotated', $format);
3681
3682       The angle 270 is also supported. This indicates text where the letters
3683       run from top to bottom.
3684
3685   set_indent()
3686           Default state:      Text indentation is off
3687           Default action:     Indent text 1 level
3688           Valid args:         Positive integers
3689
3690       This method can be used to indent text. The argument, which should be
3691       an integer, is taken as the level of indentation:
3692
3693           my $format = $workbook->add_format();
3694           $format->set_indent(2);
3695           $worksheet->write(0, 0, 'This text is indented', $format);
3696
3697       Indentation is a horizontal alignment property. It will override any
3698       other horizontal properties but it can be used in conjunction with
3699       vertical properties.
3700
3701   set_shrink()
3702           Default state:      Text shrinking is off
3703           Default action:     Turn "shrink to fit" on
3704           Valid args:         1
3705
3706       This method can be used to shrink text so that it fits in a cell.
3707
3708           my $format = $workbook->add_format();
3709           $format->set_shrink();
3710           $worksheet->write(0, 0, 'Honey, I shrunk the text!', $format);
3711
3712   set_text_justlast()
3713           Default state:      Justify last is off
3714           Default action:     Turn justify last on
3715           Valid args:         0, 1
3716
3717       Only applies to Far Eastern versions of Excel.
3718
3719   set_pattern()
3720           Default state:      Pattern is off
3721           Default action:     Solid fill is on
3722           Valid args:         0 .. 18
3723
3724       Set the background pattern of a cell.
3725
3726       Examples of the available patterns are shown in the 'Patterns'
3727       worksheet created by formats.pl. However, it is unlikely that you will
3728       ever need anything other than Pattern 1 which is a solid fill of the
3729       background color.
3730
3731   set_bg_color()
3732           Default state:      Color is off
3733           Default action:     Solid fill.
3734           Valid args:         See set_color()
3735
3736       The "set_bg_color()" method can be used to set the background colour of
3737       a pattern. Patterns are defined via the "set_pattern()" method. If a
3738       pattern hasn't been defined then a solid fill pattern is used as the
3739       default.
3740
3741       Here is an example of how to set up a solid fill in a cell:
3742
3743           my $format = $workbook->add_format();
3744
3745           $format->set_pattern(); # This is optional when using a solid fill
3746
3747           $format->set_bg_color('green');
3748           $worksheet->write('A1', 'Ray', $format);
3749
3750       For further examples see the 'Patterns' worksheet created by
3751       formats.pl.
3752
3753   set_fg_color()
3754           Default state:      Color is off
3755           Default action:     Solid fill.
3756           Valid args:         See set_color()
3757
3758       The "set_fg_color()" method can be used to set the foreground colour of
3759       a pattern.
3760
3761       For further examples see the 'Patterns' worksheet created by
3762       formats.pl.
3763
3764   set_border()
3765           Also applies to:    set_bottom()
3766                               set_top()
3767                               set_left()
3768                               set_right()
3769
3770           Default state:      Border is off
3771           Default action:     Set border type 1
3772           Valid args:         0-13, See below.
3773
3774       A cell border is comprised of a border on the bottom, top, left and
3775       right. These can be set to the same value using "set_border()" or
3776       individually using the relevant method calls shown above.
3777
3778       The following shows the border styles sorted by Spreadsheet::WriteExcel
3779       index number:
3780
3781           Index   Name            Weight   Style
3782           =====   =============   ======   ===========
3783           0       None            0
3784           1       Continuous      1        -----------
3785           2       Continuous      2        -----------
3786           3       Dash            1        - - - - - -
3787           4       Dot             1        . . . . . .
3788           5       Continuous      3        -----------
3789           6       Double          3        ===========
3790           7       Continuous      0        -----------
3791           8       Dash            2        - - - - - -
3792           9       Dash Dot        1        - . - . - .
3793           10      Dash Dot        2        - . - . - .
3794           11      Dash Dot Dot    1        - . . - . .
3795           12      Dash Dot Dot    2        - . . - . .
3796           13      SlantDash Dot   2        / - . / - .
3797
3798       The following shows the borders sorted by style:
3799
3800           Name            Weight   Style         Index
3801           =============   ======   ===========   =====
3802           Continuous      0        -----------   7
3803           Continuous      1        -----------   1
3804           Continuous      2        -----------   2
3805           Continuous      3        -----------   5
3806           Dash            1        - - - - - -   3
3807           Dash            2        - - - - - -   8
3808           Dash Dot        1        - . - . - .   9
3809           Dash Dot        2        - . - . - .   10
3810           Dash Dot Dot    1        - . . - . .   11
3811           Dash Dot Dot    2        - . . - . .   12
3812           Dot             1        . . . . . .   4
3813           Double          3        ===========   6
3814           None            0                      0
3815           SlantDash Dot   2        / - . / - .   13
3816
3817       The following shows the borders in the order shown in the Excel Dialog.
3818
3819           Index   Style             Index   Style
3820           =====   =====             =====   =====
3821           0       None              12      - . . - . .
3822           7       -----------       13      / - . / - .
3823           4       . . . . . .       10      - . - . - .
3824           11      - . . - . .       8       - - - - - -
3825           9       - . - . - .       2       -----------
3826           3       - - - - - -       5       -----------
3827           1       -----------       6       ===========
3828
3829       Examples of the available border styles are shown in the 'Borders'
3830       worksheet created by formats.pl.
3831
3832   set_border_color()
3833           Also applies to:    set_bottom_color()
3834                               set_top_color()
3835                               set_left_color()
3836                               set_right_color()
3837
3838           Default state:      Color is off
3839           Default action:     Undefined
3840           Valid args:         See set_color()
3841
3842       Set the colour of the cell borders. A cell border is comprised of a
3843       border on the bottom, top, left and right. These can be set to the same
3844       colour using "set_border_color()" or individually using the relevant
3845       method calls shown above. Examples of the border styles and colours are
3846       shown in the 'Borders' worksheet created by formats.pl.
3847
3848   copy($format)
3849       This method is used to copy all of the properties from one Format
3850       object to another:
3851
3852           my $lorry1 = $workbook->add_format();
3853           $lorry1->set_bold();
3854           $lorry1->set_italic();
3855           $lorry1->set_color('red');    # lorry1 is bold, italic and red
3856
3857           my $lorry2 = $workbook->add_format();
3858           $lorry2->copy($lorry1);
3859           $lorry2->set_color('yellow'); # lorry2 is bold, italic and yellow
3860
3861       The "copy()" method is only useful if you are using the method
3862       interface to Format properties. It generally isn't required if you are
3863       setting Format properties directly using hashes.
3864
3865       Note: this is not a copy constructor, both objects must exist prior to
3866       copying.
3867

UNICODE IN EXCEL

3869       The following is a brief introduction to handling Unicode in
3870       "Spreadsheet::WriteExcel".
3871
3872       For a more general introduction to Unicode handling in Perl see
3873       perlunitut and perluniintro.
3874
3875       When using Spreadsheet::WriteExcel the best and easiest way to write
3876       unicode strings to an Excel file is to use "UTF-8" encoded strings and
3877       perl 5.8 (or later). Spreadsheet::WriteExcel also allows you to write
3878       unicode strings using older perls but it generally requires more work,
3879       as explained below.
3880
3881       Internally, Excel encodes unicode data as "UTF-16LE" (where LE means
3882       little-endian). If you are using perl 5.8+ then Spreadsheet::WriteExcel
3883       will convert "UTF-8" strings to "UTF-16LE" when required. No further
3884       intervention is required from the programmer, for example:
3885
3886           # perl 5.8+ example:
3887           my $smiley = "\x{263A}";
3888
3889           $worksheet->write('A1', 'Hello world'); # ASCII
3890           $worksheet->write('A2', $smiley);       # UTF-8
3891
3892       Spreadsheet::WriteExcel also lets you write unicode data as "UTF-16".
3893       Since the majority of CPAN modules default to "UTF-16BE" (big-endian)
3894       Spreadsheet::WriteExcel also uses "UTF-16BE" and converts it internally
3895       to "UTF-16LE":
3896
3897           # perl 5.005 example:
3898           my $smiley = pack 'n', 0x263A;
3899
3900           $worksheet->write               ('A3', 'Hello world'); # ASCII
3901           $worksheet->write_utf16be_string('A4', $smiley);       # UTF-16
3902
3903       Although the above examples look similar there is an important
3904       difference. With "uft8" and perl 5.8+ Spreadsheet::WriteExcel treats
3905       "UTF-8" strings in exactly the same way as any other string. However,
3906       with "UTF16" data we need to distinguish it from other strings either
3907       by calling a separate function or by passing an additional flag to
3908       indicate the data type.
3909
3910       If you are dealing with non-ASCII characters that aren't in "UTF-8"
3911       then perl 5.8+ provides useful tools in the guise of the "Encode"
3912       module to help you to convert to the required format. For example:
3913
3914           use Encode 'decode';
3915
3916           my $string = 'some string with koi8-r characters';
3917              $string = decode('koi8-r', $string); # koi8-r to utf8
3918
3919       Alternatively you can read data from an encoded file and convert it to
3920       "UTF-8" as you read it in:
3921
3922           my $file = 'unicode_koi8r.txt';
3923           open FH, '<:encoding(koi8-r)', $file  or die "Couldn't open $file: $!\n";
3924
3925           my $row = 0;
3926           while (<FH>) {
3927               # Data read in is now in utf8 format.
3928               chomp;
3929               $worksheet->write($row++, 0,  $_);
3930           }
3931
3932       These methodologies are explained in more detail in perlunitut,
3933       perluniintro and perlunicode.
3934
3935       See also the "unicode_*.pl" programs in the examples directory of the
3936       distro.
3937

COLOURS IN EXCEL

3939       Excel provides a colour palette of 56 colours. In
3940       Spreadsheet::WriteExcel these colours are accessed via their palette
3941       index in the range 8..63. This index is used to set the colour of
3942       fonts, cell patterns and cell borders. For example:
3943
3944           my $format = $workbook->add_format(
3945                                               color => 12, # index for blue
3946                                               font  => 'Arial',
3947                                               size  => 12,
3948                                               bold  => 1,
3949                                            );
3950
3951       The most commonly used colours can also be accessed by name. The name
3952       acts as a simple alias for the colour index:
3953
3954           black     =>    8
3955           blue      =>   12
3956           brown     =>   16
3957           cyan      =>   15
3958           gray      =>   23
3959           green     =>   17
3960           lime      =>   11
3961           magenta   =>   14
3962           navy      =>   18
3963           orange    =>   53
3964           pink      =>   33
3965           purple    =>   20
3966           red       =>   10
3967           silver    =>   22
3968           white     =>    9
3969           yellow    =>   13
3970
3971       For example:
3972
3973           my $font = $workbook->add_format(color => 'red');
3974
3975       Users of VBA in Excel should note that the equivalent colour indices
3976       are in the range 1..56 instead of 8..63.
3977
3978       If the default palette does not provide a required colour you can
3979       override one of the built-in values. This is achieved by using the
3980       "set_custom_color()" workbook method to adjust the RGB (red green blue)
3981       components of the colour:
3982
3983           my $ferrari = $workbook->set_custom_color(40, 216, 12, 12);
3984
3985           my $format  = $workbook->add_format(
3986                                               bg_color => $ferrari,
3987                                               pattern  => 1,
3988                                               border   => 1
3989                                             );
3990
3991           $worksheet->write_blank('A1', $format);
3992
3993       The default Excel 97 colour palette is shown in "palette.html" in the
3994       "docs" directory  of the distro. You can generate an Excel version of
3995       the palette using "colors.pl" in the "examples" directory.
3996
3997       A comparison of the colour components in the Excel 5 and Excel 97+
3998       colour palettes is shown in "rgb5-97.txt" in the "docs" directory.
3999
4000       You may also find the following links helpful:
4001
4002       A detailed look at Excel's colour palette:
4003       <http://www.mvps.org/dmcritchie/excel/colors.htm>
4004
4005       A decimal RGB chart: <http://www.hypersolutions.org/pages/rgbdec.html>.
4006
4007       A hex RGB chart: : <http://www.hypersolutions.org/pages/rgbhex.html>.
4008

DATES AND TIME IN EXCEL

4010       There are two important things to understand about dates and times in
4011       Excel:
4012
4013       1 A date/time in Excel is a real number plus an Excel number format.
4014       2 Spreadsheet::WriteExcel doesn't automatically convert date/time
4015       strings in "write()" to an Excel date/time.
4016
4017       These two points are explained in more detail below along with some
4018       suggestions on how to convert times and dates to the required format.
4019
4020   An Excel date/time is a number plus a format
4021       If you write a date string with "write()" then all you will get is a
4022       string:
4023
4024           $worksheet->write('A1', '02/03/04'); # !! Writes a string not a date. !!
4025
4026       Dates and times in Excel are represented by real numbers, for example
4027       "Jan 1 2001 12:30 AM" is represented by the number 36892.521.
4028
4029       The integer part of the number stores the number of days since the
4030       epoch and the fractional part stores the percentage of the day.
4031
4032       A date or time in Excel is just like any other number. To have the
4033       number display as a date you must apply an Excel number format to it.
4034       Here are some examples.
4035
4036           #!/usr/bin/perl -w
4037
4038           use strict;
4039           use Spreadsheet::WriteExcel;
4040
4041           my $workbook  = Spreadsheet::WriteExcel->new('date_examples.xls');
4042           my $worksheet = $workbook->add_worksheet();
4043
4044           $worksheet->set_column('A:A', 30); # For extra visibility.
4045
4046           my $number    = 39506.5;
4047
4048           $worksheet->write('A1', $number);            #     39506.5
4049
4050           my $format2 = $workbook->add_format(num_format => 'dd/mm/yy');
4051           $worksheet->write('A2', $number , $format2); #     28/02/08
4052
4053           my $format3 = $workbook->add_format(num_format => 'mm/dd/yy');
4054           $worksheet->write('A3', $number , $format3); #     02/28/08
4055
4056           my $format4 = $workbook->add_format(num_format => 'd-m-yyyy');
4057           $worksheet->write('A4', $number , $format4); #     28-2-2008
4058
4059           my $format5 = $workbook->add_format(num_format => 'dd/mm/yy hh:mm');
4060           $worksheet->write('A5', $number , $format5); #     28/02/08 12:00
4061
4062           my $format6 = $workbook->add_format(num_format => 'd mmm yyyy');
4063           $worksheet->write('A6', $number , $format6); #     28 Feb 2008
4064
4065           my $format7 = $workbook->add_format(num_format => 'mmm d yyyy hh:mm AM/PM');
4066           $worksheet->write('A7', $number , $format7); #     Feb 28 2008 12:00 PM
4067
4068   Spreadsheet::WriteExcel doesn't automatically convert date/time strings
4069       Spreadsheet::WriteExcel doesn't automatically convert input date
4070       strings into Excel's formatted date numbers due to the large number of
4071       possible date formats and also due to the possibility of
4072       misinterpretation.
4073
4074       For example, does "02/03/04" mean March 2 2004, February 3 2004 or even
4075       March 4 2002.
4076
4077       Therefore, in order to handle dates you will have to convert them to
4078       numbers and apply an Excel format. Some methods for converting dates
4079       are listed in the next section.
4080
4081       The most direct way is to convert your dates to the ISO8601
4082       "yyyy-mm-ddThh:mm:ss.sss" date format and use the "write_date_time()"
4083       worksheet method:
4084
4085           $worksheet->write_date_time('A2', '2001-01-01T12:20', $format);
4086
4087       See the "write_date_time()" section of the documentation for more
4088       details.
4089
4090       A general methodology for handling date strings with
4091       "write_date_time()" is:
4092
4093           1. Identify incoming date/time strings with a regex.
4094           2. Extract the component parts of the date/time using the same regex.
4095           3. Convert the date/time to the ISO8601 format.
4096           4. Write the date/time using write_date_time() and a number format.
4097
4098       Here is an example:
4099
4100           #!/usr/bin/perl -w
4101
4102           use strict;
4103           use Spreadsheet::WriteExcel;
4104
4105           my $workbook    = Spreadsheet::WriteExcel->new('example.xls');
4106           my $worksheet   = $workbook->add_worksheet();
4107
4108           # Set the default format for dates.
4109           my $date_format = $workbook->add_format(num_format => 'mmm d yyyy');
4110
4111           # Increase column width to improve visibility of data.
4112           $worksheet->set_column('A:C', 20);
4113
4114           # Simulate reading from a data source.
4115           my $row = 0;
4116
4117           while (<DATA>) {
4118               chomp;
4119
4120               my $col  = 0;
4121               my @data = split ' ';
4122
4123               for my $item (@data) {
4124
4125                   # Match dates in the following formats: d/m/yy, d/m/yyyy
4126                   if ($item =~ qr[^(\d{1,2})/(\d{1,2})/(\d{4})$]) {
4127
4128                       # Change to the date format required by write_date_time().
4129                       my $date = sprintf "%4d-%02d-%02dT", $3, $2, $1;
4130
4131                       $worksheet->write_date_time($row, $col++, $date, $date_format);
4132                   }
4133                   else {
4134                       # Just plain data
4135                       $worksheet->write($row, $col++, $item);
4136                   }
4137               }
4138               $row++;
4139           }
4140
4141           __DATA__
4142           Item    Cost    Date
4143           Book    10      1/9/2007
4144           Beer    4       12/9/2007
4145           Bed     500     5/10/2007
4146
4147       For a slightly more advanced solution you can modify the "write()"
4148       method to handle date formats of your choice via the
4149       "add_write_handler()" method. See the "add_write_handler()" section of
4150       the docs and the write_handler3.pl and write_handler4.pl programs in
4151       the examples directory of the distro.
4152
4153   Converting dates and times to an Excel date or time
4154       The "write_date_time()" method above is just one way of handling dates
4155       and times.
4156
4157       The Spreadsheet::WriteExcel::Utility module which is included in the
4158       distro has date/time handling functions:
4159
4160           use Spreadsheet::WriteExcel::Utility;
4161
4162           $date           = xl_date_list(2002, 1, 1);         # 37257
4163           $date           = xl_parse_date("11 July 1997");    # 35622
4164           $time           = xl_parse_time('3:21:36 PM');      # 0.64
4165           $date           = xl_decode_date_EU("13 May 2002"); # 37389
4166
4167       Note: some of these functions require additional CPAN modules.
4168
4169       For date conversions using the CPAN "DateTime" framework see
4170       DateTime::Format::Excel
4171       http://search.cpan.org/search?dist=DateTime-Format-Excel
4172       <http://search.cpan.org/search?dist=DateTime-Format-Excel>.
4173

OUTLINES AND GROUPING IN EXCEL

4175       Excel allows you to group rows or columns so that they can be hidden or
4176       displayed with a single mouse click. This feature is referred to as
4177       outlines.
4178
4179       Outlines can reduce complex data down to a few salient sub-totals or
4180       summaries.
4181
4182       This feature is best viewed in Excel but the following is an ASCII
4183       representation of what a worksheet with three outlines might look like.
4184       Rows 3-4 and rows 7-8 are grouped at level 2. Rows 2-9 are grouped at
4185       level 1. The lines at the left hand side are called outline level bars.
4186
4187                   ------------------------------------------
4188            1 2 3 |   |   A   |   B   |   C   |   D   |  ...
4189                   ------------------------------------------
4190             _    | 1 |   A   |       |       |       |  ...
4191            |  _  | 2 |   B   |       |       |       |  ...
4192            | |   | 3 |  (C)  |       |       |       |  ...
4193            | |   | 4 |  (D)  |       |       |       |  ...
4194            | -   | 5 |   E   |       |       |       |  ...
4195            |  _  | 6 |   F   |       |       |       |  ...
4196            | |   | 7 |  (G)  |       |       |       |  ...
4197            | |   | 8 |  (H)  |       |       |       |  ...
4198            | -   | 9 |   I   |       |       |       |  ...
4199            -     | . |  ...  |  ...  |  ...  |  ...  |  ...
4200
4201       Clicking the minus sign on each of the level 2 outlines will collapse
4202       and hide the data as shown in the next figure. The minus sign changes
4203       to a plus sign to indicate that the data in the outline is hidden.
4204
4205                   ------------------------------------------
4206            1 2 3 |   |   A   |   B   |   C   |   D   |  ...
4207                   ------------------------------------------
4208             _    | 1 |   A   |       |       |       |  ...
4209            |     | 2 |   B   |       |       |       |  ...
4210            | +   | 5 |   E   |       |       |       |  ...
4211            |     | 6 |   F   |       |       |       |  ...
4212            | +   | 9 |   I   |       |       |       |  ...
4213            -     | . |  ...  |  ...  |  ...  |  ...  |  ...
4214
4215       Clicking on the minus sign on the level 1 outline will collapse the
4216       remaining rows as follows:
4217
4218                   ------------------------------------------
4219            1 2 3 |   |   A   |   B   |   C   |   D   |  ...
4220                   ------------------------------------------
4221                  | 1 |   A   |       |       |       |  ...
4222            +     | . |  ...  |  ...  |  ...  |  ...  |  ...
4223
4224       Grouping in "Spreadsheet::WriteExcel" is achieved by setting the
4225       outline level via the "set_row()" and "set_column()" worksheet methods:
4226
4227           set_row($row, $height, $format, $hidden, $level, $collapsed)
4228           set_column($first_col, $last_col, $width, $format, $hidden, $level, $collapsed)
4229
4230       The following example sets an outline level of 1 for rows 1 and 2
4231       (zero-indexed) and columns B to G. The parameters $height and $XF are
4232       assigned default values since they are undefined:
4233
4234           $worksheet->set_row(1, undef, undef, 0, 1);
4235           $worksheet->set_row(2, undef, undef, 0, 1);
4236           $worksheet->set_column('B:G', undef, undef, 0, 1);
4237
4238       Excel allows up to 7 outline levels. Therefore the $level parameter
4239       should be in the range "0 <= $level <= 7".
4240
4241       Rows and columns can be collapsed by setting the $hidden flag for the
4242       hidden rows/columns and setting the $collapsed flag for the row/column
4243       that has the collapsed "+" symbol:
4244
4245           $worksheet->set_row(1, undef, undef, 1, 1);
4246           $worksheet->set_row(2, undef, undef, 1, 1);
4247           $worksheet->set_row(3, undef, undef, 0, 0, 1);        # Collapsed flag.
4248
4249           $worksheet->set_column('B:G', undef, undef, 1, 1);
4250           $worksheet->set_column('H:H', undef, undef, 0, 0, 1); # Collapsed flag.
4251
4252       Note: Setting the $collapsed flag is particularly important for
4253       compatibility with OpenOffice.org and Gnumeric.
4254
4255       For a more complete example see the "outline.pl" and
4256       "outline_collapsed.pl" programs in the examples directory of the
4257       distro.
4258
4259       Some additional outline properties can be set via the
4260       "outline_settings()" worksheet method, see above.
4261

DATA VALIDATION IN EXCEL

4263       Data validation is a feature of Excel which allows you to restrict the
4264       data that a users enters in a cell and to display help and warning
4265       messages. It also allows you to restrict input to values in a drop down
4266       list.
4267
4268       A typical use case might be to restrict data in a cell to integer
4269       values in a certain range, to provide a help message to indicate the
4270       required value and to issue a warning if the input data doesn't meet
4271       the stated criteria. In Spreadsheet::WriteExcel we could do that as
4272       follows:
4273
4274           $worksheet->data_validation('B3',
4275               {
4276                   validate        => 'integer',
4277                   criteria        => 'between',
4278                   minimum         => 1,
4279                   maximum         => 100,
4280                   input_title     => 'Input an integer:',
4281                   input_message   => 'Between 1 and 100',
4282                   error_message   => 'Sorry, try again.',
4283               });
4284
4285       The above example would look like this in Excel:
4286       <http://homepage.eircom.net/~jmcnamara/perl/data_validation.jpg>.
4287
4288       For more information on data validation see the following Microsoft
4289       support article "Description and examples of data validation in Excel":
4290       <http://support.microsoft.com/kb/211485>.
4291
4292       The following sections describe how to use the "data_validation()"
4293       method and its various options.
4294
4295   data_validation($row, $col, { parameter => 'value', ... })
4296       The "data_validation()" method is used to construct an Excel data
4297       validation.
4298
4299       It can be applied to a single cell or a range of cells. You can pass 3
4300       parameters such as  "($row, $col, {...})" or 5 parameters such as
4301       "($first_row, $first_col, $last_row, $last_col, {...})". You can also
4302       use "A1" style notation. For example:
4303
4304           $worksheet->data_validation(0, 0,       {...});
4305           $worksheet->data_validation(0, 0, 4, 1, {...});
4306
4307           # Which are the same as:
4308
4309           $worksheet->data_validation('A1',       {...});
4310           $worksheet->data_validation('A1:B5',    {...});
4311
4312       See also the note about "Cell notation" for more information.
4313
4314       The last parameter in "data_validation()" must be a hash ref containing
4315       the parameters that describe the type and style of the data validation.
4316       The allowable parameters are:
4317
4318           validate
4319           criteria
4320           value | minimum | source
4321           maximum
4322           ignore_blank
4323           dropdown
4324
4325           input_title
4326           input_message
4327           show_input
4328
4329           error_title
4330           error_message
4331           error_type
4332           show_error
4333
4334       These parameters are explained in the following sections. Most of the
4335       parameters are optional, however, you will generally require the three
4336       main options "validate", "criteria" and "value".
4337
4338           $worksheet->data_validation('B3',
4339               {
4340                   validate => 'integer',
4341                   criteria => '>',
4342                   value    => 100,
4343               });
4344
4345       The "data_validation" method returns:
4346
4347            0 for success.
4348           -1 for insufficient number of arguments.
4349           -2 for row or column out of bounds.
4350           -3 for incorrect parameter or value.
4351
4352   validate
4353       This parameter is passed in a hash ref to "data_validation()".
4354
4355       The "validate" parameter is used to set the type of data that you wish
4356       to validate. It is always required and it has no default value.
4357       Allowable values are:
4358
4359           any
4360           integer
4361           decimal
4362           list
4363           date
4364           time
4365           length
4366           custom
4367
4368       ·   any is used to specify that the type of data is unrestricted. This
4369           is the same as not applying a data validation. It is only provided
4370           for completeness and isn't used very often in the context of
4371           Spreadsheet::WriteExcel.
4372
4373       ·   integer restricts the cell to integer values. Excel refers to this
4374           as 'whole number'.
4375
4376               validate => 'integer',
4377               criteria => '>',
4378               value    => 100,
4379
4380       ·   decimal restricts the cell to decimal values.
4381
4382               validate => 'decimal',
4383               criteria => '>',
4384               value    => 38.6,
4385
4386       ·   list restricts the cell to a set of user specified values. These
4387           can be passed in an array ref or as a cell range (named ranges
4388           aren't currently supported):
4389
4390               validate => 'list',
4391               value    => ['open', 'high', 'close'],
4392               # Or like this:
4393               value    => 'B1:B3',
4394
4395           Excel requires that range references are only to cells on the same
4396           worksheet.
4397
4398       ·   date restricts the cell to date values. Dates in Excel are
4399           expressed as integer values but you can also pass an ISO860 style
4400           string as used in "write_date_time()". See also "DATES AND TIME IN
4401           EXCEL" for more information about working with Excel's dates.
4402
4403               validate => 'date',
4404               criteria => '>',
4405               value    => 39653, # 24 July 2008
4406               # Or like this:
4407               value    => '2008-07-24T',
4408
4409       ·   time restricts the cell to time values. Times in Excel are
4410           expressed as decimal values but you can also pass an ISO860 style
4411           string as used in "write_date_time()". See also "DATES AND TIME IN
4412           EXCEL" for more information about working with Excel's times.
4413
4414               validate => 'time',
4415               criteria => '>',
4416               value    => 0.5, # Noon
4417               # Or like this:
4418               value    => 'T12:00:00',
4419
4420       ·   length restricts the cell data based on an integer string length.
4421           Excel refers to this as 'Text length'.
4422
4423               validate => 'length',
4424               criteria => '>',
4425               value    => 10,
4426
4427       ·   custom restricts the cell based on an external Excel formula that
4428           returns a "TRUE/FALSE" value.
4429
4430               validate => 'custom',
4431               value    => '=IF(A10>B10,TRUE,FALSE)',
4432
4433   criteria
4434       This parameter is passed in a hash ref to "data_validation()".
4435
4436       The "criteria" parameter is used to set the criteria by which the data
4437       in the cell is validated. It is almost always required except for the
4438       "list" and "custom" validate options. It has no default value.
4439       Allowable values are:
4440
4441           'between'
4442           'not between'
4443           'equal to'                  |  '=='  |  '='
4444           'not equal to'              |  '!='  |  '<>'
4445           'greater than'              |  '>'
4446           'less than'                 |  '<'
4447           'greater than or equal to'  |  '>='
4448           'less than or equal to'     |  '<='
4449
4450       You can either use Excel's textual description strings, in the first
4451       column above, or the more common operator alternatives. The following
4452       are equivalent:
4453
4454           validate => 'integer',
4455           criteria => 'greater than',
4456           value    => 100,
4457
4458           validate => 'integer',
4459           criteria => '>',
4460           value    => 100,
4461
4462       The "list" and "custom" validate options don't require a "criteria". If
4463       you specify one it will be ignored.
4464
4465           validate => 'list',
4466           value    => ['open', 'high', 'close'],
4467
4468           validate => 'custom',
4469           value    => '=IF(A10>B10,TRUE,FALSE)',
4470
4471   value | minimum | source
4472       This parameter is passed in a hash ref to "data_validation()".
4473
4474       The "value" parameter is used to set the limiting value to which the
4475       "criteria" is applied. It is always required and it has no default
4476       value. You can also use the synonyms "minimum" or "source" to make the
4477       validation a little clearer and closer to Excel's description of the
4478       parameter:
4479
4480           # Use 'value'
4481           validate => 'integer',
4482           criteria => '>',
4483           value    => 100,
4484
4485           # Use 'minimum'
4486           validate => 'integer',
4487           criteria => 'between',
4488           minimum  => 1,
4489           maximum  => 100,
4490
4491           # Use 'source'
4492           validate => 'list',
4493           source   => 'B1:B3',
4494
4495   maximum
4496       This parameter is passed in a hash ref to "data_validation()".
4497
4498       The "maximum" parameter is used to set the upper limiting value when
4499       the "criteria" is either 'between' or 'not between':
4500
4501           validate => 'integer',
4502           criteria => 'between',
4503           minimum  => 1,
4504           maximum  => 100,
4505
4506   ignore_blank
4507       This parameter is passed in a hash ref to "data_validation()".
4508
4509       The "ignore_blank" parameter is used to toggle on and off the 'Ignore
4510       blank' option in the Excel data validation dialog. When the option is
4511       on the data validation is not applied to blank data in the cell. It is
4512       on by default.
4513
4514           ignore_blank => 0,  # Turn the option off
4515
4516   dropdown
4517       This parameter is passed in a hash ref to "data_validation()".
4518
4519       The "dropdown" parameter is used to toggle on and off the 'In-cell
4520       dropdown' option in the Excel data validation dialog. When the option
4521       is on a dropdown list will be shown for "list" validations. It is on by
4522       default.
4523
4524           dropdown => 0,      # Turn the option off
4525
4526   input_title
4527       This parameter is passed in a hash ref to "data_validation()".
4528
4529       The "input_title" parameter is used to set the title of the input
4530       message that is displayed when a cell is entered. It has no default
4531       value and is only displayed if the input message is displayed. See the
4532       "input_message" parameter below.
4533
4534           input_title   => 'This is the input title',
4535
4536       The maximum title length is 32 characters. UTF8 strings are handled
4537       automatically in perl 5.8 and later.
4538
4539   input_message
4540       This parameter is passed in a hash ref to "data_validation()".
4541
4542       The "input_message" parameter is used to set the input message that is
4543       displayed when a cell is entered. It has no default value.
4544
4545           validate      => 'integer',
4546           criteria      => 'between',
4547           minimum       => 1,
4548           maximum       => 100,
4549           input_title   => 'Enter the applied discount:',
4550           input_message => 'between 1 and 100',
4551
4552       The message can be split over several lines using newlines, "\n" in
4553       double quoted strings.
4554
4555           input_message => "This is\na test.",
4556
4557       The maximum message length is 255 characters. UTF8 strings are handled
4558       automatically in perl 5.8 and later.
4559
4560   show_input
4561       This parameter is passed in a hash ref to "data_validation()".
4562
4563       The "show_input" parameter is used to toggle on and off the 'Show input
4564       message when cell is selected' option in the Excel data validation
4565       dialog. When the option is off an input message is not displayed even
4566       if it has been set using "input_message". It is on by default.
4567
4568           show_input => 0,      # Turn the option off
4569
4570   error_title
4571       This parameter is passed in a hash ref to "data_validation()".
4572
4573       The "error_title" parameter is used to set the title of the error
4574       message that is displayed when the data validation criteria is not met.
4575       The default error title is 'Microsoft Excel'.
4576
4577           error_title   => 'Input value is not valid',
4578
4579       The maximum title length is 32 characters. UTF8 strings are handled
4580       automatically in perl 5.8 and later.
4581
4582   error_message
4583       This parameter is passed in a hash ref to "data_validation()".
4584
4585       The "error_message" parameter is used to set the error message that is
4586       displayed when a cell is entered. The default error message is "The
4587       value you entered is not valid.\nA user has restricted values that can
4588       be entered into the cell.".
4589
4590           validate      => 'integer',
4591           criteria      => 'between',
4592           minimum       => 1,
4593           maximum       => 100,
4594           error_title   => 'Input value is not valid',
4595           error_message => 'It should be an integer between 1 and 100',
4596
4597       The message can be split over several lines using newlines, "\n" in
4598       double quoted strings.
4599
4600           input_message => "This is\na test.",
4601
4602       The maximum message length is 255 characters. UTF8 strings are handled
4603       automatically in perl 5.8 and later.
4604
4605   error_type
4606       This parameter is passed in a hash ref to "data_validation()".
4607
4608       The "error_type" parameter is used to specify the type of error dialog
4609       that is displayed. There are 3 options:
4610
4611           'stop'
4612           'warning'
4613           'information'
4614
4615       The default is 'stop'.
4616
4617   show_error
4618       This parameter is passed in a hash ref to "data_validation()".
4619
4620       The "show_error" parameter is used to toggle on and off the 'Show error
4621       alert after invalid data is entered' option in the Excel data
4622       validation dialog. When the option is off an error message is not
4623       displayed even if it has been set using "error_message". It is on by
4624       default.
4625
4626           show_error => 0,      # Turn the option off
4627
4628   Data Validation Examples
4629       Example 1. Limiting input to an integer greater than a fixed value.
4630
4631           $worksheet->data_validation('A1',
4632               {
4633                   validate        => 'integer',
4634                   criteria        => '>',
4635                   value           => 0,
4636               });
4637
4638       Example 2. Limiting input to an integer greater than a fixed value
4639       where the value is referenced from a cell.
4640
4641           $worksheet->data_validation('A2',
4642               {
4643                   validate        => 'integer',
4644                   criteria        => '>',
4645                   value           => '=E3',
4646               });
4647
4648       Example 3. Limiting input to a decimal in a fixed range.
4649
4650           $worksheet->data_validation('A3',
4651               {
4652                   validate        => 'decimal',
4653                   criteria        => 'between',
4654                   minimum         => 0.1,
4655                   maximum         => 0.5,
4656               });
4657
4658       Example 4. Limiting input to a value in a dropdown list.
4659
4660           $worksheet->data_validation('A4',
4661               {
4662                   validate        => 'list',
4663                   source          => ['open', 'high', 'close'],
4664               });
4665
4666       Example 5. Limiting input to a value in a dropdown list where the list
4667       is specified as a cell range.
4668
4669           $worksheet->data_validation('A5',
4670               {
4671                   validate        => 'list',
4672                   source          => '=E4:G4',
4673               });
4674
4675       Example 6. Limiting input to a date in a fixed range.
4676
4677           $worksheet->data_validation('A6',
4678               {
4679                   validate        => 'date',
4680                   criteria        => 'between',
4681                   minimum         => '2008-01-01T',
4682                   maximum         => '2008-12-12T',
4683               });
4684
4685       Example 7. Displaying a message when the cell is selected.
4686
4687           $worksheet->data_validation('A7',
4688               {
4689                   validate      => 'integer',
4690                   criteria      => 'between',
4691                   minimum       => 1,
4692                   maximum       => 100,
4693                   input_title   => 'Enter an integer:',
4694                   input_message => 'between 1 and 100',
4695               });
4696
4697       See also the "data_validate.pl" program in the examples directory of
4698       the distro.
4699

FORMULAS AND FUNCTIONS IN EXCEL

4701   Caveats
4702       The first thing to note is that there are still some outstanding issues
4703       with the implementation of formulas and functions:
4704
4705           1. Writing a formula is much slower than writing the equivalent string.
4706           2. You cannot use array constants, i.e. {1;2;3}, in functions.
4707           3. Unary minus isn't supported.
4708           4. Whitespace is not preserved around operators.
4709           5. Named ranges are not supported.
4710           6. Array formulas are not supported.
4711
4712       However, these constraints will be removed in future versions. They are
4713       here because of a trade-off between features and time. Also, it is
4714       possible to work around issue 1 using the "store_formula()" and
4715       "repeat_formula()" methods as described later in this section.
4716
4717   Introduction
4718       The following is a brief introduction to formulas and functions in
4719       Excel and Spreadsheet::WriteExcel.
4720
4721       A formula is a string that begins with an equals sign:
4722
4723           '=A1+B1'
4724           '=AVERAGE(1, 2, 3)'
4725
4726       The formula can contain numbers, strings, boolean values, cell
4727       references, cell ranges and functions. Named ranges are not supported.
4728       Formulas should be written as they appear in Excel, that is cells and
4729       functions must be in uppercase.
4730
4731       Cells in Excel are referenced using the A1 notation system where the
4732       column is designated by a letter and the row by a number. Columns range
4733       from A to IV i.e. 0 to 255, rows range from 1 to 65536. The
4734       "Spreadsheet::WriteExcel::Utility" module that is included in the
4735       distro contains helper functions for dealing with A1 notation, for
4736       example:
4737
4738           use Spreadsheet::WriteExcel::Utility;
4739
4740           ($row, $col) = xl_cell_to_rowcol('C2');  # (1, 2)
4741           $str         = xl_rowcol_to_cell(1, 2);  # C2
4742
4743       The Excel "$" notation in cell references is also supported. This
4744       allows you to specify whether a row or column is relative or absolute.
4745       This only has an effect if the cell is copied. The following examples
4746       show relative and absolute values.
4747
4748           '=A1'   # Column and row are relative
4749           '=$A1'  # Column is absolute and row is relative
4750           '=A$1'  # Column is relative and row is absolute
4751           '=$A$1' # Column and row are absolute
4752
4753       Formulas can also refer to cells in other worksheets of the current
4754       workbook. For example:
4755
4756           '=Sheet2!A1'
4757           '=Sheet2!A1:A5'
4758           '=Sheet2:Sheet3!A1'
4759           '=Sheet2:Sheet3!A1:A5'
4760           q{='Test Data'!A1}
4761           q{='Test Data1:Test Data2'!A1}
4762
4763       The sheet reference and the cell reference are separated by  "!" the
4764       exclamation mark symbol. If worksheet names contain spaces, commas o
4765       parentheses then Excel requires that the name is enclosed in single
4766       quotes as shown in the last two examples above. In order to avoid using
4767       a lot of escape characters you can use the quote operator "q{}" to
4768       protect the quotes. See "perlop" in the main Perl documentation. Only
4769       valid sheet names that have been added using the "add_worksheet()"
4770       method can be used in formulas. You cannot reference external
4771       workbooks.
4772
4773       The following table lists the operators that are available in Excel's
4774       formulas. The majority of the operators are the same as Perl's,
4775       differences are indicated:
4776
4777           Arithmetic operators:
4778           =====================
4779           Operator  Meaning                   Example
4780              +      Addition                  1+2
4781              -      Subtraction               2-1
4782              *      Multiplication            2*3
4783              /      Division                  1/4
4784              ^      Exponentiation            2^3      # Equivalent to **
4785              -      Unary minus               -(1+2)   # Not yet supported
4786              %      Percent (Not modulus)     13%      # Not supported, [1]
4787
4788
4789           Comparison operators:
4790           =====================
4791           Operator  Meaning                   Example
4792               =     Equal to                  A1 =  B1 # Equivalent to ==
4793               <>    Not equal to              A1 <> B1 # Equivalent to !=
4794               >     Greater than              A1 >  B1
4795               <     Less than                 A1 <  B1
4796               >=    Greater than or equal to  A1 >= B1
4797               <=    Less than or equal to     A1 <= B1
4798
4799
4800           String operator:
4801           ================
4802           Operator  Meaning                   Example
4803               &     Concatenation             "Hello " & "World!" # [2]
4804
4805
4806           Reference operators:
4807           ====================
4808           Operator  Meaning                   Example
4809               :     Range operator            A1:A4               # [3]
4810               ,     Union operator            SUM(1, 2+2, B3)     # [4]
4811
4812
4813           Notes:
4814           [1]: You can get a percentage with formatting and modulus with MOD().
4815           [2]: Equivalent to ("Hello " . "World!") in Perl.
4816           [3]: This range is equivalent to cells A1, A2, A3 and A4.
4817           [4]: The comma behaves like the list separator in Perl.
4818
4819       The range and comma operators can have different symbols in non-English
4820       versions of Excel. These will be supported in a later version of
4821       Spreadsheet::WriteExcel. European users of Excel take note:
4822
4823           $worksheet->write('A1', '=SUM(1; 2; 3)'); # Wrong!!
4824           $worksheet->write('A1', '=SUM(1, 2, 3)'); # Okay
4825
4826       The following table lists all of the core functions supported by Excel
4827       5 and Spreadsheet::WriteExcel. Any additional functions that are
4828       available through the "Analysis ToolPak" or other add-ins are not
4829       supported. These functions have all been tested to verify that they
4830       work.
4831
4832           ABS           DB            INDIRECT      NORMINV       SLN
4833           ACOS          DCOUNT        INFO          NORMSDIST     SLOPE
4834           ACOSH         DCOUNTA       INT           NORMSINV      SMALL
4835           ADDRESS       DDB           INTERCEPT     NOT           SQRT
4836           AND           DEGREES       IPMT          NOW           STANDARDIZE
4837           AREAS         DEVSQ         IRR           NPER          STDEV
4838           ASIN          DGET          ISBLANK       NPV           STDEVP
4839           ASINH         DMAX          ISERR         ODD           STEYX
4840           ATAN          DMIN          ISERROR       OFFSET        SUBSTITUTE
4841           ATAN2         DOLLAR        ISLOGICAL     OR            SUBTOTAL
4842           ATANH         DPRODUCT      ISNA          PEARSON       SUM
4843           AVEDEV        DSTDEV        ISNONTEXT     PERCENTILE    SUMIF
4844           AVERAGE       DSTDEVP       ISNUMBER      PERCENTRANK   SUMPRODUCT
4845           BETADIST      DSUM          ISREF         PERMUT        SUMSQ
4846           BETAINV       DVAR          ISTEXT        PI            SUMX2MY2
4847           BINOMDIST     DVARP         KURT          PMT           SUMX2PY2
4848           CALL          ERROR.TYPE    LARGE         POISSON       SUMXMY2
4849           CEILING       EVEN          LEFT          POWER         SYD
4850           CELL          EXACT         LEN           PPMT          T
4851           CHAR          EXP           LINEST        PROB          TAN
4852           CHIDIST       EXPONDIST     LN            PRODUCT       TANH
4853           CHIINV        FACT          LOG           PROPER        TDIST
4854           CHITEST       FALSE         LOG10         PV            TEXT
4855           CHOOSE        FDIST         LOGEST        QUARTILE      TIME
4856           CLEAN         FIND          LOGINV        RADIANS       TIMEVALUE
4857           CODE          FINV          LOGNORMDIST   RAND          TINV
4858           COLUMN        FISHER        LOOKUP        RANK          TODAY
4859           COLUMNS       FISHERINV     LOWER         RATE          TRANSPOSE
4860           COMBIN        FIXED         MATCH         REGISTER.ID   TREND
4861           CONCATENATE   FLOOR         MAX           REPLACE       TRIM
4862           CONFIDENCE    FORECAST      MDETERM       REPT          TRIMMEAN
4863           CORREL        FREQUENCY     MEDIAN        RIGHT         TRUE
4864           COS           FTEST         MID           ROMAN         TRUNC
4865           COSH          FV            MIN           ROUND         TTEST
4866           COUNT         GAMMADIST     MINUTE        ROUNDDOWN     TYPE
4867           COUNTA        GAMMAINV      MINVERSE      ROUNDUP       UPPER
4868           COUNTBLANK    GAMMALN       MIRR          ROW           VALUE
4869           COUNTIF       GEOMEAN       MMULT         ROWS          VAR
4870           COVAR         GROWTH        MOD           RSQ           VARP
4871           CRITBINOM     HARMEAN       MODE          SEARCH        VDB
4872           DATE          HLOOKUP       MONTH         SECOND        VLOOKUP
4873           DATEVALUE     HOUR          N             SIGN          WEEKDAY
4874           DAVERAGE      HYPGEOMDIST   NA            SIN           WEIBULL
4875           DAY           IF            NEGBINOMDIST  SINH          YEAR
4876           DAYS360       INDEX         NORMDIST      SKEW          ZTEST
4877
4878       You can also modify the module to support function names in the
4879       following languages: German, French, Spanish, Portuguese, Dutch,
4880       Finnish, Italian and Swedish. See the "function_locale.pl" program in
4881       the "examples" directory of the distro.
4882
4883       For a general introduction to Excel's formulas and an explanation of
4884       the syntax of the function refer to the Excel help files or the
4885       following:
4886       http://office.microsoft.com/en-us/assistance/CH062528031033.aspx
4887       <http://office.microsoft.com/en-us/assistance/CH062528031033.aspx>.
4888
4889       If your formula doesn't work in Spreadsheet::WriteExcel try the
4890       following:
4891
4892           1. Verify that the formula works in Excel (or Gnumeric or OpenOffice.org).
4893           2. Ensure that it isn't on the Caveats list shown above.
4894           3. Ensure that cell references and formula names are in uppercase.
4895           4. Ensure that you are using ':' as the range operator, A1:A4.
4896           5. Ensure that you are using ',' as the union operator, SUM(1,2,3).
4897           6. Ensure that the function is in the above table.
4898
4899       If you go through steps 1-6 and you still have a problem, mail me.
4900
4901   Improving performance when working with formulas
4902       Writing a large number of formulas with Spreadsheet::WriteExcel can be
4903       slow. This is due to the fact that each formula has to be parsed and
4904       with the current implementation this is computationally expensive.
4905
4906       However, in a lot of cases the formulas that you write will be quite
4907       similar, for example:
4908
4909           $worksheet->write_formula('B1',    '=A1 * 3 + 50',    $format);
4910           $worksheet->write_formula('B2',    '=A2 * 3 + 50',    $format);
4911           ...
4912           ...
4913           $worksheet->write_formula('B99',   '=A999 * 3 + 50',  $format);
4914           $worksheet->write_formula('B1000', '=A1000 * 3 + 50', $format);
4915
4916       In this example the cell reference changes in iterations from "A1" to
4917       "A1000". The parser treats this variable as a token and arranges it
4918       according to predefined rules. However, since the parser is oblivious
4919       to the value of the token, it is essentially performing the same
4920       calculation 1000 times. This is inefficient.
4921
4922       The way to avoid this inefficiency and thereby speed up the writing of
4923       formulas is to parse the formula once and then repeatedly substitute
4924       similar tokens.
4925
4926       A formula can be parsed and stored via the "store_formula()" worksheet
4927       method. You can then use the "repeat_formula()" method to substitute
4928       $pattern, $replace pairs in the stored formula:
4929
4930           my $formula = $worksheet->store_formula('=A1 * 3 + 50');
4931
4932           for my $row (0..999) {
4933               $worksheet->repeat_formula($row, 1, $formula, $format, 'A1', 'A'.($row +1));
4934           }
4935
4936       On an arbitrary test machine this method was 10 times faster than the
4937       brute force method shown above.
4938
4939       For more information about how Spreadsheet::WriteExcel parses and
4940       stores formulas see the "Spreadsheet::WriteExcel::Formula" man page.
4941
4942       It should be noted however that the overall speed of direct formula
4943       parsing will be improved in a future version.
4944

EXAMPLES

4946       See Spreadsheet::WriteExcel::Examples for a full list of examples.
4947
4948   Example 1
4949       The following example shows some of the basic features of
4950       Spreadsheet::WriteExcel.
4951
4952           #!/usr/bin/perl -w
4953
4954           use strict;
4955           use Spreadsheet::WriteExcel;
4956
4957           # Create a new workbook called simple.xls and add a worksheet
4958           my $workbook  = Spreadsheet::WriteExcel->new('simple.xls');
4959           my $worksheet = $workbook->add_worksheet();
4960
4961           # The general syntax is write($row, $column, $token). Note that row and
4962           # column are zero indexed
4963
4964           # Write some text
4965           $worksheet->write(0, 0,  'Hi Excel!');
4966
4967
4968           # Write some numbers
4969           $worksheet->write(2, 0,  3);          # Writes 3
4970           $worksheet->write(3, 0,  3.00000);    # Writes 3
4971           $worksheet->write(4, 0,  3.00001);    # Writes 3.00001
4972           $worksheet->write(5, 0,  3.14159);    # TeX revision no.?
4973
4974
4975           # Write some formulas
4976           $worksheet->write(7, 0,  '=A3 + A6');
4977           $worksheet->write(8, 0,  '=IF(A5>3,"Yes", "No")');
4978
4979
4980           # Write a hyperlink
4981           $worksheet->write(10, 0, 'http://www.perl.com/');
4982
4983   Example 2
4984       The following is a general example which demonstrates some features of
4985       working with multiple worksheets.
4986
4987           #!/usr/bin/perl -w
4988
4989           use strict;
4990           use Spreadsheet::WriteExcel;
4991
4992           # Create a new Excel workbook
4993           my $workbook = Spreadsheet::WriteExcel->new('regions.xls');
4994
4995           # Add some worksheets
4996           my $north = $workbook->add_worksheet('North');
4997           my $south = $workbook->add_worksheet('South');
4998           my $east  = $workbook->add_worksheet('East');
4999           my $west  = $workbook->add_worksheet('West');
5000
5001           # Add a Format
5002           my $format = $workbook->add_format();
5003           $format->set_bold();
5004           $format->set_color('blue');
5005
5006           # Add a caption to each worksheet
5007           foreach my $worksheet ($workbook->sheets()) {
5008               $worksheet->write(0, 0, 'Sales', $format);
5009           }
5010
5011           # Write some data
5012           $north->write(0, 1, 200000);
5013           $south->write(0, 1, 100000);
5014           $east->write (0, 1, 150000);
5015           $west->write (0, 1, 100000);
5016
5017           # Set the active worksheet
5018           $south->activate();
5019
5020           # Set the width of the first column
5021           $south->set_column(0, 0, 20);
5022
5023           # Set the active cell
5024           $south->set_selection(0, 1);
5025
5026   Example 3
5027       This example shows how to use a conditional numerical format with
5028       colours to indicate if a share price has gone up or down.
5029
5030           use strict;
5031           use Spreadsheet::WriteExcel;
5032
5033           # Create a new workbook and add a worksheet
5034           my $workbook  = Spreadsheet::WriteExcel->new('stocks.xls');
5035           my $worksheet = $workbook->add_worksheet();
5036
5037           # Set the column width for columns 1, 2, 3 and 4
5038           $worksheet->set_column(0, 3, 15);
5039
5040
5041           # Create a format for the column headings
5042           my $header = $workbook->add_format();
5043           $header->set_bold();
5044           $header->set_size(12);
5045           $header->set_color('blue');
5046
5047
5048           # Create a format for the stock price
5049           my $f_price = $workbook->add_format();
5050           $f_price->set_align('left');
5051           $f_price->set_num_format('$0.00');
5052
5053
5054           # Create a format for the stock volume
5055           my $f_volume = $workbook->add_format();
5056           $f_volume->set_align('left');
5057           $f_volume->set_num_format('#,##0');
5058
5059
5060           # Create a format for the price change. This is an example of a
5061           # conditional format. The number is formatted as a percentage. If it is
5062           # positive it is formatted in green, if it is negative it is formatted
5063           # in red and if it is zero it is formatted as the default font colour
5064           # (in this case black). Note: the [Green] format produces an unappealing
5065           # lime green. Try [Color 10] instead for a dark green.
5066           #
5067           my $f_change = $workbook->add_format();
5068           $f_change->set_align('left');
5069           $f_change->set_num_format('[Green]0.0%;[Red]-0.0%;0.0%');
5070
5071
5072           # Write out the data
5073           $worksheet->write(0, 0, 'Company',$header);
5074           $worksheet->write(0, 1, 'Price',  $header);
5075           $worksheet->write(0, 2, 'Volume', $header);
5076           $worksheet->write(0, 3, 'Change', $header);
5077
5078           $worksheet->write(1, 0, 'Damage Inc.'       );
5079           $worksheet->write(1, 1, 30.25,    $f_price ); # $30.25
5080           $worksheet->write(1, 2, 1234567,  $f_volume); # 1,234,567
5081           $worksheet->write(1, 3, 0.085,    $f_change); # 8.5% in green
5082
5083           $worksheet->write(2, 0, 'Dump Corp.'        );
5084           $worksheet->write(2, 1, 1.56,     $f_price ); # $1.56
5085           $worksheet->write(2, 2, 7564,     $f_volume); # 7,564
5086           $worksheet->write(2, 3, -0.015,   $f_change); # -1.5% in red
5087
5088           $worksheet->write(3, 0, 'Rev Ltd.'          );
5089           $worksheet->write(3, 1, 0.13,     $f_price ); # $0.13
5090           $worksheet->write(3, 2, 321,      $f_volume); # 321
5091           $worksheet->write(3, 3, 0,        $f_change); # 0 in the font color (black)
5092
5093   Example 4
5094       The following is a simple example of using functions.
5095
5096           #!/usr/bin/perl -w
5097
5098           use strict;
5099           use Spreadsheet::WriteExcel;
5100
5101           # Create a new workbook and add a worksheet
5102           my $workbook  = Spreadsheet::WriteExcel->new('stats.xls');
5103           my $worksheet = $workbook->add_worksheet('Test data');
5104
5105           # Set the column width for columns 1
5106           $worksheet->set_column(0, 0, 20);
5107
5108
5109           # Create a format for the headings
5110           my $format = $workbook->add_format();
5111           $format->set_bold();
5112
5113
5114           # Write the sample data
5115           $worksheet->write(0, 0, 'Sample', $format);
5116           $worksheet->write(0, 1, 1);
5117           $worksheet->write(0, 2, 2);
5118           $worksheet->write(0, 3, 3);
5119           $worksheet->write(0, 4, 4);
5120           $worksheet->write(0, 5, 5);
5121           $worksheet->write(0, 6, 6);
5122           $worksheet->write(0, 7, 7);
5123           $worksheet->write(0, 8, 8);
5124
5125           $worksheet->write(1, 0, 'Length', $format);
5126           $worksheet->write(1, 1, 25.4);
5127           $worksheet->write(1, 2, 25.4);
5128           $worksheet->write(1, 3, 24.8);
5129           $worksheet->write(1, 4, 25.0);
5130           $worksheet->write(1, 5, 25.3);
5131           $worksheet->write(1, 6, 24.9);
5132           $worksheet->write(1, 7, 25.2);
5133           $worksheet->write(1, 8, 24.8);
5134
5135           # Write some statistical functions
5136           $worksheet->write(4,  0, 'Count', $format);
5137           $worksheet->write(4,  1, '=COUNT(B1:I1)');
5138
5139           $worksheet->write(5,  0, 'Sum', $format);
5140           $worksheet->write(5,  1, '=SUM(B2:I2)');
5141
5142           $worksheet->write(6,  0, 'Average', $format);
5143           $worksheet->write(6,  1, '=AVERAGE(B2:I2)');
5144
5145           $worksheet->write(7,  0, 'Min', $format);
5146           $worksheet->write(7,  1, '=MIN(B2:I2)');
5147
5148           $worksheet->write(8,  0, 'Max', $format);
5149           $worksheet->write(8,  1, '=MAX(B2:I2)');
5150
5151           $worksheet->write(9,  0, 'Standard Deviation', $format);
5152           $worksheet->write(9,  1, '=STDEV(B2:I2)');
5153
5154           $worksheet->write(10, 0, 'Kurtosis', $format);
5155           $worksheet->write(10, 1, '=KURT(B2:I2)');
5156
5157   Example 5
5158       The following example converts a tab separated file called "tab.txt"
5159       into an Excel file called "tab.xls".
5160
5161           #!/usr/bin/perl -w
5162
5163           use strict;
5164           use Spreadsheet::WriteExcel;
5165
5166           open (TABFILE, 'tab.txt') or die "tab.txt: $!";
5167
5168           my $workbook  = Spreadsheet::WriteExcel->new('tab.xls');
5169           my $worksheet = $workbook->add_worksheet();
5170
5171           # Row and column are zero indexed
5172           my $row = 0;
5173
5174           while (<TABFILE>) {
5175               chomp;
5176               # Split on single tab
5177               my @Fld = split('\t', $_);
5178
5179               my $col = 0;
5180               foreach my $token (@Fld) {
5181                   $worksheet->write($row, $col, $token);
5182                   $col++;
5183               }
5184               $row++;
5185           }
5186
5187       NOTE: This is a simple conversion program for illustrative purposes
5188       only. For converting a CSV or Tab separated or any other type of
5189       delimited text file to Excel I recommend the more rigorous csv2xls
5190       program that is part of H.Merijn Brand's Text::CSV_XS module distro.
5191
5192       See the examples/csv2xls link here:
5193       http://search.cpan.org/~hmbrand/Text-CSV_XS/MANIFEST
5194       <http://search.cpan.org/~hmbrand/Text-CSV_XS/MANIFEST>.
5195
5196   Additional Examples
5197       The following is a description of the example files that are provided
5198       in the standard Spreadsheet::WriteExcel distribution. They demonstrate
5199       the different features and options of the module.  See
5200       Spreadsheet::WriteExcel::Examples for more details.
5201
5202           Getting started
5203           ===============
5204           a_simple.pl             A get started example with some basic features.
5205           demo.pl                 A demo of some of the available features.
5206           regions.pl              A simple example of multiple worksheets.
5207           stats.pl                Basic formulas and functions.
5208           formats.pl              All the available formatting on several worksheets.
5209           bug_report.pl           A template for submitting bug reports.
5210
5211
5212           Advanced
5213           ========
5214           autofilter.pl           Examples of worksheet autofilters.
5215           autofit.pl              Simulate Excel's autofit for column widths.
5216           bigfile.pl              Write past the 7MB limit with OLE::Storage_Lite.
5217           cgi.pl                  A simple CGI program.
5218           chart_area.pl           A demo of area style charts.
5219           chart_bar.pl            A demo of bar (vertical histogram) style charts.
5220           chart_column.pl         A demo of column (histogram) style charts.
5221           chart_line.pl           A demo of line style charts.
5222           chart_pie.pl            A demo of pie style charts.
5223           chart_scatter.pl        A demo of scatter style charts.
5224           chart_stock.pl          A demo of stock style charts.
5225           chess.pl                An example of reusing formatting via properties.
5226           colors.pl               A demo of the colour palette and named colours.
5227           comments1.pl            Add comments to worksheet cells.
5228           comments2.pl            Add comments with advanced options.
5229           copyformat.pl           Example of copying a cell format.
5230           data_validate.pl        An example of data validation and dropdown lists.
5231           date_time.pl            Write dates and times with write_date_time().
5232           defined_name.pl         Example of how to create defined names.
5233           diag_border.pl          A simple example of diagonal cell borders.
5234           easter_egg.pl           Expose the Excel97 flight simulator.
5235           filehandle.pl           Examples of working with filehandles.
5236           formula_result.pl       Formulas with user specified results.
5237           headers.pl              Examples of worksheet headers and footers.
5238           hide_sheet.pl           Simple example of hiding a worksheet.
5239           hyperlink1.pl           Shows how to create web hyperlinks.
5240           hyperlink2.pl           Examples of internal and external hyperlinks.
5241           images.pl               Adding images to worksheets.
5242           indent.pl               An example of cell indentation.
5243           merge1.pl               A simple example of cell merging.
5244           merge2.pl               A simple example of cell merging with formatting.
5245           merge3.pl               Add hyperlinks to merged cells.
5246           merge4.pl               An advanced example of merging with formatting.
5247           merge5.pl               An advanced example of merging with formatting.
5248           merge6.pl               An example of merging with Unicode strings.
5249           mod_perl1.pl            A simple mod_perl 1 program.
5250           mod_perl2.pl            A simple mod_perl 2 program.
5251           outline.pl              An example of outlines and grouping.
5252           outline_collapsed.pl    An example of collapsed outlines.
5253           panes.pl                An examples of how to create panes.
5254           properties.pl           Add document properties to a workbook.
5255           protection.pl           Example of cell locking and formula hiding.
5256           repeat.pl               Example of writing repeated formulas.
5257           right_to_left.pl        Change default sheet direction to right to left.
5258           row_wrap.pl             How to wrap data from one worksheet onto another.
5259           sales.pl                An example of a simple sales spreadsheet.
5260           sendmail.pl             Send an Excel email attachment using Mail::Sender.
5261           stats_ext.pl            Same as stats.pl with external references.
5262           stocks.pl               Demonstrates conditional formatting.
5263           tab_colors.pl           Example of how to set worksheet tab colours.
5264           textwrap.pl             Demonstrates text wrapping options.
5265           win32ole.pl             A sample Win32::OLE example for comparison.
5266           write_arrays.pl         Example of writing 1D or 2D arrays of data.
5267           write_handler1.pl       Example of extending the write() method. Step 1.
5268           write_handler2.pl       Example of extending the write() method. Step 2.
5269           write_handler3.pl       Example of extending the write() method. Step 3.
5270           write_handler4.pl       Example of extending the write() method. Step 4.
5271           write_to_scalar.pl      Example of writing an Excel file to a Perl scalar.
5272
5273
5274           Unicode
5275           =======
5276           unicode_utf16.pl        Simple example of using Unicode UTF16 strings.
5277           unicode_utf16_japan.pl  Write Japanese Unicode strings using UTF-16.
5278           unicode_cyrillic.pl     Write Russian Cyrillic strings using UTF-8.
5279           unicode_list.pl         List the chars in a Unicode font.
5280           unicode_2022_jp.pl      Japanese: ISO-2022-JP to utf8 in perl 5.8.
5281           unicode_8859_11.pl      Thai:     ISO-8859_11 to utf8 in perl 5.8.
5282           unicode_8859_7.pl       Greek:    ISO-8859_7  to utf8 in perl 5.8.
5283           unicode_big5.pl         Chinese:  BIG5        to utf8 in perl 5.8.
5284           unicode_cp1251.pl       Russian:  CP1251      to utf8 in perl 5.8.
5285           unicode_cp1256.pl       Arabic:   CP1256      to utf8 in perl 5.8.
5286           unicode_koi8r.pl        Russian:  KOI8-R      to utf8 in perl 5.8.
5287           unicode_polish_utf8.pl  Polish :  UTF8        to utf8 in perl 5.8.
5288           unicode_shift_jis.pl    Japanese: Shift JIS   to utf8 in perl 5.8.
5289
5290
5291           Utility
5292           =======
5293           csv2xls.pl              Program to convert a CSV file to an Excel file.
5294           tab2xls.pl              Program to convert a tab separated file to xls.
5295           datecalc1.pl            Convert Unix/Perl time to Excel time.
5296           datecalc2.pl            Calculate an Excel date using Date::Calc.
5297           lecxe.pl                Convert Excel to WriteExcel using Win32::OLE.
5298
5299
5300           Developer
5301           =========
5302           convertA1.pl            Helper functions for dealing with A1 notation.
5303           function_locale.pl      Add non-English function names to Formula.pm.
5304           writeA1.pl              Example of how to extend the module.
5305

LIMITATIONS

5307       The following limits are imposed by Excel:
5308
5309           Description                          Limit
5310           -----------------------------------  ------
5311           Maximum number of chars in a string  32767
5312           Maximum number of columns            256
5313           Maximum number of rows               65536
5314           Maximum chars in a sheet name        31
5315           Maximum chars in a header/footer     254
5316
5317       The minimum file size is 6K due to the OLE overhead. The maximum file
5318       size is approximately 7MB (7087104 bytes) of BIFF data. This can be
5319       extended by installing Takanori Kawai's OLE::Storage_Lite module
5320       http://search.cpan.org/search?dist=OLE-Storage_Lite
5321       <http://search.cpan.org/search?dist=OLE-Storage_Lite> see the
5322       "bigfile.pl" example in the "examples" directory of the distro.
5323

DOWNLOADING

5325       The latest version of this module is always available at:
5326       http://search.cpan.org/search?dist=Spreadsheet-WriteExcel/
5327       <http://search.cpan.org/search?dist=Spreadsheet-WriteExcel/>.
5328

REQUIREMENTS

5330       This module requires Perl >= 5.005, Parse::RecDescent, File::Temp and
5331       OLE::Storage_Lite:
5332
5333           http://search.cpan.org/search?dist=Parse-RecDescent/ # For formulas.
5334           http://search.cpan.org/search?dist=File-Temp/        # For set_tempdir().
5335           http://search.cpan.org/search?dist=OLE-Storage_Lite/ # For files > 7MB.
5336
5337       Note, these aren't strict requirements. Spreadsheet::WriteExcel will
5338       work without these modules if you don't use write_formula(),
5339       set_tempdir() or create files greater than 7MB. However, it is best to
5340       install them if possible and they will be installed automatically if
5341       you use a tool such as CPAN.pm or ppm.
5342

INSTALLATION

5344       See the INSTALL or install.html docs that come with the distribution
5345       or:
5346       http://search.cpan.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.31/INSTALL
5347       <http://search.cpan.org/src/JMCNAMARA/Spreadsheet-
5348       WriteExcel-2.31/INSTALL>.
5349

PORTABILITY

5351       Spreadsheet::WriteExcel will work on the majority of Windows, UNIX and
5352       Macintosh platforms. Specifically, the module will work on any system
5353       where perl packs floats in the 64 bit IEEE format. The float must also
5354       be in little-endian format but it will be reversed if necessary. Thus:
5355
5356           print join(' ', map { sprintf '%#02x', $_ } unpack('C*', pack 'd', 1.2345)), "\n";
5357
5358       should give (or in reverse order):
5359
5360           0x8d 0x97 0x6e 0x12 0x83 0xc0 0xf3 0x3f
5361
5362       In general, if you don't know whether your system supports a 64 bit
5363       IEEE float or not, it probably does. If your system doesn't, WriteExcel
5364       will "croak()" with the message given in the DIAGNOSTICS section. You
5365       can check which platforms the module has been tested on at the CPAN
5366       testers site:
5367       http://testers.cpan.org/search?request=dist&dist=Spreadsheet-WriteExcel
5368       <http://testers.cpan.org/search?request=dist&dist=Spreadsheet-
5369       WriteExcel>.
5370

DIAGNOSTICS

5372       Filename required by Spreadsheet::WriteExcel->new()
5373           A filename must be given in the constructor.
5374
5375       Can't open filename. It may be in use or protected.
5376           The file cannot be opened for writing. The directory that you are
5377           writing to  may be protected or the file may be in use by another
5378           program.
5379
5380       Unable to create tmp files via File::Temp::tempfile()...
5381           This is a "-w" warning. You will see it if you are using
5382           Spreadsheet::WriteExcel in an environment where temporary files
5383           cannot be created, in which case all data will be stored in memory.
5384           The warning is for information only: it does not affect creation
5385           but it will affect the speed of execution for large files. See the
5386           "set_tempdir" workbook method.
5387
5388       Maximum file size, 7087104, exceeded.
5389           The current OLE implementation only supports a maximum BIFF file of
5390           this size. This limit can be extended, see the LIMITATIONS section.
5391
5392       Can't locate Parse/RecDescent.pm in @INC ...
5393           Spreadsheet::WriteExcel requires the Parse::RecDescent module.
5394           Download it from CPAN:
5395           http://search.cpan.org/search?dist=Parse-RecDescent
5396           <http://search.cpan.org/search?dist=Parse-RecDescent>
5397
5398       Couldn't parse formula ...
5399           There are a large number of warnings which relate to badly formed
5400           formulas and functions. See the "FORMULAS AND FUNCTIONS IN EXCEL"
5401           section for suggestions on how to avoid these errors. You should
5402           also check the formula in Excel to ensure that it is valid.
5403
5404       Required floating point format not supported on this platform.
5405           Operating system doesn't support 64 bit IEEE float or it is byte-
5406           ordered in a way unknown to WriteExcel.
5407
5408       'file.xls' cannot be accessed. The file may be read-only ...
5409           You may sometimes encounter the following error when trying to open
5410           a file in Excel: "file.xls cannot be accessed. The file may be
5411           read-only, or you may be trying to access a read-only location. Or,
5412           the server the document is stored on may not be responding."
5413
5414           This error generally means that the Excel file has been corrupted.
5415           There are two likely causes of this: the file was FTPed in ASCII
5416           mode instead of binary mode or else the file was created with
5417           "UTF-8" data returned by an XML parser. See "Warning about
5418           XML::Parser and perl 5.6" for further details.
5419

THE EXCEL BINARY FORMAT

5421       The following is some general information about the Excel binary format
5422       for anyone who may be interested.
5423
5424       Excel data is stored in the "Binary Interchange File Format" (BIFF)
5425       file format. Details of this format are given in "Excel 97-2007 Binary
5426       File Format Specification"
5427       <http://www.microsoft.com/interop/docs/OfficeBinaryFormats.mspx>.
5428
5429       Daniel Rentz of OpenOffice.org has also written a detailed description
5430       of the Excel workbook records, see
5431       <http://sc.openoffice.org/excelfileformat.pdf>.
5432
5433       Charles Wybble has collected together additional information about the
5434       Excel file format. See "The Chicago Project" at
5435       <http://chicago.sourceforge.net/devel/>.
5436
5437       The BIFF data is stored along with other data in an OLE Compound File.
5438       This is a structured storage which acts like a file system within a
5439       file. A Compound File is comprised of storages and streams which, to
5440       follow the file system analogy, are like directories and files.
5441
5442       The OLE format is explained in the "Windows Compound Binary File Format
5443       Specification"
5444       <http://www.microsoft.com/interop/docs/supportingtechnologies.mspx>
5445
5446       The Digital Imaging Group have also detailed the OLE format in the
5447       JPEG2000 specification: see Appendix A of
5448       <http://www.i3a.org/pdf/wg1n1017.pdf>.
5449
5450       Please note that the provision of this information does not constitute
5451       an invitation to start hacking at the BIFF or OLE file formats. There
5452       are more interesting ways to waste your time. ;-)
5453

WRITING EXCEL FILES

5455       Depending on your requirements, background and general sensibilities
5456       you may prefer one of the following methods of getting data into Excel:
5457
5458       ·   Win32::OLE module and office automation
5459
5460           This requires a Windows platform and an installed copy of Excel.
5461           This is the most powerful and complete method for interfacing with
5462           Excel. See
5463           http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/faq/Windows/ActivePerl-Winfaq12.html
5464           <http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/faq/Windows/ActivePerl-
5465           Winfaq12.html> and
5466           http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/site/lib/Win32/OLE.html
5467           <http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/site/lib/Win32/OLE.html>.
5468           If your main platform is UNIX but you have the resources to set up
5469           a separate Win32/MSOffice server, you can convert office documents
5470           to text, postscript or PDF using Win32::OLE. For a demonstration of
5471           how to do this using Perl see Docserver:
5472           <http://search.cpan.org/search?mode=module&query=docserver>.
5473
5474       ·   CSV, comma separated variables or text
5475
5476           If the file extension is "csv", Excel will open and convert this
5477           format automatically. Generating a valid CSV file isn't as easy as
5478           it seems. Have a look at the DBD::RAM, DBD::CSV, Text::xSV and
5479           Text::CSV_XS modules.
5480
5481       ·   DBI with DBD::ADO or DBD::ODBC
5482
5483           Excel files contain an internal index table that allows them to act
5484           like a database file. Using one of the standard Perl database
5485           modules you can connect to an Excel file as a database.
5486
5487       ·   DBD::Excel
5488
5489           You can also access Spreadsheet::WriteExcel using the standard DBI
5490           interface via Takanori Kawai's DBD::Excel module
5491           http://search.cpan.org/dist/DBD-Excel
5492           <http://search.cpan.org/dist/DBD-Excel>
5493
5494       ·   Spreadsheet::WriteExcelXML
5495
5496           This module allows you to create an Excel XML file using the same
5497           interface as Spreadsheet::WriteExcel. See:
5498           http://search.cpan.org/dist/Spreadsheet-WriteExcelXML
5499           <http://search.cpan.org/dist/Spreadsheet-WriteExcelXML>
5500
5501       ·   Excel::Template
5502
5503           This module allows you to create an Excel file from an XML template
5504           in a manner similar to HTML::Template. See
5505           http://search.cpan.org/dist/Excel-Template/
5506           <http://search.cpan.org/dist/Excel-Template/>.
5507
5508       ·   Spreadsheet::WriteExcel::FromXML
5509
5510           This module allows you to turn a simple XML file into an Excel file
5511           using Spreadsheet::WriteExcel as a back-end. The format of the XML
5512           file is defined by a supplied DTD:
5513           http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromXML
5514           <http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromXML>.
5515
5516       ·   Spreadsheet::WriteExcel::Simple
5517
5518           This provides an easier interface to Spreadsheet::WriteExcel:
5519           http://search.cpan.org/dist/Spreadsheet-WriteExcel-Simple
5520           <http://search.cpan.org/dist/Spreadsheet-WriteExcel-Simple>.
5521
5522       ·   Spreadsheet::WriteExcel::FromDB
5523
5524           This is a useful module for creating Excel files directly from a DB
5525           table: http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromDB
5526           <http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromDB>.
5527
5528       ·   HTML tables
5529
5530           This is an easy way of adding formatting via a text based format.
5531
5532       ·   XML or HTML
5533
5534           The Excel XML and HTML file specification are available from
5535           <http://msdn.microsoft.com/library/officedev/ofxml2k/ofxml2k.htm>.
5536
5537       For other Perl-Excel modules try the following search:
5538       <http://search.cpan.org/search?mode=module&query=excel>.
5539

READING EXCEL FILES

5541       To read data from Excel files try:
5542
5543       ·   Spreadsheet::ParseExcel
5544
5545           This uses the OLE::Storage-Lite module to extract data from an
5546           Excel file. http://search.cpan.org/dist/Spreadsheet-ParseExcel
5547           <http://search.cpan.org/dist/Spreadsheet-ParseExcel>.
5548
5549       ·   Spreadsheet::ParseExcel_XLHTML
5550
5551           This module uses Spreadsheet::ParseExcel's interface but uses
5552           xlHtml (see below) to do the conversion:
5553           http://search.cpan.org/dist/Spreadsheet-ParseExcel_XLHTML
5554           <http://search.cpan.org/dist/Spreadsheet-ParseExcel_XLHTML>
5555           Spreadsheet::ParseExcel_XLHTML
5556
5557       ·   xlHtml
5558
5559           This is an open source "Excel to HTML Converter" C/C++ project at
5560           <http://chicago.sourceforge.net/xlhtml/>.
5561
5562       ·   DBD::Excel (reading)
5563
5564           You can also access Spreadsheet::ParseExcel using the standard DBI
5565           interface via  Takanori Kawai's DBD::Excel module
5566           http://search.cpan.org/dist/DBD-Excel
5567           <http://search.cpan.org/dist/DBD-Excel>.
5568
5569       ·   Win32::OLE module and office automation (reading)
5570
5571           See, the section "WRITING EXCEL FILES".
5572
5573       ·   HTML tables (reading)
5574
5575           If the files are saved from Excel in a HTML format the data can be
5576           accessed using HTML::TableExtract
5577           http://search.cpan.org/dist/HTML-TableExtract
5578           <http://search.cpan.org/dist/HTML-TableExtract>.
5579
5580       ·   DBI with DBD::ADO or DBD::ODBC.
5581
5582           See, the section "WRITING EXCEL FILES".
5583
5584       ·   XML::Excel
5585
5586           Converts Excel files to XML using Spreadsheet::ParseExcel
5587           http://search.cpan.org/dist/XML-Excel
5588           <http://search.cpan.org/dist/XML-Excel>.
5589
5590       ·   OLE::Storage, aka LAOLA
5591
5592           This is a Perl interface to OLE file formats. In particular, the
5593           distro contains an Excel to HTML converter called Herbert,
5594           http://user.cs.tu-berlin.de/~schwartz/pmh/ <http://user.cs.tu-
5595           berlin.de/~schwartz/pmh/>. This has been superseded by the
5596           Spreadsheet::ParseExcel module.
5597
5598       For other Perl-Excel modules try the following search:
5599       <http://search.cpan.org/search?mode=module&query=excel>.
5600
5601       If you wish to view Excel files on a UNIX/Linux platform check out the
5602       excellent Gnumeric spreadsheet application at
5603       <http://www.gnome.org/projects/gnumeric/> or OpenOffice.org at
5604       <http://www.openoffice.org/>.
5605
5606       If you wish to view Excel files on a Windows platform which doesn't
5607       have Excel installed you can use the free Microsoft Excel Viewer
5608       <http://office.microsoft.com/downloads/2000/xlviewer.aspx>.
5609

MODIFYING AND REWRITING EXCEL FILES

5611       An Excel file is a binary file within a binary file. It contains
5612       several interlinked checksums and changing even one byte can cause it
5613       to become corrupted.
5614
5615       As such you cannot simply append or update an Excel file. The only way
5616       to achieve this is to read the entire file into memory, make the
5617       required changes or additions and then write the file out again.
5618
5619       You can read and rewrite an Excel file using the
5620       Spreadsheet::ParseExcel::SaveParser module which is a wrapper around
5621       Spreadsheet::ParseExcel and Spreadsheet::WriteExcel. It is part of the
5622       Spreadsheet::ParseExcel package:
5623       http://search.cpan.org/search?dist=Spreadsheet-ParseExcel
5624       <http://search.cpan.org/search?dist=Spreadsheet-ParseExcel>.
5625
5626       However, you can only rewrite the features that Spreadsheet::WriteExcel
5627       supports so macros, graphs and some other features in the original
5628       Excel file will be lost. Also, formulas aren't rewritten, only the
5629       result of a formula is written.
5630
5631       Here is an example:
5632
5633           #!/usr/bin/perl -w
5634
5635           use strict;
5636           use Spreadsheet::ParseExcel;
5637           use Spreadsheet::ParseExcel::SaveParser;
5638
5639           # Open the template with SaveParser
5640           my $parser   = new Spreadsheet::ParseExcel::SaveParser;
5641           my $template = $parser->Parse('template.xls');
5642
5643           my $sheet    = 0;
5644           my $row      = 0;
5645           my $col      = 0;
5646
5647           # Get the format from the cell
5648           my $format   = $template->{Worksheet}[$sheet]
5649                                   ->{Cells}[$row][$col]
5650                                   ->{FormatNo};
5651
5652           # Write data to some cells
5653           $template->AddCell(0, $row,   $col,   1,     $format);
5654           $template->AddCell(0, $row+1, $col, "Hello", $format);
5655
5656           # Add a new worksheet
5657           $template->AddWorksheet('New Data');
5658
5659           # The SaveParser SaveAs() method returns a reference to a
5660           # Spreadsheet::WriteExcel object. If you wish you can then
5661           # use this to access any of the methods that aren't
5662           # available from the SaveParser object. If you don't need
5663           # to do this just use SaveAs().
5664           #
5665           my $workbook;
5666
5667           {
5668               # SaveAs generates a lot of harmless warnings about unset
5669               # Worksheet properties. You can ignore them if you wish.
5670               local $^W = 0;
5671
5672               # Rewrite the file or save as a new file
5673               $workbook = $template->SaveAs('new.xls');
5674           }
5675
5676           # Use Spreadsheet::WriteExcel methods
5677           my $worksheet  = $workbook->sheets(0);
5678
5679           $worksheet->write($row+2, $col, "World2");
5680
5681           $workbook->close();
5682

Warning about XML::Parser and perl 5.6

5684       You must be careful when using Spreadsheet::WriteExcel in conjunction
5685       with perl 5.6 and XML::Parser (and other XML parsers) due to the fact
5686       that the data returned by the parser is generally in "UTF-8" format.
5687
5688       When "UTF-8" strings are added to Spreadsheet::WriteExcel's internal
5689       data it causes the generated Excel file to become corrupt.
5690
5691       Note, this doesn't affect perl 5.005 (which doesn't try to handle
5692       "UTF-8") or 5.8 (which handles it correctly).
5693
5694       To avoid this problem you should upgrade to perl 5.8, if possible, or
5695       else you should convert the output data from XML::Parser to ASCII or
5696       ISO-8859-1 using one of the following methods:
5697
5698           $new_str = pack 'C*', unpack 'U*', $utf8_str;
5699
5700
5701           use Unicode::MapUTF8 'from_utf8';
5702           $new_str = from_utf8({-str => $utf8_str, -charset => 'ISO-8859-1'});
5703

Warning about Office Service Pack 3

5705       If you have Office Service Pack 3 (SP3) installed you may see the
5706       following warning when you open a file created by
5707       Spreadsheet::WriteExcel:
5708
5709           "File Error: data may have been lost".
5710
5711       This is usually caused by multiple instances of data in a cell.
5712
5713       SP3 changed Excel's default behaviour when it encounters multiple data
5714       in a cell so that it issues a warning when the file is opened and it
5715       displays the first data that was written. Prior to SP3 it didn't issue
5716       a warning and displayed the last data written.
5717
5718       For a longer discussion and some workarounds see the following:
5719       http://groups.google.com/group/spreadsheet-writeexcel/browse_thread/thread/3dcea40e6620af3a
5720       <http://groups.google.com/group/spreadsheet-
5721       writeexcel/browse_thread/thread/3dcea40e6620af3a>.
5722

BUGS

5724       Formulas are formulae.
5725
5726       XML and "UTF-8" data on perl 5.6 can cause Excel files created by
5727       Spreadsheet::WriteExcel to become corrupt. See "Warning about
5728       XML::Parser and perl 5.6" for further details.
5729
5730       The format object that is used with a "merge_range()" method call is
5731       marked internally as being associated with a merged range. It is a
5732       fatal error to use a merged format in a non-merged cell. The current
5733       workaround is to use separate formats for merged and non-merged cell.
5734       This restriction will be removed in a future release.
5735
5736       Nested formulas sometimes aren't parsed correctly and give a result of
5737       "#VALUE". If you come across a formula that parses like this, let me
5738       know.
5739
5740       Spreadsheet::ParseExcel: All formulas created by
5741       Spreadsheet::WriteExcel are read as having a value of zero. This is
5742       because Spreadsheet::WriteExcel only stores the formula and not the
5743       calculated result.
5744
5745       OpenOffice.org: No known issues in this release.
5746
5747       Gnumeric: No known issues in this release.
5748
5749       If you wish to submit a bug report run the "bug_report.pl" program in
5750       the "examples" directory of the distro.
5751

TO DO

5753       The roadmap is as follows:
5754
5755       ·   Enhance named ranges.
5756
5757       Also, here are some of the most requested features that probably won't
5758       get added:
5759
5760       ·   Macros.
5761
5762           This would solve some other problems neatly. However, the format of
5763           Excel macros isn't documented.
5764
5765       ·   Some feature that you really need. ;-)
5766
5767       If there is some feature of an Excel file that you really, really need
5768       then you should use Win32::OLE with Excel on Windows. If you are on
5769       Unix you could consider connecting to a Windows server via Docserver or
5770       SOAP, see "WRITING EXCEL FILES".
5771

REPOSITORY

5773       The Spreadsheet::WriteExcel source code in host on github:
5774       http://github.com/jmcnamara/spreadsheet-writeexcel
5775       <http://github.com/jmcnamara/spreadsheet-writeexcel>.
5776

MAILING LIST

5778       There is a Google group for discussing and asking questions about
5779       Spreadsheet::WriteExcel. This is a good place to search to see if your
5780       question has been asked before:
5781       http://groups.google.com/group/spreadsheet-writeexcel
5782       <http://groups.google.com/group/spreadsheet-writeexcel>.
5783
5784       Alternatively you can keep up to date with future releases by
5785       subscribing at: <http://freshmeat.net/projects/writeexcel/>.
5786

DONATIONS

5788       If you'd care to donate to the Spreadsheet::WriteExcel project, you can
5789       do so via PayPal: <http://tinyurl.com/7ayes>.
5790

SEE ALSO

5792       Spreadsheet::ParseExcel:
5793       http://search.cpan.org/dist/Spreadsheet-ParseExcel
5794       <http://search.cpan.org/dist/Spreadsheet-ParseExcel>.
5795
5796       Spreadsheet-WriteExcel-FromXML:
5797       http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromXML
5798       <http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromXML>.
5799
5800       Spreadsheet::WriteExcel::FromDB:
5801       http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromDB
5802       <http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromDB>.
5803
5804       Excel::Template: http://search.cpan.org/~rkinyon/Excel-Template/
5805       <http://search.cpan.org/~rkinyon/Excel-Template/>.
5806
5807       DateTime::Format::Excel:
5808       http://search.cpan.org/dist/DateTime-Format-Excel
5809       <http://search.cpan.org/dist/DateTime-Format-Excel>.
5810
5811       "Reading and writing Excel files with Perl" by Teodor Zlatanov, at IBM
5812       developerWorks: http://www-106.ibm.com/developerworks/library/l-pexcel/
5813       <http://www-106.ibm.com/developerworks/library/l-pexcel/>.
5814
5815       "Excel-Dateien mit Perl erstellen - Controller im Gluck" by Peter
5816       Dintelmann and Christian Kirsch in the German Unix/web journal iX:
5817       <http://www.heise.de/ix/artikel/2001/06/175/>.
5818
5819       Spreadsheet::WriteExcel documentation in Japanese by Takanori Kawai.
5820       <http://member.nifty.ne.jp/hippo2000/perltips/Spreadsheet/WriteExcel.htm>.
5821
5822       Oesterly user brushes with fame:
5823       <http://oesterly.com/releases/12102000.html>.
5824
5825       The csv2xls program that is part of Text::CSV_XS:
5826       http://search.cpan.org/~hmbrand/Text-CSV_XS/MANIFEST
5827       <http://search.cpan.org/~hmbrand/Text-CSV_XS/MANIFEST>.
5828

ACKNOWLEDGMENTS

5830       The following people contributed to the debugging and testing of
5831       Spreadsheet::WriteExcel:
5832
5833       Alexander Farber, Andre de Bruin, Arthur@ais, Artur Silveira da Cunha,
5834       Bob Rose, Borgar Olsen, Brian Foley, Brian White, Bob Mackay, Cedric
5835       Bouvier, Chad Johnson, CPAN testers, Damyan Ivanov, Daniel Berger,
5836       Daniel Gardner, Dmitry Kochurov, Eric Frazier, Ernesto Baschny, Felipe
5837       Perez Galiana, Gordon Simpson, Hanc Pavel, Harold Bamford, James
5838       Holmes, James Wilkinson, Johan Ekenberg, Johann Hanne, Jonathan Scott
5839       Duff, J.C. Wren, Kenneth Stacey, Keith Miller, Kyle Krom, Marc
5840       Rosenthal, Markus Schmitz, Michael Braig, Michael Buschauer, Mike
5841       Blazer, Michael Erickson, Michael W J West, Ning Xie, Paul J. Falbe,
5842       Paul Medynski, Peter Dintelmann, Pierre Laplante, Praveen Kotha, Reto
5843       Badertscher, Rich Sorden, Shane Ashby, Sharron McKenzie, Shenyu Zheng,
5844       Stephan Loescher, Steve Sapovits, Sven Passig, Svetoslav Marinov, Tamas
5845       Gulacsi, Troy Daniels, Vahe Sarkissian.
5846
5847       The following people contributed patches, examples or Excel
5848       information:
5849
5850       Andrew Benham, Bill Young, Cedric Bouvier, Charles Wybble, Daniel
5851       Rentz, David Robins, Franco Venturi, Guy Albertelli, Ian Penman, John
5852       Heitmann, Jon Guy, Kyle R. Burton, Pierre-Jean Vouette, Rubio, Marco
5853       Geri, Mark Fowler, Matisse Enzer, Sam Kington, Takanori Kawai, Tom
5854       O'Sullivan.
5855
5856       Many thanks to Ron McKelvey, Ronzo Consulting for Siemens, who
5857       sponsored the development of the formula caching routines.
5858
5859       Many thanks to Cassens Transport who sponsored the development of the
5860       embedded charts and autofilters.
5861
5862       Additional thanks to Takanori Kawai for translating the documentation
5863       into Japanese.
5864
5865       Gunnar Wolf maintains the Debian distro.
5866
5867       Thanks to Damian Conway for the excellent Parse::RecDescent.
5868
5869       Thanks to Tim Jenness for File::Temp.
5870
5871       Thanks to Michael Meeks and Jody Goldberg for their work on Gnumeric.
5872

DISCLAIMER OF WARRANTY

5874       Because this software is licensed free of charge, there is no warranty
5875       for the software, to the extent permitted by applicable law. Except
5876       when otherwise stated in writing the copyright holders and/or other
5877       parties provide the software "as is" without warranty of any kind,
5878       either expressed or implied, including, but not limited to, the implied
5879       warranties of merchantability and fitness for a particular purpose. The
5880       entire risk as to the quality and performance of the software is with
5881       you. Should the software prove defective, you assume the cost of all
5882       necessary servicing, repair, or correction.
5883
5884       In no event unless required by applicable law or agreed to in writing
5885       will any copyright holder, or any other party who may modify and/or
5886       redistribute the software as permitted by the above licence, be liable
5887       to you for damages, including any general, special, incidental, or
5888       consequential damages arising out of the use or inability to use the
5889       software (including but not limited to loss of data or data being
5890       rendered inaccurate or losses sustained by you or third parties or a
5891       failure of the software to operate with any other software), even if
5892       such holder or other party has been advised of the possibility of such
5893       damages.
5894

LICENSE

5896       Either the Perl Artistic Licence
5897       <http://dev.perl.org/licenses/artistic.html> or the GPL
5898       http://www.opensource.org/licenses/gpl-license.php
5899       <http://www.opensource.org/licenses/gpl-license.php>.
5900

AUTHOR

5902       John McNamara jmcnamara@cpan.org
5903
5904           Another day in June, we'll pick eleven for football
5905           (Pick eleven for football)
5906           We're playing for our lives the referee gives us fuck all
5907           (Ref you're giving us fuck all)
5908           I saw you with the corner of my eye on the sidelines
5909           Your dark mascara bids me to historical deeds
5910
5911               -- Belle and Sebastian
5912
5914       Copyright MM-MMX, John McNamara.
5915
5916       All Rights Reserved. This module is free software. It may be used,
5917       redistributed and/or modified under the same terms as Perl itself.
5918
5919
5920
5921perl v5.12.0                      2010-01-21        Spreadsheet::WriteExcel(3)
Impressum