1Excel::Writer::XLSX(3)User Contributed Perl DocumentationExcel::Writer::XLSX(3)
2
3
4

NAME

6       Excel::Writer::XLSX - Create a new file in the Excel 2007+ XLSX format.
7

SYNOPSIS

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

DESCRIPTION

38       The "Excel::Writer::XLSX" module can be used to create an Excel file in
39       the 2007+ XLSX format.
40
41       The XLSX format is the Office Open XML (OOXML) format used by Excel
42       2007 and later.
43
44       Multiple worksheets can be added to a workbook and formatting can be
45       applied to cells. Text, numbers, and formulas can be written to the
46       cells.
47
48       This module cannot, as yet, be used to write to an existing Excel XLSX
49       file.
50

Excel::Writer::XLSX and Spreadsheet::WriteExcel

52       "Excel::Writer::XLSX" uses the same interface as the
53       Spreadsheet::WriteExcel module which produces an Excel file in binary
54       XLS format.
55
56       Excel::Writer::XLSX supports all of the features of
57       Spreadsheet::WriteExcel and in some cases has more functionality. For
58       more details see "Compatibility with Spreadsheet::WriteExcel".
59
60       The main advantage of the XLSX format over the XLS format is that it
61       allows a larger number of rows and columns in a worksheet. The XLSX
62       file format also produces much smaller files than the XLS file format.
63

QUICK START

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

WORKBOOK METHODS

100       The Excel::Writer::XLSX module provides an object oriented interface to
101       a new Excel workbook. The following methods are available through a new
102       workbook.
103
104           new()
105           add_worksheet()
106           add_format()
107           add_chart()
108           add_shape()
109           add_vba_project()
110           set_vba_name()
111           close()
112           set_properties()
113           set_custom_property()
114           define_name()
115           set_tempdir()
116           set_custom_color()
117           sheets()
118           get_worksheet_by_name()
119           set_1904()
120           set_optimization()
121           set_calc_mode()
122           get_default_url_format()
123
124       If you are unfamiliar with object oriented interfaces or the way that
125       they are implemented in Perl have a look at "perlobj" and "perltoot" in
126       the main Perl documentation.
127
128   new()
129       A new Excel workbook is created using the "new()" constructor which
130       accepts either a filename or a filehandle as a parameter. The following
131       example creates a new Excel file based on a filename:
132
133           my $workbook  = Excel::Writer::XLSX->new( 'filename.xlsx' );
134           my $worksheet = $workbook->add_worksheet();
135           $worksheet->write( 0, 0, 'Hi Excel!' );
136           $workbook->close();
137
138       Here are some other examples of using "new()" with filenames:
139
140           my $workbook1 = Excel::Writer::XLSX->new( $filename );
141           my $workbook2 = Excel::Writer::XLSX->new( '/tmp/filename.xlsx' );
142           my $workbook3 = Excel::Writer::XLSX->new( "c:\\tmp\\filename.xlsx" );
143           my $workbook4 = Excel::Writer::XLSX->new( 'c:\tmp\filename.xlsx' );
144
145       The last two examples demonstrates how to create a file on DOS or
146       Windows where it is necessary to either escape the directory separator
147       "\" or to use single quotes to ensure that it isn't interpolated. For
148       more information see "perlfaq5: Why can't I use "C:\temp\foo" in DOS
149       paths?".
150
151       It is recommended that the filename uses the extension ".xlsx" rather
152       than ".xls" since the latter causes an Excel warning when used with the
153       XLSX format.
154
155       The "new()" constructor returns a Excel::Writer::XLSX object that you
156       can use to add worksheets and store data. It should be noted that
157       although "my" is not specifically required it defines the scope of the
158       new workbook variable and, in the majority of cases, ensures that the
159       workbook is closed properly without explicitly calling the "close()"
160       method.
161
162       If the file cannot be created, due to file permissions or some other
163       reason,  "new" will return "undef". Therefore, it is good practice to
164       check the return value of "new" before proceeding. As usual the Perl
165       variable $! will be set if there is a file creation error. You will
166       also see one of the warning messages detailed in "DIAGNOSTICS":
167
168           my $workbook = Excel::Writer::XLSX->new( 'protected.xlsx' );
169           die "Problems creating new Excel file: $!" unless defined $workbook;
170
171       You can also pass a valid filehandle to the "new()" constructor. For
172       example in a CGI program you could do something like this:
173
174           binmode( STDOUT );
175           my $workbook = Excel::Writer::XLSX->new( \*STDOUT );
176
177       The requirement for "binmode()" is explained below.
178
179       See also, the "cgi.pl" program in the "examples" directory of the
180       distro.
181
182       In "mod_perl" programs where you will have to do something like the
183       following:
184
185           # mod_perl 1
186           ...
187           tie *XLSX, 'Apache';
188           binmode( XLSX );
189           my $workbook = Excel::Writer::XLSX->new( \*XLSX );
190           ...
191
192           # mod_perl 2
193           ...
194           tie *XLSX => $r;    # Tie to the Apache::RequestRec object
195           binmode( *XLSX );
196           my $workbook = Excel::Writer::XLSX->new( \*XLSX );
197           ...
198
199       See also, the "mod_perl1.pl" and "mod_perl2.pl" programs in the
200       "examples" directory of the distro.
201
202       Filehandles can also be useful if you want to stream an Excel file over
203       a socket or if you want to store an Excel file in a scalar.
204
205       For example here is a way to write an Excel file to a scalar:
206
207           #!/usr/bin/perl -w
208
209           use strict;
210           use Excel::Writer::XLSX;
211
212           open my $fh, '>', \my $str or die "Failed to open filehandle: $!";
213
214           my $workbook  = Excel::Writer::XLSX->new( $fh );
215           my $worksheet = $workbook->add_worksheet();
216
217           $worksheet->write( 0, 0, 'Hi Excel!' );
218
219           $workbook->close();
220
221           # The Excel file in now in $str. Remember to binmode() the output
222           # filehandle before printing it.
223           binmode STDOUT;
224           print $str;
225
226       See also the "write_to_scalar.pl" and "filehandle.pl" programs in the
227       "examples" directory of the distro.
228
229       Note about the requirement for "binmode()". An Excel file is comprised
230       of binary data. Therefore, if you are using a filehandle you should
231       ensure that you "binmode()" it prior to passing it to "new()".You
232       should do this regardless of whether you are on a Windows platform or
233       not.
234
235       You don't have to worry about "binmode()" if you are using filenames
236       instead of filehandles. Excel::Writer::XLSX performs the "binmode()"
237       internally when it converts the filename to a filehandle. For more
238       information about "binmode()" see "perlfunc" and "perlopentut" in the
239       main Perl documentation.
240
241   add_worksheet( $sheetname )
242       At least one worksheet should be added to a new workbook. A worksheet
243       is used to write data into cells:
244
245           $worksheet1 = $workbook->add_worksheet();               # Sheet1
246           $worksheet2 = $workbook->add_worksheet( 'Foglio2' );    # Foglio2
247           $worksheet3 = $workbook->add_worksheet( 'Data' );       # Data
248           $worksheet4 = $workbook->add_worksheet();               # Sheet4
249
250       If $sheetname is not specified the default Excel convention will be
251       followed, i.e. Sheet1, Sheet2, etc.
252
253       The worksheet name must be a valid Excel worksheet name, i.e:
254
255       ·   It must be less than 32 characters.
256
257       ·   It cannot contain any of the following characters: "[ ] : * ? / \"
258
259       ·   It cannot start or end with an apostrophe.
260
261       ·   It cannot be the same as an existing worksheet name (or a case
262           insensitive variant).
263
264       ·   It cannot be the reserved name "History" (or a case insensitive
265           variant).
266
267       See the Excel worksheet naming rules at
268       <https://support.office.com/en-ie/article/rename-a-worksheet-3f1f7148-ee83-404d-8ef0-9ff99fbad1f9>.
269
270   add_format( %properties )
271       The "add_format()" method can be used to create new Format objects
272       which are used to apply formatting to a cell. You can either define the
273       properties at creation time via a hash of property values or later via
274       method calls.
275
276           $format1 = $workbook->add_format( %props );    # Set properties at creation
277           $format2 = $workbook->add_format();            # Set properties later
278
279       See the "CELL FORMATTING" section for more details about Format
280       properties and how to set them.
281
282   add_chart( %properties )
283       This method is use to create a new chart either as a standalone
284       worksheet (the default) or as an embeddable object that can be inserted
285       into a worksheet via the "insert_chart()" Worksheet method.
286
287           my $chart = $workbook->add_chart( type => 'column' );
288
289       The properties that can be set are:
290
291           type     (required)
292           subtype  (optional)
293           name     (optional)
294           embedded (optional)
295
296       ·   "type"
297
298           This is a required parameter. It defines the type of chart that
299           will be created.
300
301               my $chart = $workbook->add_chart( type => 'line' );
302
303           The available types are:
304
305               area
306               bar
307               column
308               line
309               pie
310               doughnut
311               scatter
312               stock
313
314       ·   "subtype"
315
316           Used to define a chart subtype where available.
317
318               my $chart = $workbook->add_chart( type => 'bar', subtype => 'stacked' );
319
320           See the Excel::Writer::XLSX::Chart documentation for a list of
321           available chart subtypes.
322
323       ·   "name"
324
325           Set the name for the chart sheet. The name property is optional and
326           if it isn't supplied will default to "Chart1 .. n". The name must
327           be a valid Excel worksheet name. See "add_worksheet()" for more
328           details on valid sheet names. The "name" property can be omitted
329           for embedded charts.
330
331               my $chart = $workbook->add_chart( type => 'line', name => 'Results Chart' );
332
333       ·   "embedded"
334
335           Specifies that the Chart object will be inserted in a worksheet via
336           the "insert_chart()" Worksheet method. It is an error to try insert
337           a Chart that doesn't have this flag set.
338
339               my $chart = $workbook->add_chart( type => 'line', embedded => 1 );
340
341               # Configure the chart.
342               ...
343
344               # Insert the chart into the a worksheet.
345               $worksheet->insert_chart( 'E2', $chart );
346
347       See Excel::Writer::XLSX::Chart for details on how to configure the
348       chart object once it is created. See also the "chart_*.pl" programs in
349       the examples directory of the distro.
350
351   add_shape( %properties )
352       The "add_shape()" method can be used to create new shapes that may be
353       inserted into a worksheet.
354
355       You can either define the properties at creation time via a hash of
356       property values or later via method calls.
357
358           # Set properties at creation.
359           $plus = $workbook->add_shape(
360               type   => 'plus',
361               id     => 3,
362               width  => $pw,
363               height => $ph
364           );
365
366
367           # Default rectangle shape. Set properties later.
368           $rect =  $workbook->add_shape();
369
370       See Excel::Writer::XLSX::Shape for details on how to configure the
371       shape object once it is created.
372
373       See also the "shape*.pl" programs in the examples directory of the
374       distro.
375
376   add_vba_project( 'vbaProject.bin' )
377       The "add_vba_project()" method can be used to add macros or functions
378       to an Excel::Writer::XLSX file using a binary VBA project file that has
379       been extracted from an existing Excel "xlsm" file.
380
381           my $workbook  = Excel::Writer::XLSX->new( 'file.xlsm' );
382
383           $workbook->add_vba_project( './vbaProject.bin' );
384
385       The supplied "extract_vba" utility can be used to extract the required
386       "vbaProject.bin" file from an existing Excel file:
387
388           $ extract_vba file.xlsm
389           Extracted 'vbaProject.bin' successfully
390
391       Macros can be tied to buttons using the worksheet "insert_button()"
392       method (see the "WORKSHEET METHODS" section for details):
393
394           $worksheet->insert_button( 'C2', { macro => 'my_macro' } );
395
396       Note, Excel uses the file extension "xlsm" instead of "xlsx" for files
397       that contain macros. It is advisable to follow the same convention.
398
399       See also the "macros.pl" example file and the "WORKING WITH VBA
400       MACROS".
401
402   set_vba_name()
403       The "set_vba_name()" method can be used to set the VBA codename for the
404       workbook. This is sometimes required when a "vbaProject macro" included
405       via "add_vba_project()" refers to the workbook. The default Excel VBA
406       name of "ThisWorkbook" is used if a user defined name isn't specified.
407       See also "WORKING WITH VBA MACROS".
408
409   close()
410       In general your Excel file will be closed automatically when your
411       program ends or when the Workbook object goes out of scope. However it
412       is recommended to explicitly call the "close()" method close the Excel
413       file and avoid the potential issues outlined below. The "close()"
414       method is called like this:
415
416           $workbook->close();
417
418       The return value of "close()" is the same as that returned by perl when
419       it closes the file created by "new()". This allows you to handle error
420       conditions in the usual way:
421
422           $workbook->close() or die "Error closing file: $!";
423
424       An explicit "close()" is required if the file must be closed prior to
425       performing some external action on it such as copying it, reading its
426       size or attaching it to an email.
427
428       In addition, "close()" may be required to prevent perl's garbage
429       collector from disposing of the Workbook, Worksheet and Format objects
430       in the wrong order. Situations where this can occur are:
431
432       ·   If "my()" was not used to declare the scope of a workbook variable
433           created using "new()".
434
435       ·   If the "new()", "add_worksheet()" or "add_format()" methods are
436           called in subroutines.
437
438       The reason for this is that Excel::Writer::XLSX relies on Perl's
439       "DESTROY" mechanism to trigger destructor methods in a specific
440       sequence. This may not happen in cases where the Workbook, Worksheet
441       and Format variables are not lexically scoped or where they have
442       different lexical scopes.
443
444       To avoid these issues it is recommended that you always close the
445       Excel::Writer::XLSX filehandle using "close()".
446
447   set_size( $width, $height )
448       The "set_size()" method can be used to set the size of a workbook
449       window.
450
451           $workbook->set_size(1200, 800);
452
453       The Excel window size was used in Excel 2007 to define the width and
454       height of a workbook window within the Multiple Document Interface
455       (MDI). In later versions of Excel for Windows this interface was
456       dropped. This method is currently only useful when setting the window
457       size in Excel for Mac 2011. The units are pixels and the default size
458       is 1073 x 644.
459
460       Note, this doesn't equate exactly to the Excel for Mac pixel size since
461       it is based on the original Excel 2007 for Windows sizing.
462
463   set_tab_ratio( $tab_ratio )
464       The "set_tab_ratio()" method can be used to set the ratio between
465       worksheet tabs and the horizontal slider at the bottom of a workbook.
466       This can be increased to give more room to the tabs or reduced to
467       increase the size of the horizontal slider:
468
469           $workbook->set_tab_ratio(75);
470
471       The default value in Excel is 60.
472
473   set_properties()
474       The "set_properties" method can be used to set the document properties
475       of the Excel file created by "Excel::Writer::XLSX". These properties
476       are visible when you use the "Office Button -> Prepare -> Properties"
477       option in Excel and are also available to external applications that
478       read or index Windows files.
479
480       The properties should be passed in hash format as follows:
481
482           $workbook->set_properties(
483               title    => 'This is an example spreadsheet',
484               author   => 'John McNamara',
485               comments => 'Created with Perl and Excel::Writer::XLSX',
486           );
487
488       The properties that can be set are:
489
490           title
491           subject
492           author
493           manager
494           company
495           category
496           keywords
497           comments
498           status
499           hyperlink_base
500           created - File create date. Such be an aref of gmtime() values.
501
502       See also the "properties.pl" program in the examples directory of the
503       distro.
504
505   set_custom_property( $name, $value, $type)
506       The "set_custom_property" method can be used to set one of more custom
507       document properties not covered by the "set_properties()" method above.
508       These properties are visible when you use the "Office Button -> Prepare
509       -> Properties -> Advanced Properties -> Custom" option in Excel and are
510       also available to external applications that read or index Windows
511       files.
512
513       The "set_custom_property" method takes 3 parameters:
514
515           $workbook-> set_custom_property( $name, $value, $type);
516
517       Where the available types are:
518
519           text
520           date
521           number
522           bool
523
524       For example:
525
526           $workbook->set_custom_property( 'Checked by',      'Eve',                  'text'   );
527           $workbook->set_custom_property( 'Date completed',  '2016-12-12T23:00:00Z', 'date'   );
528           $workbook->set_custom_property( 'Document number', '12345' ,               'number' );
529           $workbook->set_custom_property( 'Reference',       '1.2345',               'number' );
530           $workbook->set_custom_property( 'Has review',      1,                      'bool'   );
531           $workbook->set_custom_property( 'Signed off',      0,                      'bool'   );
532           $workbook->set_custom_property( 'Department',      $some_string,           'text'   );
533           $workbook->set_custom_property( 'Scale',           '1.2345678901234',      'number' );
534
535       Dates should by in ISO8601 "yyyy-mm-ddThh:mm:ss.sssZ" date format in
536       Zulu time, as shown above.
537
538       The "text" and "number" types are optional since they can usually be
539       inferred from the data:
540
541           $workbook->set_custom_property( 'Checked by', 'Eve'    );
542           $workbook->set_custom_property( 'Reference',  '1.2345' );
543
544       The $name and $value parameters are limited to 255 characters by Excel.
545
546   define_name()
547       This method is used to defined a name that can be used to represent a
548       value, a single cell or a range of cells in a workbook.
549
550       For example to set a global/workbook name:
551
552           # Global/workbook names.
553           $workbook->define_name( 'Exchange_rate', '=0.96' );
554           $workbook->define_name( 'Sales',         '=Sheet1!$G$1:$H$10' );
555
556       It is also possible to define a local/worksheet name by prefixing the
557       name with the sheet name using the syntax "sheetname!definedname":
558
559           # Local/worksheet name.
560           $workbook->define_name( 'Sheet2!Sales',  '=Sheet2!$G$1:$G$10' );
561
562       If the sheet name contains spaces or special characters you must
563       enclose it in single quotes like in Excel:
564
565           $workbook->define_name( "'New Data'!Sales",  '=Sheet2!$G$1:$G$10' );
566
567       See the defined_name.pl program in the examples dir of the distro.
568
569       Refer to the following to see Excel's syntax rules for defined names:
570       <http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010147120.aspx#BMsyntax_rules_for_names>
571
572   set_tempdir()
573       "Excel::Writer::XLSX" stores worksheet data in temporary files prior to
574       assembling the final workbook.
575
576       The "File::Temp" module is used to create these temporary files.
577       File::Temp uses "File::Spec" to determine an appropriate location for
578       these files such as "/tmp" or "c:\windows\temp". You can find out which
579       directory is used on your system as follows:
580
581           perl -MFile::Spec -le "print File::Spec->tmpdir()"
582
583       If the default temporary file directory isn't accessible to your
584       application, or doesn't contain enough space, you can specify an
585       alternative location using the "set_tempdir()" method:
586
587           $workbook->set_tempdir( '/tmp/writeexcel' );
588           $workbook->set_tempdir( 'c:\windows\temp\writeexcel' );
589
590       The directory for the temporary file must exist, "set_tempdir()" will
591       not create a new directory.
592
593   set_custom_color( $index, $red, $green, $blue )
594       The method is maintained for backward compatibility with
595       Spreadsheet::WriteExcel. Excel::Writer::XLSX programs don't require
596       this method and colours can be specified using a Html style "#RRGGBB"
597       value, see "WORKING WITH COLOURS".
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           for $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 the 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           for $worksheet ( $workbook->sheets( 0, -1 ) ) {
626               # Do something
627           }
628
629       Array slices are explained in the "perldata" manpage.
630
631   get_worksheet_by_name()
632       The "get_worksheet_by_name()" function return a worksheet or chartsheet
633       object in the workbook using the sheetname:
634
635           $worksheet = $workbook->get_worksheet_by_name('Sheet1');
636
637   set_1904()
638       Excel stores dates as real numbers where the integer part stores the
639       number of days since the epoch and the fractional part stores the
640       percentage of the day. The epoch can be either 1900 or 1904. Excel for
641       Windows uses 1900 and Excel for Macintosh uses 1904. However, Excel on
642       either platform will convert automatically between one system and the
643       other.
644
645       Excel::Writer::XLSX stores dates in the 1900 format by default. If you
646       wish to change this you can call the "set_1904()" workbook method. You
647       can query the current value by calling the "get_1904()" workbook
648       method. This returns 0 for 1900 and 1 for 1904.
649
650       See also "DATES AND TIME IN EXCEL" for more information about working
651       with Excel's date system.
652
653       In general you probably won't need to use "set_1904()".
654
655   set_optimization()
656       The "set_optimization()" method is used to turn on optimizations in the
657       Excel::Writer::XLSX module. Currently there is only one optimization
658       available and that is to reduce memory usage.
659
660           $workbook->set_optimization();
661
662       See "SPEED AND MEMORY USAGE" for more background information.
663
664       Note, that with this optimization turned on a row of data is written
665       and then discarded when a cell in a new row is added via one of the
666       Worksheet "write_*()" methods. As such data should be written in
667       sequential row order once the optimization is turned on.
668
669       This method must be called before any calls to "add_worksheet()".
670
671   set_calc_mode( $mode )
672       Set the calculation mode for formulas in the workbook. This is mainly
673       of use for workbooks with slow formulas where you want to allow the
674       user to calculate them manually.
675
676       The mode parameter can be one of the following strings:
677
678       "auto"
679           The default. Excel will re-calculate formulas when a formula or a
680           value affecting the formula changes.
681
682       "manual"
683           Only re-calculate formulas when the user requires it. Generally by
684           pressing F9.
685
686       "auto_except_tables"
687           Excel will automatically re-calculate formulas except for tables.
688
689   get_default_url_format()
690       The "get_default_url_format()" method gets a copy of the default url
691       format used when a user defined format isn't specified with the
692       worksheet "write_url()" method. The format is the hyperlink style
693       defined by Excel for the default theme:
694
695           my $url_format = $workbook->get_default_url_format();
696

WORKSHEET METHODS

698       A new worksheet is created by calling the "add_worksheet()" method from
699       a workbook object:
700
701           $worksheet1 = $workbook->add_worksheet();
702           $worksheet2 = $workbook->add_worksheet();
703
704       The following methods are available through a new worksheet:
705
706           write()
707           write_number()
708           write_string()
709           write_rich_string()
710           keep_leading_zeros()
711           write_blank()
712           write_row()
713           write_col()
714           write_date_time()
715           write_url()
716           write_url_range()
717           write_formula()
718           write_boolean()
719           write_comment()
720           show_comments()
721           set_comments_author()
722           add_write_handler()
723           insert_image()
724           insert_chart()
725           insert_shape()
726           insert_button()
727           data_validation()
728           conditional_formatting()
729           add_sparkline()
730           add_table()
731           get_name()
732           activate()
733           select()
734           hide()
735           set_first_sheet()
736           protect()
737           set_selection()
738           set_row()
739           set_default_row()
740           set_column()
741           outline_settings()
742           freeze_panes()
743           split_panes()
744           merge_range()
745           merge_range_type()
746           set_zoom()
747           right_to_left()
748           hide_zero()
749           set_tab_color()
750           autofilter()
751           filter_column()
752           filter_column_list()
753           set_vba_name()
754
755   Cell notation
756       Excel::Writer::XLSX supports two forms of notation to designate the
757       position of cells: Row-column notation and A1 notation.
758
759       Row-column notation uses a zero based index for both row and column
760       while A1 notation uses the standard Excel alphanumeric sequence of
761       column letter and 1-based row. For example:
762
763           (0, 0)      # The top left cell in row-column notation.
764           ('A1')      # The top left cell in A1 notation.
765
766           (1999, 29)  # Row-column notation.
767           ('AD2000')  # The same cell in A1 notation.
768
769       Row-column notation is useful if you are referring to cells
770       programmatically:
771
772           for my $i ( 0 .. 9 ) {
773               $worksheet->write( $i, 0, 'Hello' );    # Cells A1 to A10
774           }
775
776       A1 notation is useful for setting up a worksheet manually and for
777       working with formulas:
778
779           $worksheet->write( 'H1', 200 );
780           $worksheet->write( 'H2', '=H1+1' );
781
782       In formulas and applicable methods you can also use the "A:A" column
783       notation:
784
785           $worksheet->write( 'A1', '=SUM(B:B)' );
786
787       The "Excel::Writer::XLSX::Utility" module that is included in the
788       distro contains helper functions for dealing with A1 notation, for
789       example:
790
791           use Excel::Writer::XLSX::Utility;
792
793           ( $row, $col ) = xl_cell_to_rowcol( 'C2' );    # (1, 2)
794           $str           = xl_rowcol_to_cell( 1, 2 );    # C2
795
796       For simplicity, the parameter lists for the worksheet method calls in
797       the following sections are given in terms of row-column notation. In
798       all cases it is also possible to use A1 notation.
799
800       Note: in Excel it is also possible to use a R1C1 notation. This is not
801       supported by Excel::Writer::XLSX.
802
803   write( $row, $column, $token, $format )
804       Excel makes a distinction between data types such as strings, numbers,
805       blanks, formulas and hyperlinks. To simplify the process of writing
806       data the "write()" method acts as a general alias for several more
807       specific methods:
808
809           write_string()
810           write_number()
811           write_blank()
812           write_formula()
813           write_url()
814           write_row()
815           write_col()
816
817       The general rule is that if the data looks like a something then a
818       something is written. Here are some examples in both row-column and A1
819       notation:
820
821                                                               # Same as:
822           $worksheet->write( 0, 0, 'Hello'                 ); # write_string()
823           $worksheet->write( 1, 0, 'One'                   ); # write_string()
824           $worksheet->write( 2, 0,  2                      ); # write_number()
825           $worksheet->write( 3, 0,  3.00001                ); # write_number()
826           $worksheet->write( 4, 0,  ""                     ); # write_blank()
827           $worksheet->write( 5, 0,  ''                     ); # write_blank()
828           $worksheet->write( 6, 0,  undef                  ); # write_blank()
829           $worksheet->write( 7, 0                          ); # write_blank()
830           $worksheet->write( 8, 0,  'http://www.perl.com/' ); # write_url()
831           $worksheet->write( 'A9',  'ftp://ftp.cpan.org/'  ); # write_url()
832           $worksheet->write( 'A10', 'internal:Sheet1!A1'   ); # write_url()
833           $worksheet->write( 'A11', 'external:c:\foo.xlsx' ); # write_url()
834           $worksheet->write( 'A12', '=A3 + 3*A4'           ); # write_formula()
835           $worksheet->write( 'A13', '=SIN(PI()/4)'         ); # write_formula()
836           $worksheet->write( 'A14', \@array                ); # write_row()
837           $worksheet->write( 'A15', [\@array]              ); # write_col()
838
839           # And if the keep_leading_zeros property is set:
840           $worksheet->write( 'A16', '2'                    ); # write_number()
841           $worksheet->write( 'A17', '02'                   ); # write_string()
842           $worksheet->write( 'A18', '00002'                ); # write_string()
843
844           # Write an array formula. Not available in Spreadsheet::WriteExcel.
845           $worksheet->write( 'A19', '{=SUM(A1:B1*A2:B2)}'  ); # write_formula()
846
847       The "looks like" rule is defined by regular expressions:
848
849       "write_number()" if $token is a number based on the following regex:
850       "$token =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/".
851
852       "write_string()" if "keep_leading_zeros()" is set and $token is an
853       integer with leading zeros based on the following regex: "$token =~
854       /^0\d+$/".
855
856       "write_blank()" if $token is undef or a blank string: "undef", "" or
857       ''.
858
859       "write_url()" if $token is a http, https, ftp or mailto URL based on
860       the following regexes: "$token =~ m|^[fh]tt?ps?://|" or "$token =~
861       m|^mailto:|".
862
863       "write_url()" if $token is an internal or external sheet reference
864       based on the following regex: "$token =~ m[^(in|ex)ternal:]".
865
866       "write_formula()" if the first character of $token is "=".
867
868       "write_array_formula()" if the $token matches "/^{=.*}$/".
869
870       "write_row()" if $token is an array ref.
871
872       "write_col()" if $token is an array ref of array refs.
873
874       "write_string()" if none of the previous conditions apply.
875
876       The $format parameter is optional. It should be a valid Format object,
877       see "CELL FORMATTING":
878
879           my $format = $workbook->add_format();
880           $format->set_bold();
881           $format->set_color( 'red' );
882           $format->set_align( 'center' );
883
884           $worksheet->write( 4, 0, 'Hello', $format );    # Formatted string
885
886       The write() method will ignore empty strings or "undef" tokens unless a
887       format is also supplied. As such you needn't worry about special
888       handling for empty or "undef" values in your data. See also the
889       "write_blank()" method.
890
891       One problem with the "write()" method is that occasionally data looks
892       like a number but you don't want it treated as a number. For example,
893       zip codes or ID numbers often start with a leading zero. If you write
894       this data as a number then the leading zero(s) will be stripped. You
895       can change this default behaviour by using the "keep_leading_zeros()"
896       method. While this property is in place any integers with leading zeros
897       will be treated as strings and the zeros will be preserved. See the
898       "keep_leading_zeros()" section for a full discussion of this issue.
899
900       You can also add your own data handlers to the "write()" method using
901       "add_write_handler()".
902
903       The "write()" method will also handle Unicode strings in "UTF-8"
904       format.
905
906       The "write" methods return:
907
908           0 for success.
909          -1 for insufficient number of arguments.
910          -2 for row or column out of bounds.
911          -3 for string too long.
912
913   write_number( $row, $column, $number, $format )
914       Write an integer or a float to the cell specified by $row and $column:
915
916           $worksheet->write_number( 0, 0, 123456 );
917           $worksheet->write_number( 'A2', 2.3451 );
918
919       See the note about "Cell notation". The $format parameter is optional.
920
921       In general it is sufficient to use the "write()" method.
922
923       Note: some versions of Excel 2007 do not display the calculated values
924       of formulas written by Excel::Writer::XLSX. Applying all available
925       Service Packs to Excel should fix this.
926
927   write_string( $row, $column, $string, $format )
928       Write a string to the cell specified by $row and $column:
929
930           $worksheet->write_string( 0, 0, 'Your text here' );
931           $worksheet->write_string( 'A2', 'or here' );
932
933       The maximum string size is 32767 characters. However the maximum string
934       segment that Excel can display in a cell is 1000. All 32767 characters
935       can be displayed in the formula bar.
936
937       The $format parameter is optional.
938
939       The "write()" method will also handle strings in "UTF-8" format. See
940       also the "unicode_*.pl" programs in the examples directory of the
941       distro.
942
943       In general it is sufficient to use the "write()" method. However, you
944       may sometimes wish to use the "write_string()" method to write data
945       that looks like a number but that you don't want treated as a number.
946       For example, zip codes or phone numbers:
947
948           # Write as a plain string
949           $worksheet->write_string( 'A1', '01209' );
950
951       However, if the user edits this string Excel may convert it back to a
952       number. To get around this you can use the Excel text format "@":
953
954           # Format as a string. Doesn't change to a number when edited
955           my $format1 = $workbook->add_format( num_format => '@' );
956           $worksheet->write_string( 'A2', '01209', $format1 );
957
958       See also the note about "Cell notation".
959
960   write_rich_string( $row, $column, $format, $string, ..., $cell_format )
961       The "write_rich_string()" method is used to write strings with multiple
962       formats. For example to write the string "This is bold and this is
963       italic" you would use the following:
964
965           my $bold   = $workbook->add_format( bold   => 1 );
966           my $italic = $workbook->add_format( italic => 1 );
967
968           $worksheet->write_rich_string( 'A1',
969               'This is ', $bold, 'bold', ' and this is ', $italic, 'italic' );
970
971       The basic rule is to break the string into fragments and put a $format
972       object before the fragment that you want to format. For example:
973
974           # Unformatted string.
975             'This is an example string'
976
977           # Break it into fragments.
978             'This is an ', 'example', ' string'
979
980           # Add formatting before the fragments you want formatted.
981             'This is an ', $format, 'example', ' string'
982
983           # In Excel::Writer::XLSX.
984           $worksheet->write_rich_string( 'A1',
985               'This is an ', $format, 'example', ' string' );
986
987       String fragments that don't have a format are given a default format.
988       So for example when writing the string "Some bold text" you would use
989       the first example below but it would be equivalent to the second:
990
991           # With default formatting:
992           my $bold    = $workbook->add_format( bold => 1 );
993
994           $worksheet->write_rich_string( 'A1',
995               'Some ', $bold, 'bold', ' text' );
996
997           # Or more explicitly:
998           my $bold    = $workbook->add_format( bold => 1 );
999           my $default = $workbook->add_format();
1000
1001           $worksheet->write_rich_string( 'A1',
1002               $default, 'Some ', $bold, 'bold', $default, ' text' );
1003
1004       As with Excel, only the font properties of the format such as font
1005       name, style, size, underline, color and effects are applied to the
1006       string fragments. Other features such as border, background, text wrap
1007       and alignment must be applied to the cell.
1008
1009       The "write_rich_string()" method allows you to do this by using the
1010       last argument as a cell format (if it is a format object). The
1011       following example centers a rich string in the cell:
1012
1013           my $bold   = $workbook->add_format( bold  => 1 );
1014           my $center = $workbook->add_format( align => 'center' );
1015
1016           $worksheet->write_rich_string( 'A5',
1017               'Some ', $bold, 'bold text', ' centered', $center );
1018
1019       See the "rich_strings.pl" example in the distro for more examples.
1020
1021           my $bold   = $workbook->add_format( bold        => 1 );
1022           my $italic = $workbook->add_format( italic      => 1 );
1023           my $red    = $workbook->add_format( color       => 'red' );
1024           my $blue   = $workbook->add_format( color       => 'blue' );
1025           my $center = $workbook->add_format( align       => 'center' );
1026           my $super  = $workbook->add_format( font_script => 1 );
1027
1028
1029           # Write some strings with multiple formats.
1030           $worksheet->write_rich_string( 'A1',
1031               'This is ', $bold, 'bold', ' and this is ', $italic, 'italic' );
1032
1033           $worksheet->write_rich_string( 'A3',
1034               'This is ', $red, 'red', ' and this is ', $blue, 'blue' );
1035
1036           $worksheet->write_rich_string( 'A5',
1037               'Some ', $bold, 'bold text', ' centered', $center );
1038
1039           $worksheet->write_rich_string( 'A7',
1040               $italic, 'j = k', $super, '(n-1)', $center );
1041
1042       As with "write_sting()" the maximum string size is 32767 characters.
1043       See also the note about "Cell notation".
1044
1045   keep_leading_zeros()
1046       This method changes the default handling of integers with leading zeros
1047       when using the "write()" method.
1048
1049       The "write()" method uses regular expressions to determine what type of
1050       data to write to an Excel worksheet. If the data looks like a number it
1051       writes a number using "write_number()". One problem with this approach
1052       is that occasionally data looks like a number but you don't want it
1053       treated as a number.
1054
1055       Zip codes and ID numbers, for example, often start with a leading zero.
1056       If you write this data as a number then the leading zero(s) will be
1057       stripped. This is the also the default behaviour when you enter data
1058       manually in Excel.
1059
1060       To get around this you can use one of three options. Write a formatted
1061       number, write the number as a string or use the "keep_leading_zeros()"
1062       method to change the default behaviour of "write()":
1063
1064           # Implicitly write a number, the leading zero is removed: 1209
1065           $worksheet->write( 'A1', '01209' );
1066
1067           # Write a zero padded number using a format: 01209
1068           my $format1 = $workbook->add_format( num_format => '00000' );
1069           $worksheet->write( 'A2', '01209', $format1 );
1070
1071           # Write explicitly as a string: 01209
1072           $worksheet->write_string( 'A3', '01209' );
1073
1074           # Write implicitly as a string: 01209
1075           $worksheet->keep_leading_zeros();
1076           $worksheet->write( 'A4', '01209' );
1077
1078       The above code would generate a worksheet that looked like the
1079       following:
1080
1081            -----------------------------------------------------------
1082           |   |     A     |     B     |     C     |     D     | ...
1083            -----------------------------------------------------------
1084           | 1 |      1209 |           |           |           | ...
1085           | 2 |     01209 |           |           |           | ...
1086           | 3 | 01209     |           |           |           | ...
1087           | 4 | 01209     |           |           |           | ...
1088
1089       The examples are on different sides of the cells due to the fact that
1090       Excel displays strings with a left justification and numbers with a
1091       right justification by default. You can change this by using a format
1092       to justify the data, see "CELL FORMATTING".
1093
1094       It should be noted that if the user edits the data in examples "A3" and
1095       "A4" the strings will revert back to numbers. Again this is Excel's
1096       default behaviour. To avoid this you can use the text format "@":
1097
1098           # Format as a string (01209)
1099           my $format2 = $workbook->add_format( num_format => '@' );
1100           $worksheet->write_string( 'A5', '01209', $format2 );
1101
1102       The "keep_leading_zeros()" property is off by default. The
1103       "keep_leading_zeros()" method takes 0 or 1 as an argument. It defaults
1104       to 1 if an argument isn't specified:
1105
1106           $worksheet->keep_leading_zeros();       # Set on
1107           $worksheet->keep_leading_zeros( 1 );    # Set on
1108           $worksheet->keep_leading_zeros( 0 );    # Set off
1109
1110       See also the "add_write_handler()" method.
1111
1112   write_blank( $row, $column, $format )
1113       Write a blank cell specified by $row and $column:
1114
1115           $worksheet->write_blank( 0, 0, $format );
1116
1117       This method is used to add formatting to a cell which doesn't contain a
1118       string or number value.
1119
1120       Excel differentiates between an "Empty" cell and a "Blank" cell. An
1121       "Empty" cell is a cell which doesn't contain data whilst a "Blank" cell
1122       is a cell which doesn't contain data but does contain formatting. Excel
1123       stores "Blank" cells but ignores "Empty" cells.
1124
1125       As such, if you write an empty cell without formatting it is ignored:
1126
1127           $worksheet->write( 'A1', undef, $format );    # write_blank()
1128           $worksheet->write( 'A2', undef );             # Ignored
1129
1130       This seemingly uninteresting fact means that you can write arrays of
1131       data without special treatment for "undef" or empty string values.
1132
1133       See the note about "Cell notation".
1134
1135   write_row( $row, $column, $array_ref, $format )
1136       The "write_row()" method can be used to write a 1D or 2D array of data
1137       in one go. This is useful for converting the results of a database
1138       query into an Excel worksheet. You must pass a reference to the array
1139       of data rather than the array itself. The "write()" method is then
1140       called for each element of the data. For example:
1141
1142           @array = ( 'awk', 'gawk', 'mawk' );
1143           $array_ref = \@array;
1144
1145           $worksheet->write_row( 0, 0, $array_ref );
1146
1147           # The above example is equivalent to:
1148           $worksheet->write( 0, 0, $array[0] );
1149           $worksheet->write( 0, 1, $array[1] );
1150           $worksheet->write( 0, 2, $array[2] );
1151
1152       Note: For convenience the "write()" method behaves in the same way as
1153       "write_row()" if it is passed an array reference. Therefore the
1154       following two method calls are equivalent:
1155
1156           $worksheet->write_row( 'A1', $array_ref );    # Write a row of data
1157           $worksheet->write(     'A1', $array_ref );    # Same thing
1158
1159       As with all of the write methods the $format parameter is optional. If
1160       a format is specified it is applied to all the elements of the data
1161       array.
1162
1163       Array references within the data will be treated as columns. This
1164       allows you to write 2D arrays of data in one go. For example:
1165
1166           @eec =  (
1167                       ['maggie', 'milly', 'molly', 'may'  ],
1168                       [13,       14,      15,      16     ],
1169                       ['shell',  'star',  'crab',  'stone']
1170                   );
1171
1172           $worksheet->write_row( 'A1', \@eec );
1173
1174       Would produce a worksheet as follows:
1175
1176            -----------------------------------------------------------
1177           |   |    A    |    B    |    C    |    D    |    E    | ...
1178            -----------------------------------------------------------
1179           | 1 | maggie  | 13      | shell   | ...     |  ...    | ...
1180           | 2 | milly   | 14      | star    | ...     |  ...    | ...
1181           | 3 | molly   | 15      | crab    | ...     |  ...    | ...
1182           | 4 | may     | 16      | stone   | ...     |  ...    | ...
1183           | 5 | ...     | ...     | ...     | ...     |  ...    | ...
1184           | 6 | ...     | ...     | ...     | ...     |  ...    | ...
1185
1186       To write the data in a row-column order refer to the "write_col()"
1187       method below.
1188
1189       Any "undef" values in the data will be ignored unless a format is
1190       applied to the data, in which case a formatted blank cell will be
1191       written. In either case the appropriate row or column value will still
1192       be incremented.
1193
1194       To find out more about array references refer to "perlref" and
1195       "perlreftut" in the main Perl documentation. To find out more about 2D
1196       arrays or "lists of lists" refer to "perllol".
1197
1198       The "write_row()" method returns the first error encountered when
1199       writing the elements of the data or zero if no errors were encountered.
1200       See the return values described for the "write()" method above.
1201
1202       See also the "write_arrays.pl" program in the "examples" directory of
1203       the distro.
1204
1205       The "write_row()" method allows the following idiomatic conversion of a
1206       text file to an Excel file:
1207
1208           #!/usr/bin/perl -w
1209
1210           use strict;
1211           use Excel::Writer::XLSX;
1212
1213           my $workbook  = Excel::Writer::XLSX->new( 'file.xlsx' );
1214           my $worksheet = $workbook->add_worksheet();
1215
1216           open INPUT, 'file.txt' or die "Couldn't open file: $!";
1217
1218           $worksheet->write( $. -1, 0, [split] ) while <INPUT>;
1219
1220           $workbook->close();
1221
1222   write_col( $row, $column, $array_ref, $format )
1223       The "write_col()" method can be used to write a 1D or 2D array of data
1224       in one go. This is useful for converting the results of a database
1225       query into an Excel worksheet. You must pass a reference to the array
1226       of data rather than the array itself. The "write()" method is then
1227       called for each element of the data. For example:
1228
1229           @array = ( 'awk', 'gawk', 'mawk' );
1230           $array_ref = \@array;
1231
1232           $worksheet->write_col( 0, 0, $array_ref );
1233
1234           # The above example is equivalent to:
1235           $worksheet->write( 0, 0, $array[0] );
1236           $worksheet->write( 1, 0, $array[1] );
1237           $worksheet->write( 2, 0, $array[2] );
1238
1239       As with all of the write methods the $format parameter is optional. If
1240       a format is specified it is applied to all the elements of the data
1241       array.
1242
1243       Array references within the data will be treated as rows. This allows
1244       you to write 2D arrays of data in one go. For example:
1245
1246           @eec =  (
1247                       ['maggie', 'milly', 'molly', 'may'  ],
1248                       [13,       14,      15,      16     ],
1249                       ['shell',  'star',  'crab',  'stone']
1250                   );
1251
1252           $worksheet->write_col( 'A1', \@eec );
1253
1254       Would produce a worksheet as follows:
1255
1256            -----------------------------------------------------------
1257           |   |    A    |    B    |    C    |    D    |    E    | ...
1258            -----------------------------------------------------------
1259           | 1 | maggie  | milly   | molly   | may     |  ...    | ...
1260           | 2 | 13      | 14      | 15      | 16      |  ...    | ...
1261           | 3 | shell   | star    | crab    | stone   |  ...    | ...
1262           | 4 | ...     | ...     | ...     | ...     |  ...    | ...
1263           | 5 | ...     | ...     | ...     | ...     |  ...    | ...
1264           | 6 | ...     | ...     | ...     | ...     |  ...    | ...
1265
1266       To write the data in a column-row order refer to the "write_row()"
1267       method above.
1268
1269       Any "undef" values in the data will be ignored unless a format is
1270       applied to the data, in which case a formatted blank cell will be
1271       written. In either case the appropriate row or column value will still
1272       be incremented.
1273
1274       As noted above the "write()" method can be used as a synonym for
1275       "write_row()" and "write_row()" handles nested array refs as columns.
1276       Therefore, the following two method calls are equivalent although the
1277       more explicit call to "write_col()" would be preferable for
1278       maintainability:
1279
1280           $worksheet->write_col( 'A1', $array_ref     ); # Write a column of data
1281           $worksheet->write(     'A1', [ $array_ref ] ); # Same thing
1282
1283       To find out more about array references refer to "perlref" and
1284       "perlreftut" in the main Perl documentation. To find out more about 2D
1285       arrays or "lists of lists" refer to "perllol".
1286
1287       The "write_col()" method returns the first error encountered when
1288       writing the elements of the data or zero if no errors were encountered.
1289       See the return values described for the "write()" method above.
1290
1291       See also the "write_arrays.pl" program in the "examples" directory of
1292       the distro.
1293
1294   write_date_time( $row, $col, $date_string, $format )
1295       The "write_date_time()" method can be used to write a date or time to
1296       the cell specified by $row and $column:
1297
1298           $worksheet->write_date_time( 'A1', '2004-05-13T23:20', $date_format );
1299
1300       The $date_string should be in the following format:
1301
1302           yyyy-mm-ddThh:mm:ss.sss
1303
1304       This conforms to an ISO8601 date but it should be noted that the full
1305       range of ISO8601 formats are not supported.
1306
1307       The following variations on the $date_string parameter are permitted:
1308
1309           yyyy-mm-ddThh:mm:ss.sss         # Standard format
1310           yyyy-mm-ddT                     # No time
1311                     Thh:mm:ss.sss         # No date
1312           yyyy-mm-ddThh:mm:ss.sssZ        # Additional Z (but not time zones)
1313           yyyy-mm-ddThh:mm:ss             # No fractional seconds
1314           yyyy-mm-ddThh:mm                # No seconds
1315
1316       Note that the "T" is required in all cases.
1317
1318       A date should always have a $format, otherwise it will appear as a
1319       number, see "DATES AND TIME IN EXCEL" and "CELL FORMATTING". Here is a
1320       typical example:
1321
1322           my $date_format = $workbook->add_format( num_format => 'mm/dd/yy' );
1323           $worksheet->write_date_time( 'A1', '2004-05-13T23:20', $date_format );
1324
1325       Valid dates should be in the range 1900-01-01 to 9999-12-31, for the
1326       1900 epoch and 1904-01-01 to 9999-12-31, for the 1904 epoch. As with
1327       Excel, dates outside these ranges will be written as a string.
1328
1329       See also the date_time.pl program in the "examples" directory of the
1330       distro.
1331
1332   write_url( $row, $col, $url, $format, $label )
1333       Write a hyperlink to a URL in the cell specified by $row and $column.
1334       The hyperlink is comprised of two elements: the visible label and the
1335       invisible link. The visible label is the same as the link unless an
1336       alternative label is specified. The $label parameter is optional. The
1337       label is written using the "write()" method. Therefore it is possible
1338       to write strings, numbers or formulas as labels.
1339
1340       The $format parameter is also optional and the default Excel hyperlink
1341       style will be used if it isn't specified. If required you can access
1342       the default url format using the Workbook "get_default_url_format"
1343       method:
1344
1345           my $url_format = $workbook->get_default_url_format();
1346
1347       There are four web style URI's supported: "http://", "https://",
1348       "ftp://" and "mailto:":
1349
1350           $worksheet->write_url( 0, 0, 'ftp://www.perl.org/' );
1351           $worksheet->write_url( 'A3', 'http://www.perl.com/' );
1352           $worksheet->write_url( 'A4', 'mailto:jmcnamara@cpan.org' );
1353
1354       You can display an alternative string using the $label parameter:
1355
1356           $worksheet->write_url( 1, 0, 'http://www.perl.com/', undef, 'Perl' );
1357
1358       If you wish to have some other cell data such as a number or a formula
1359       you can overwrite the cell using another call to "write_*()":
1360
1361           $worksheet->write_url( 'A1', 'http://www.perl.com/' );
1362
1363           # Overwrite the URL string with a formula. The cell is still a link.
1364           # Note the use of the default url format for consistency with other links.
1365           my $url_format = $workbook->get_default_url_format();
1366           $worksheet->write_formula( 'A1', '=1+1', $url_format );
1367
1368       There are two local URIs supported: "internal:" and "external:". These
1369       are used for hyperlinks to internal worksheet references or external
1370       workbook and worksheet references:
1371
1372           $worksheet->write_url( 'A6',  'internal:Sheet2!A1' );
1373           $worksheet->write_url( 'A7',  'internal:Sheet2!A1' );
1374           $worksheet->write_url( 'A8',  'internal:Sheet2!A1:B2' );
1375           $worksheet->write_url( 'A9',  q{internal:'Sales Data'!A1} );
1376           $worksheet->write_url( 'A10', 'external:c:\temp\foo.xlsx' );
1377           $worksheet->write_url( 'A11', 'external:c:\foo.xlsx#Sheet2!A1' );
1378           $worksheet->write_url( 'A12', 'external:..\foo.xlsx' );
1379           $worksheet->write_url( 'A13', 'external:..\foo.xlsx#Sheet2!A1' );
1380           $worksheet->write_url( 'A13', 'external:\\\\NET\share\foo.xlsx' );
1381
1382       All of the these URI types are recognised by the "write()" method, see
1383       above.
1384
1385       Worksheet references are typically of the form "Sheet1!A1". You can
1386       also refer to a worksheet range using the standard Excel notation:
1387       "Sheet1!A1:B2".
1388
1389       In external links the workbook and worksheet name must be separated by
1390       the "#" character: "external:Workbook.xlsx#Sheet1!A1'".
1391
1392       You can also link to a named range in the target worksheet. For example
1393       say you have a named range called "my_name" in the workbook
1394       "c:\temp\foo.xlsx" you could link to it as follows:
1395
1396           $worksheet->write_url( 'A14', 'external:c:\temp\foo.xlsx#my_name' );
1397
1398       Excel requires that worksheet names containing spaces or non
1399       alphanumeric characters are single quoted as follows "'Sales Data'!A1".
1400       If you need to do this in a single quoted string then you can either
1401       escape the single quotes "\'" or use the quote operator "q{}" as
1402       described in "perlop" in the main Perl documentation.
1403
1404       Links to network files are also supported. MS/Novell Network files
1405       normally begin with two back slashes as follows "\\NETWORK\etc". In
1406       order to generate this in a single or double quoted string you will
1407       have to escape the backslashes,  '\\\\NETWORK\etc'.
1408
1409       If you are using double quote strings then you should be careful to
1410       escape anything that looks like a metacharacter. For more information
1411       see "perlfaq5: Why can't I use "C:\temp\foo" in DOS paths?".
1412
1413       Finally, you can avoid most of these quoting problems by using forward
1414       slashes. These are translated internally to backslashes:
1415
1416           $worksheet->write_url( 'A14', "external:c:/temp/foo.xlsx" );
1417           $worksheet->write_url( 'A15', 'external://NETWORK/share/foo.xlsx' );
1418
1419       Note: Excel::Writer::XLSX will escape the following characters in URLs
1420       as required by Excel: "\s " < > \ [  ] ` ^ { }" unless the URL already
1421       contains %xx style escapes. In which case it is assumed that the URL
1422       was escaped correctly by the user and will by passed directly to Excel.
1423
1424       Versions of Excel prior to Excel 2015 limited hyperlink links and
1425       anchor/locations to 255 characters each. Versions after that support
1426       urls up to 2079 characters. Excel::Writer::XLSX versions >= 1.0.2
1427       support the new longer limit by default.
1428
1429       See also, the note about "Cell notation".
1430
1431   write_formula( $row, $column, $formula, $format, $value )
1432       Write a formula or function to the cell specified by $row and $column:
1433
1434           $worksheet->write_formula( 0, 0, '=$B$3 + B4' );
1435           $worksheet->write_formula( 1, 0, '=SIN(PI()/4)' );
1436           $worksheet->write_formula( 2, 0, '=SUM(B1:B5)' );
1437           $worksheet->write_formula( 'A4', '=IF(A3>1,"Yes", "No")' );
1438           $worksheet->write_formula( 'A5', '=AVERAGE(1, 2, 3, 4)' );
1439           $worksheet->write_formula( 'A6', '=DATEVALUE("1-Jan-2001")' );
1440
1441       Array formulas are also supported:
1442
1443           $worksheet->write_formula( 'A7', '{=SUM(A1:B1*A2:B2)}' );
1444
1445       See also the "write_array_formula()" method below.
1446
1447       See the note about "Cell notation". For more information about writing
1448       Excel formulas see "FORMULAS AND FUNCTIONS IN EXCEL"
1449
1450       If required, it is also possible to specify the calculated value of the
1451       formula. This is occasionally necessary when working with non-Excel
1452       applications that don't calculate the value of the formula. The
1453       calculated $value is added at the end of the argument list:
1454
1455           $worksheet->write( 'A1', '=2+2', $format, 4 );
1456
1457       However, this probably isn't something that you will ever need to do.
1458       If you do use this feature then do so with care.
1459
1460   write_array_formula($first_row, $first_col, $last_row, $last_col, $formula,
1461       $format, $value)
1462       Write an array formula to a cell range. In Excel an array formula is a
1463       formula that performs a calculation on a set of values. It can return a
1464       single value or a range of values.
1465
1466       An array formula is indicated by a pair of braces around the formula:
1467       "{=SUM(A1:B1*A2:B2)}".  If the array formula returns a single value
1468       then the $first_ and $last_ parameters should be the same:
1469
1470           $worksheet->write_array_formula('A1:A1', '{=SUM(B1:C1*B2:C2)}');
1471
1472       It this case however it is easier to just use the "write_formula()" or
1473       "write()" methods:
1474
1475           # Same as above but more concise.
1476           $worksheet->write( 'A1', '{=SUM(B1:C1*B2:C2)}' );
1477           $worksheet->write_formula( 'A1', '{=SUM(B1:C1*B2:C2)}' );
1478
1479       For array formulas that return a range of values you must specify the
1480       range that the return values will be written to:
1481
1482           $worksheet->write_array_formula( 'A1:A3',    '{=TREND(C1:C3,B1:B3)}' );
1483           $worksheet->write_array_formula( 0, 0, 2, 0, '{=TREND(C1:C3,B1:B3)}' );
1484
1485       If required, it is also possible to specify the calculated value of the
1486       formula. This is occasionally necessary when working with non-Excel
1487       applications that don't calculate the value of the formula. However,
1488       using this parameter only writes a single value to the upper left cell
1489       in the result array. For a multi-cell array formula where the results
1490       are required, the other result values can be specified by using
1491       "write_number()" to write to the appropriate cell:
1492
1493           # Specify the result for a single cell range.
1494           $worksheet->write_array_formula( 'A1:A3', '{=SUM(B1:C1*B2:C2)}, $format, 2005 );
1495
1496           # Specify the results for a multi cell range.
1497           $worksheet->write_array_formula( 'A1:A3', '{=TREND(C1:C3,B1:B3)}', $format, 105 );
1498           $worksheet->write_number( 'A2', 12, format );
1499           $worksheet->write_number( 'A3', 14, format );
1500
1501       In addition, some early versions of Excel 2007 don't calculate the
1502       values of array formulas when they aren't supplied. Installing the
1503       latest Office Service Pack should fix this issue.
1504
1505       See also the "array_formula.pl" program in the "examples" directory of
1506       the distro.
1507
1508       Note: Array formulas are not supported by Spreadsheet::WriteExcel.
1509
1510   write_boolean( $row, $column, $value, $format )
1511       Write an Excel boolean value to the cell specified by $row and $column:
1512
1513           $worksheet->write_boolean( 'A1', 1          );  # TRUE
1514           $worksheet->write_boolean( 'A2', 0          );  # FALSE
1515           $worksheet->write_boolean( 'A3', undef      );  # FALSE
1516           $worksheet->write_boolean( 'A3', 0, $format );  # FALSE, with format.
1517
1518       A $value that is true or false using Perl's rules will be written as an
1519       Excel boolean "TRUE" or "FALSE" value.
1520
1521       See the note about "Cell notation".
1522
1523   store_formula( $formula )
1524       Deprecated. This is a Spreadsheet::WriteExcel method that is no longer
1525       required by Excel::Writer::XLSX. See below.
1526
1527   repeat_formula( $row, $col, $formula, $format )
1528       Deprecated. This is a Spreadsheet::WriteExcel method that is no longer
1529       required by Excel::Writer::XLSX.
1530
1531       In Spreadsheet::WriteExcel it was computationally expensive to write
1532       formulas since they were parsed by a recursive descent parser. The
1533       "store_formula()" and "repeat_formula()" methods were used as a way of
1534       avoiding the overhead of repeated formulas by reusing a pre-parsed
1535       formula.
1536
1537       In Excel::Writer::XLSX this is no longer necessary since it is just as
1538       quick to write a formula as it is to write a string or a number.
1539
1540       The methods remain for backward compatibility but new
1541       Excel::Writer::XLSX programs shouldn't use them.
1542
1543   write_comment( $row, $column, $string, ... )
1544       The "write_comment()" method is used to add a comment to a cell. A cell
1545       comment is indicated in Excel by a small red triangle in the upper
1546       right-hand corner of the cell. Moving the cursor over the red triangle
1547       will reveal the comment.
1548
1549       The following example shows how to add a comment to a cell:
1550
1551           $worksheet->write        ( 2, 2, 'Hello' );
1552           $worksheet->write_comment( 2, 2, 'This is a comment.' );
1553
1554       As usual you can replace the $row and $column parameters with an "A1"
1555       cell reference. See the note about "Cell notation".
1556
1557           $worksheet->write        ( 'C3', 'Hello');
1558           $worksheet->write_comment( 'C3', 'This is a comment.' );
1559
1560       The "write_comment()" method will also handle strings in "UTF-8"
1561       format.
1562
1563           $worksheet->write_comment( 'C3', "\x{263a}" );       # Smiley
1564           $worksheet->write_comment( 'C4', 'Comment ca va?' );
1565
1566       In addition to the basic 3 argument form of "write_comment()" you can
1567       pass in several optional key/value pairs to control the format of the
1568       comment. For example:
1569
1570           $worksheet->write_comment( 'C3', 'Hello', visible => 1, author => 'Perl' );
1571
1572       Most of these options are quite specific and in general the default
1573       comment behaves will be all that you need. However, should you need
1574       greater control over the format of the cell comment the following
1575       options are available:
1576
1577           author
1578           visible
1579           x_scale
1580           width
1581           y_scale
1582           height
1583           color
1584           start_cell
1585           start_row
1586           start_col
1587           x_offset
1588           y_offset
1589           font
1590           font_size
1591
1592       Option: author
1593           This option is used to indicate who is the author of the cell
1594           comment. Excel displays the author of the comment in the status bar
1595           at the bottom of the worksheet. This is usually of interest in
1596           corporate environments where several people might review and
1597           provide comments to a workbook.
1598
1599               $worksheet->write_comment( 'C3', 'Atonement', author => 'Ian McEwan' );
1600
1601           The default author for all cell comments can be set using the
1602           "set_comments_author()" method (see below).
1603
1604               $worksheet->set_comments_author( 'Perl' );
1605
1606       Option: visible
1607           This option is used to make a cell comment visible when the
1608           worksheet is opened. The default behaviour in Excel is that
1609           comments are initially hidden. However, it is also possible in
1610           Excel to make individual or all comments visible. In
1611           Excel::Writer::XLSX individual comments can be made visible as
1612           follows:
1613
1614               $worksheet->write_comment( 'C3', 'Hello', visible => 1 );
1615
1616           It is possible to make all comments in a worksheet visible using
1617           the "show_comments()" worksheet method (see below). Alternatively,
1618           if all of the cell comments have been made visible you can hide
1619           individual comments:
1620
1621               $worksheet->write_comment( 'C3', 'Hello', visible => 0 );
1622
1623       Option: x_scale
1624           This option is used to set the width of the cell comment box as a
1625           factor of the default width.
1626
1627               $worksheet->write_comment( 'C3', 'Hello', x_scale => 2 );
1628               $worksheet->write_comment( 'C4', 'Hello', x_scale => 4.2 );
1629
1630       Option: width
1631           This option is used to set the width of the cell comment box
1632           explicitly in pixels.
1633
1634               $worksheet->write_comment( 'C3', 'Hello', width => 200 );
1635
1636       Option: y_scale
1637           This option is used to set the height of the cell comment box as a
1638           factor of the default height.
1639
1640               $worksheet->write_comment( 'C3', 'Hello', y_scale => 2 );
1641               $worksheet->write_comment( 'C4', 'Hello', y_scale => 4.2 );
1642
1643       Option: height
1644           This option is used to set the height of the cell comment box
1645           explicitly in pixels.
1646
1647               $worksheet->write_comment( 'C3', 'Hello', height => 200 );
1648
1649       Option: color
1650           This option is used to set the background colour of cell comment
1651           box. You can use one of the named colours recognised by
1652           Excel::Writer::XLSX or a Html style "#RRGGBB" colour. See "WORKING
1653           WITH COLOURS".
1654
1655               $worksheet->write_comment( 'C3', 'Hello', color => 'green' );
1656               $worksheet->write_comment( 'C4', 'Hello', color => '#FF6600' ); # Orange
1657
1658       Option: start_cell
1659           This option is used to set the cell in which the comment will
1660           appear. By default Excel displays comments one cell to the right
1661           and one cell above the cell to which the comment relates. However,
1662           you can change this behaviour if you wish. In the following example
1663           the comment which would appear by default in cell "D2" is moved to
1664           "E2".
1665
1666               $worksheet->write_comment( 'C3', 'Hello', start_cell => 'E2' );
1667
1668       Option: start_row
1669           This option is used to set the row in which the comment will
1670           appear. See the "start_cell" option above. The row is zero indexed.
1671
1672               $worksheet->write_comment( 'C3', 'Hello', start_row => 0 );
1673
1674       Option: start_col
1675           This option is used to set the column in which the comment will
1676           appear. See the "start_cell" option above. The column is zero
1677           indexed.
1678
1679               $worksheet->write_comment( 'C3', 'Hello', start_col => 4 );
1680
1681       Option: x_offset
1682           This option is used to change the x offset, in pixels, of a comment
1683           within a cell:
1684
1685               $worksheet->write_comment( 'C3', $comment, x_offset => 30 );
1686
1687       Option: y_offset
1688           This option is used to change the y offset, in pixels, of a comment
1689           within a cell:
1690
1691               $worksheet->write_comment('C3', $comment, x_offset => 30);
1692
1693       Option: font
1694           This option is used to change the font used in the comment from
1695           'Tahoma' which is the default.
1696
1697               $worksheet->write_comment('C3', $comment, font => 'Calibri');
1698
1699       Option: font_size
1700           This option is used to change the font size used in the comment
1701           from 8 which is the default.
1702
1703               $worksheet->write_comment('C3', $comment, font_size => 20);
1704
1705       You can apply as many of these options as you require.
1706
1707       Note about using options that adjust the position of the cell comment
1708       such as start_cell, start_row, start_col, x_offset and y_offset: Excel
1709       only displays offset cell comments when they are displayed as
1710       "visible". Excel does not display hidden cells as moved when you mouse
1711       over them.
1712
1713       Note about row height and comments. If you specify the height of a row
1714       that contains a comment then Excel::Writer::XLSX will adjust the height
1715       of the comment to maintain the default or user specified dimensions.
1716       However, the height of a row can also be adjusted automatically by
1717       Excel if the text wrap property is set or large fonts are used in the
1718       cell. This means that the height of the row is unknown to the module at
1719       run time and thus the comment box is stretched with the row. Use the
1720       "set_row()" method to specify the row height explicitly and avoid this
1721       problem.
1722
1723   show_comments()
1724       This method is used to make all cell comments visible when a worksheet
1725       is opened.
1726
1727           $worksheet->show_comments();
1728
1729       Individual comments can be made visible using the "visible" parameter
1730       of the "write_comment" method (see above):
1731
1732           $worksheet->write_comment( 'C3', 'Hello', visible => 1 );
1733
1734       If all of the cell comments have been made visible you can hide
1735       individual comments as follows:
1736
1737           $worksheet->show_comments();
1738           $worksheet->write_comment( 'C3', 'Hello', visible => 0 );
1739
1740   set_comments_author()
1741       This method is used to set the default author of all cell comments.
1742
1743           $worksheet->set_comments_author( 'Perl' );
1744
1745       Individual comment authors can be set using the "author" parameter of
1746       the "write_comment" method (see above).
1747
1748       The default comment author is an empty string, '', if no author is
1749       specified.
1750
1751   add_write_handler( $re, $code_ref )
1752       This method is used to extend the Excel::Writer::XLSX write() method to
1753       handle user defined data.
1754
1755       If you refer to the section on "write()" above you will see that it
1756       acts as an alias for several more specific "write_*" methods. However,
1757       it doesn't always act in exactly the way that you would like it to.
1758
1759       One solution is to filter the input data yourself and call the
1760       appropriate "write_*" method. Another approach is to use the
1761       "add_write_handler()" method to add your own automated behaviour to
1762       "write()".
1763
1764       The "add_write_handler()" method take two arguments, $re, a regular
1765       expression to match incoming data and $code_ref a callback function to
1766       handle the matched data:
1767
1768           $worksheet->add_write_handler( qr/^\d\d\d\d$/, \&my_write );
1769
1770       (In the these examples the "qr" operator is used to quote the regular
1771       expression strings, see perlop for more details).
1772
1773       The method is used as follows. say you wished to write 7 digit ID
1774       numbers as a string so that any leading zeros were preserved*, you
1775       could do something like the following:
1776
1777           $worksheet->add_write_handler( qr/^\d{7}$/, \&write_my_id );
1778
1779
1780           sub write_my_id {
1781               my $worksheet = shift;
1782               return $worksheet->write_string( @_ );
1783           }
1784
1785       * You could also use the "keep_leading_zeros()" method for this.
1786
1787       Then if you call "write()" with an appropriate string it will be
1788       handled automatically:
1789
1790           # Writes 0000000. It would normally be written as a number; 0.
1791           $worksheet->write( 'A1', '0000000' );
1792
1793       The callback function will receive a reference to the calling worksheet
1794       and all of the other arguments that were passed to "write()". The
1795       callback will see an @_ argument list that looks like the following:
1796
1797           $_[0]   A ref to the calling worksheet. *
1798           $_[1]   Zero based row number.
1799           $_[2]   Zero based column number.
1800           $_[3]   A number or string or token.
1801           $_[4]   A format ref if any.
1802           $_[5]   Any other arguments.
1803           ...
1804
1805           *  It is good style to shift this off the list so the @_ is the same
1806              as the argument list seen by write().
1807
1808       Your callback should "return()" the return value of the "write_*"
1809       method that was called or "undef" to indicate that you rejected the
1810       match and want "write()" to continue as normal.
1811
1812       So for example if you wished to apply the previous filter only to ID
1813       values that occur in the first column you could modify your callback
1814       function as follows:
1815
1816           sub write_my_id {
1817               my $worksheet = shift;
1818               my $col       = $_[1];
1819
1820               if ( $col == 0 ) {
1821                   return $worksheet->write_string( @_ );
1822               }
1823               else {
1824                   # Reject the match and return control to write()
1825                   return undef;
1826               }
1827           }
1828
1829       Now, you will get different behaviour for the first column and other
1830       columns:
1831
1832           $worksheet->write( 'A1', '0000000' );    # Writes 0000000
1833           $worksheet->write( 'B1', '0000000' );    # Writes 0
1834
1835       You may add more than one handler in which case they will be called in
1836       the order that they were added.
1837
1838       Note, the "add_write_handler()" method is particularly suited for
1839       handling dates.
1840
1841       See the "write_handler 1-4" programs in the "examples" directory for
1842       further examples.
1843
1844   insert_image( $row, $col, $filename, { %options } )
1845       This method can be used to insert a image into a worksheet. The image
1846       can be in PNG, JPEG or BMP format.
1847
1848           $worksheet1->insert_image( 'A1', 'perl.bmp' );
1849           $worksheet2->insert_image( 'A1', '../images/perl.bmp' );
1850           $worksheet3->insert_image( 'A1', '.c:\images\perl.bmp' );
1851
1852       The optional "options" hash/hashref parameter can be used to set
1853       various options for the image. The defaults are:
1854
1855           %options = (
1856               x_offset        => 0,
1857               y_offset        => 0,
1858               x_scale         => 1,
1859               y_scale         => 1,
1860               object_position => 2,
1861               url             => undef,
1862               tip             => undef,
1863           );
1864
1865       The parameters "x_offset" and "y_offset" can be used to specify an
1866       offset from the top left hand corner of the cell specified by $row and
1867       $col. The offset values are in pixels.
1868
1869           $worksheet1->insert_image('A1', 'perl.bmp', { x_offset =>32, y_offset => 10 });
1870
1871       The offsets can be greater than the width or height of the underlying
1872       cell. This can be occasionally useful if you wish to align two or more
1873       images relative to the same cell.
1874
1875       The parameters "x_scale" and "y_scale" can be used to scale the
1876       inserted image horizontally and vertically:
1877
1878           # Scale the inserted image: width x 2.0, height x 0.8
1879           $worksheet->insert_image( 'A1', 'perl.bmp', { y_scale => 2, y_scale => 0.8 } );
1880
1881       The positioning of the image when cells are resized can be set with the
1882       "object_position" parameter:
1883
1884           $worksheet->insert_image( 'A1', 'perl.bmp', { object_position => 1 } );
1885
1886       The "object_position" parameter can have one of the following allowable
1887       values:
1888
1889           1. Move and size with cells.
1890           2. Move but don't size with cells.
1891           3. Don't move or size with cells.
1892           4. Same as Option 1, see below.
1893
1894       Option 4 appears in Excel as Option 1. However, the worksheet object is
1895       sized to take hidden rows or columns into account. This allows the user
1896       to hide an image in a cell, possibly as part of an autofilter.
1897
1898       The "url" option can be use to used to add a hyperlink to an image:
1899
1900           $worksheet->insert_image( 'A1', 'logo.png',
1901               { url => 'https://github.com/jmcnamara' } );
1902
1903       The supported url formats are the same as those supported by the
1904       "write_url()" method and the same rules/limits apply.
1905
1906       The "tip" option can be use to used to add a mouseover tip to the
1907       hyperlink:
1908
1909           $worksheet->insert_image( 'A1', 'logo.png',
1910               {
1911                   url => 'https://github.com/jmcnamara',
1912                   tip => 'GitHub'
1913               }
1914           );
1915
1916       Note: you must call "set_row()" or "set_column()" before
1917       "insert_image()" if you wish to change the default dimensions of any of
1918       the rows or columns that the image occupies. The height of a row can
1919       also change if you use a font that is larger than the default. This in
1920       turn will affect the scaling of your image. To avoid this you should
1921       explicitly set the height of the row using "set_row()" if it contains a
1922       font size that will change the row height.
1923
1924       BMP images must be 24 bit, true colour, bitmaps. In general it is best
1925       to avoid BMP images since they aren't compressed.
1926
1927   insert_chart( $row, $col, $chart, { %options } )
1928       This method can be used to insert a Chart object into a worksheet. The
1929       Chart must be created by the "add_chart()" Workbook method and it must
1930       have the "embedded" option set.
1931
1932           my $chart = $workbook->add_chart( type => 'line', embedded => 1 );
1933
1934           # Configure the chart.
1935           ...
1936
1937           # Insert the chart into the a worksheet.
1938           $worksheet->insert_chart( 'E2', $chart );
1939
1940       See "add_chart()" for details on how to create the Chart object and
1941       Excel::Writer::XLSX::Chart for details on how to configure it. See also
1942       the "chart_*.pl" programs in the examples directory of the distro.
1943
1944       The optional "options" hash/hashref parameter can be used to set
1945       various options for the chart. The defaults are:
1946
1947           %options = (
1948               x_offset        => 0,
1949               y_offset        => 0,
1950               x_scale         => 1,
1951               y_scale         => 1,
1952               object_position => 1,
1953           );
1954
1955       The parameters "x_offset" and "y_offset" can be used to specify an
1956       offset from the top left hand corner of the cell specified by $row and
1957       $col. The offset values are in pixels.
1958
1959           $worksheet1->insert_chart( 'E2', $chart, { x_offset =>10, y_offset => 20 });
1960
1961       The parameters "x_scale" and "y_scale" can be used to scale the
1962       inserted chart horizontally and vertically:
1963
1964           # Scale the width by 120% and the height by 150%
1965           $worksheet->insert_chart( 'E2', $chart, { y_scale => 1.2, y_scale => 1.5 } );
1966
1967       The positioning of the chart when cells are resized can be set with the
1968       "object_position" parameter:
1969
1970           $worksheet->insert_chart( 'E2', $chart, { object_position => 2 } );
1971
1972       The "object_position" parameter can have one of the following allowable
1973       values:
1974
1975           1. Move and size with cells.
1976           2. Move but don't size with cells.
1977           3. Don't move or size with cells.
1978           4. Same as Option 1, see below.
1979
1980       Option 4 appears in Excel as Option 1. However, the worksheet object is
1981       sized to take hidden rows or columns into account. This is generally
1982       only useful for images and not for charts.
1983
1984   insert_shape( $row, $col, $shape, $x, $y, $x_scale, $y_scale )
1985       This method can be used to insert a Shape object into a worksheet. The
1986       Shape must be created by the "add_shape()" Workbook method.
1987
1988           my $shape = $workbook->add_shape( name => 'My Shape', type => 'plus' );
1989
1990           # Configure the shape.
1991           $shape->set_text('foo');
1992           ...
1993
1994           # Insert the shape into the a worksheet.
1995           $worksheet->insert_shape( 'E2', $shape );
1996
1997       See "add_shape()" for details on how to create the Shape object and
1998       Excel::Writer::XLSX::Shape for details on how to configure it.
1999
2000       The $x, $y, $x_scale and $y_scale parameters are optional.
2001
2002       The parameters $x and $y can be used to specify an offset from the top
2003       left hand corner of the cell specified by $row and $col. The offset
2004       values are in pixels.
2005
2006           $worksheet1->insert_shape( 'E2', $chart, 3, 3 );
2007
2008       The parameters $x_scale and $y_scale can be used to scale the inserted
2009       shape horizontally and vertically:
2010
2011           # Scale the width by 120% and the height by 150%
2012           $worksheet->insert_shape( 'E2', $shape, 0, 0, 1.2, 1.5 );
2013
2014       See also the "shape*.pl" programs in the examples directory of the
2015       distro.
2016
2017   insert_button( $row, $col, { %options })
2018       The "insert_button()" method can be used to insert an Excel form button
2019       into a worksheet.
2020
2021       This method is generally only useful when used in conjunction with the
2022       Workbook "add_vba_project()" method to tie the button to a macro from
2023       an embedded VBA project:
2024
2025           my $workbook  = Excel::Writer::XLSX->new( 'file.xlsm' );
2026           ...
2027           $workbook->add_vba_project( './vbaProject.bin' );
2028
2029           $worksheet->insert_button( 'C2', { macro => 'my_macro' } );
2030
2031       The properties of the button that can be set are:
2032
2033           macro
2034           caption
2035           width
2036           height
2037           x_scale
2038           y_scale
2039           x_offset
2040           y_offset
2041
2042       Option: macro
2043           This option is used to set the macro that the button will invoke
2044           when the user clicks on it. The macro should be included using the
2045           Workbook "add_vba_project()" method shown above.
2046
2047               $worksheet->insert_button( 'C2', { macro => 'my_macro' } );
2048
2049           The default macro is "ButtonX_Click" where X is the button number.
2050
2051       Option: caption
2052           This option is used to set the caption on the button. The default
2053           is "Button X" where X is the button number.
2054
2055               $worksheet->insert_button( 'C2', { macro => 'my_macro', caption => 'Hello' } );
2056
2057       Option: width
2058           This option is used to set the width of the button in pixels.
2059
2060               $worksheet->insert_button( 'C2', { macro => 'my_macro', width => 128 } );
2061
2062           The default button width is 64 pixels which is the width of a
2063           default cell.
2064
2065       Option: height
2066           This option is used to set the height of the button in pixels.
2067
2068               $worksheet->insert_button( 'C2', { macro => 'my_macro', height => 40 } );
2069
2070           The default button height is 20 pixels which is the height of a
2071           default cell.
2072
2073       Option: x_scale
2074           This option is used to set the width of the button as a factor of
2075           the default width.
2076
2077               $worksheet->insert_button( 'C2', { macro => 'my_macro', x_scale => 2.0 );
2078
2079       Option: y_scale
2080           This option is used to set the height of the button as a factor of
2081           the default height.
2082
2083               $worksheet->insert_button( 'C2', { macro => 'my_macro', y_scale => 2.0 );
2084
2085       Option: x_offset
2086           This option is used to change the x offset, in pixels, of a button
2087           within a cell:
2088
2089               $worksheet->insert_button( 'C2', { macro => 'my_macro', x_offset => 2 );
2090
2091       Option: y_offset
2092           This option is used to change the y offset, in pixels, of a comment
2093           within a cell.
2094
2095       Note: Button is the only Excel form element that is available in
2096       Excel::Writer::XLSX. Form elements represent a lot of work to implement
2097       and the underlying VML syntax isn't very much fun.
2098
2099   data_validation()
2100       The "data_validation()" method is used to construct an Excel data
2101       validation or to limit the user input to a dropdown list of values.
2102
2103           $worksheet->data_validation('B3',
2104               {
2105                   validate => 'integer',
2106                   criteria => '>',
2107                   value    => 100,
2108               });
2109
2110           $worksheet->data_validation('B5:B9',
2111               {
2112                   validate => 'list',
2113                   value    => ['open', 'high', 'close'],
2114               });
2115
2116       This method contains a lot of parameters and is described in detail in
2117       a separate section "DATA VALIDATION IN EXCEL".
2118
2119       See also the "data_validate.pl" program in the examples directory of
2120       the distro
2121
2122   conditional_formatting()
2123       The "conditional_formatting()" method is used to add formatting to a
2124       cell or range of cells based on user defined criteria.
2125
2126           $worksheet->conditional_formatting( 'A1:J10',
2127               {
2128                   type     => 'cell',
2129                   criteria => '>=',
2130                   value    => 50,
2131                   format   => $format1,
2132               }
2133           );
2134
2135       This method contains a lot of parameters and is described in detail in
2136       a separate section "CONDITIONAL FORMATTING IN EXCEL".
2137
2138       See also the "conditional_format.pl" program in the examples directory
2139       of the distro
2140
2141   add_sparkline()
2142       The "add_sparkline()" worksheet method is used to add sparklines to a
2143       cell or a range of cells.
2144
2145           $worksheet->add_sparkline(
2146               {
2147                   location => 'F2',
2148                   range    => 'Sheet1!A2:E2',
2149                   type     => 'column',
2150                   style    => 12,
2151               }
2152           );
2153
2154       This method contains a lot of parameters and is described in detail in
2155       a separate section "SPARKLINES IN EXCEL".
2156
2157       See also the "sparklines1.pl" and "sparklines2.pl" example programs in
2158       the "examples" directory of the distro.
2159
2160       Note: Sparklines are a feature of Excel 2010+ only. You can write them
2161       to an XLSX file that can be read by Excel 2007 but they won't be
2162       displayed.
2163
2164   add_table()
2165       The "add_table()" method is used to group a range of cells into an
2166       Excel Table.
2167
2168           $worksheet->add_table( 'B3:F7', { ... } );
2169
2170       This method contains a lot of parameters and is described in detail in
2171       a separate section "TABLES IN EXCEL".
2172
2173       See also the "tables.pl" program in the examples directory of the
2174       distro
2175
2176   get_name()
2177       The "get_name()" method is used to retrieve the name of a worksheet.
2178       For example:
2179
2180           for my $sheet ( $workbook->sheets() ) {
2181               print $sheet->get_name();
2182           }
2183
2184       For reasons related to the design of Excel::Writer::XLSX and to the
2185       internals of Excel there is no "set_name()" method. The only way to set
2186       the worksheet name is via the "add_worksheet()" method.
2187
2188   activate()
2189       The "activate()" method is used to specify which worksheet is initially
2190       visible in a multi-sheet workbook:
2191
2192           $worksheet1 = $workbook->add_worksheet( 'To' );
2193           $worksheet2 = $workbook->add_worksheet( 'the' );
2194           $worksheet3 = $workbook->add_worksheet( 'wind' );
2195
2196           $worksheet3->activate();
2197
2198       This is similar to the Excel VBA activate method. More than one
2199       worksheet can be selected via the "select()" method, see below, however
2200       only one worksheet can be active.
2201
2202       The default active worksheet is the first worksheet.
2203
2204   select()
2205       The "select()" method is used to indicate that a worksheet is selected
2206       in a multi-sheet workbook:
2207
2208           $worksheet1->activate();
2209           $worksheet2->select();
2210           $worksheet3->select();
2211
2212       A selected worksheet has its tab highlighted. Selecting worksheets is a
2213       way of grouping them together so that, for example, several worksheets
2214       could be printed in one go. A worksheet that has been activated via the
2215       "activate()" method will also appear as selected.
2216
2217   hide()
2218       The "hide()" method is used to hide a worksheet:
2219
2220           $worksheet2->hide();
2221
2222       You may wish to hide a worksheet in order to avoid confusing a user
2223       with intermediate data or calculations.
2224
2225       A hidden worksheet can not be activated or selected so this method is
2226       mutually exclusive with the "activate()" and "select()" methods. In
2227       addition, since the first worksheet will default to being the active
2228       worksheet, you cannot hide the first worksheet without activating
2229       another sheet:
2230
2231           $worksheet2->activate();
2232           $worksheet1->hide();
2233
2234   set_first_sheet()
2235       The "activate()" method determines which worksheet is initially
2236       selected. However, if there are a large number of worksheets the
2237       selected worksheet may not appear on the screen. To avoid this you can
2238       select which is the leftmost visible worksheet using
2239       "set_first_sheet()":
2240
2241           for ( 1 .. 20 ) {
2242               $workbook->add_worksheet;
2243           }
2244
2245           $worksheet21 = $workbook->add_worksheet();
2246           $worksheet22 = $workbook->add_worksheet();
2247
2248           $worksheet21->set_first_sheet();
2249           $worksheet22->activate();
2250
2251       This method is not required very often. The default value is the first
2252       worksheet.
2253
2254   protect( $password, \%options )
2255       The "protect()" method is used to protect a worksheet from
2256       modification:
2257
2258           $worksheet->protect();
2259
2260       The "protect()" method also has the effect of enabling a cell's
2261       "locked" and "hidden" properties if they have been set. A locked cell
2262       cannot be edited and this property is on by default for all cells. A
2263       hidden cell will display the results of a formula but not the formula
2264       itself.
2265
2266       See the "protection.pl" program in the examples directory of the distro
2267       for an illustrative example and the "set_locked" and "set_hidden"
2268       format methods in "CELL FORMATTING".
2269
2270       You can optionally add a password to the worksheet protection:
2271
2272           $worksheet->protect( 'drowssap' );
2273
2274       Passing the empty string '' is the same as turning on protection
2275       without a password.
2276
2277       Note, the worksheet level password in Excel provides very weak
2278       protection. It does not encrypt your data and is very easy to
2279       deactivate. Full workbook encryption is not supported by
2280       "Excel::Writer::XLSX" since it requires a completely different file
2281       format and would take several man months to implement.
2282
2283       You can specify which worksheet elements you wish to protect by passing
2284       a hash_ref with any or all of the following keys:
2285
2286           # Default shown.
2287           %options = (
2288               objects               => 0,
2289               scenarios             => 0,
2290               format_cells          => 0,
2291               format_columns        => 0,
2292               format_rows           => 0,
2293               insert_columns        => 0,
2294               insert_rows           => 0,
2295               insert_hyperlinks     => 0,
2296               delete_columns        => 0,
2297               delete_rows           => 0,
2298               select_locked_cells   => 1,
2299               sort                  => 0,
2300               autofilter            => 0,
2301               pivot_tables          => 0,
2302               select_unlocked_cells => 1,
2303           );
2304
2305       The default boolean values are shown above. Individual elements can be
2306       protected as follows:
2307
2308           $worksheet->protect( 'drowssap', { insert_rows => 1 } );
2309
2310       For chartsheets the allowable options and default values are:
2311
2312           %options = (
2313               objects               => 1,
2314               content               => 1,
2315           );
2316
2317   set_selection( $first_row, $first_col, $last_row, $last_col )
2318       This method can be used to specify which cell or cells are selected in
2319       a worksheet. The most common requirement is to select a single cell, in
2320       which case $last_row and $last_col can be omitted. The active cell
2321       within a selected range is determined by the order in which $first and
2322       $last are specified. It is also possible to specify a cell or a range
2323       using A1 notation. See the note about "Cell notation".
2324
2325       Examples:
2326
2327           $worksheet1->set_selection( 3, 3 );          # 1. Cell D4.
2328           $worksheet2->set_selection( 3, 3, 6, 6 );    # 2. Cells D4 to G7.
2329           $worksheet3->set_selection( 6, 6, 3, 3 );    # 3. Cells G7 to D4.
2330           $worksheet4->set_selection( 'D4' );          # Same as 1.
2331           $worksheet5->set_selection( 'D4:G7' );       # Same as 2.
2332           $worksheet6->set_selection( 'G7:D4' );       # Same as 3.
2333
2334       The default cell selections is (0, 0), 'A1'.
2335
2336   set_row( $row, $height, $format, $hidden, $level, $collapsed )
2337       This method can be used to change the default properties of a row. All
2338       parameters apart from $row are optional.
2339
2340       The most common use for this method is to change the height of a row:
2341
2342           $worksheet->set_row( 0, 20 );    # Row 1 height set to 20
2343
2344       If you wish to set the format without changing the height you can pass
2345       "undef" as the height parameter:
2346
2347           $worksheet->set_row( 0, undef, $format );
2348
2349       The $format parameter will be applied to any cells in the row that
2350       don't have a format. For example
2351
2352           $worksheet->set_row( 0, undef, $format1 );    # Set the format for row 1
2353           $worksheet->write( 'A1', 'Hello' );           # Defaults to $format1
2354           $worksheet->write( 'B1', 'Hello', $format2 ); # Keeps $format2
2355
2356       If you wish to define a row format in this way you should call the
2357       method before any calls to "write()". Calling it afterwards will
2358       overwrite any format that was previously specified.
2359
2360       The $hidden parameter should be set to 1 if you wish to hide a row.
2361       This can be used, for example, to hide intermediary steps in a
2362       complicated calculation:
2363
2364           $worksheet->set_row( 0, 20,    $format, 1 );
2365           $worksheet->set_row( 1, undef, undef,   1 );
2366
2367       The $level parameter is used to set the outline level of the row.
2368       Outlines are described in "OUTLINES AND GROUPING IN EXCEL". Adjacent
2369       rows with the same outline level are grouped together into a single
2370       outline.
2371
2372       The following example sets an outline level of 1 for rows 2 and 3
2373       (zero-indexed):
2374
2375           $worksheet->set_row( 1, undef, undef, 0, 1 );
2376           $worksheet->set_row( 2, undef, undef, 0, 1 );
2377
2378       The $hidden parameter can also be used to hide collapsed outlined rows
2379       when used in conjunction with the $level parameter.
2380
2381           $worksheet->set_row( 1, undef, undef, 1, 1 );
2382           $worksheet->set_row( 2, undef, undef, 1, 1 );
2383
2384       For collapsed outlines you should also indicate which row has the
2385       collapsed "+" symbol using the optional $collapsed parameter.
2386
2387           $worksheet->set_row( 3, undef, undef, 0, 0, 1 );
2388
2389       For a more complete example see the "outline.pl" and
2390       "outline_collapsed.pl" programs in the examples directory of the
2391       distro.
2392
2393       Excel allows up to 7 outline levels. Therefore the $level parameter
2394       should be in the range "0 <= $level <= 7".
2395
2396   set_column( $first_col, $last_col, $width, $format, $hidden, $level,
2397       $collapsed )
2398       This method can be used to change the default properties of a single
2399       column or a range of columns. All parameters apart from $first_col and
2400       $last_col are optional.
2401
2402       If "set_column()" is applied to a single column the value of $first_col
2403       and $last_col should be the same. In the case where $last_col is zero
2404       it is set to the same value as $first_col.
2405
2406       It is also possible, and generally clearer, to specify a column range
2407       using the form of A1 notation used for columns. See the note about
2408       "Cell notation".
2409
2410       Examples:
2411
2412           $worksheet->set_column( 0, 0, 20 );    # Column  A   width set to 20
2413           $worksheet->set_column( 1, 3, 30 );    # Columns B-D width set to 30
2414           $worksheet->set_column( 'E:E', 20 );   # Column  E   width set to 20
2415           $worksheet->set_column( 'F:H', 30 );   # Columns F-H width set to 30
2416
2417       The width corresponds to the column width value that is specified in
2418       Excel. It is approximately equal to the length of a string in the
2419       default font of Calibri 11. Unfortunately, there is no way to specify
2420       "AutoFit" for a column in the Excel file format. This feature is only
2421       available at runtime from within Excel.
2422
2423       As usual the $format parameter is optional, for additional information,
2424       see "CELL FORMATTING". If you wish to set the format without changing
2425       the width you can pass "undef" as the width parameter:
2426
2427           $worksheet->set_column( 0, 0, undef, $format );
2428
2429       The $format parameter will be applied to any cells in the column that
2430       don't have a format. For example
2431
2432           $worksheet->set_column( 'A:A', undef, $format1 );    # Set format for col 1
2433           $worksheet->write( 'A1', 'Hello' );                  # Defaults to $format1
2434           $worksheet->write( 'A2', 'Hello', $format2 );        # Keeps $format2
2435
2436       If you wish to define a column format in this way you should call the
2437       method before any calls to "write()". If you call it afterwards it
2438       won't have any effect.
2439
2440       A default row format takes precedence over a default column format
2441
2442           $worksheet->set_row( 0, undef, $format1 );           # Set format for row 1
2443           $worksheet->set_column( 'A:A', undef, $format2 );    # Set format for col 1
2444           $worksheet->write( 'A1', 'Hello' );                  # Defaults to $format1
2445           $worksheet->write( 'A2', 'Hello' );                  # Defaults to $format2
2446
2447       The $hidden parameter should be set to 1 if you wish to hide a column.
2448       This can be used, for example, to hide intermediary steps in a
2449       complicated calculation:
2450
2451           $worksheet->set_column( 'D:D', 20,    $format, 1 );
2452           $worksheet->set_column( 'E:E', undef, undef,   1 );
2453
2454       The $level parameter is used to set the outline level of the column.
2455       Outlines are described in "OUTLINES AND GROUPING IN EXCEL". Adjacent
2456       columns with the same outline level are grouped together into a single
2457       outline.
2458
2459       The following example sets an outline level of 1 for columns B to G:
2460
2461           $worksheet->set_column( 'B:G', undef, undef, 0, 1 );
2462
2463       The $hidden parameter can also be used to hide collapsed outlined
2464       columns when used in conjunction with the $level parameter.
2465
2466           $worksheet->set_column( 'B:G', undef, undef, 1, 1 );
2467
2468       For collapsed outlines you should also indicate which row has the
2469       collapsed "+" symbol using the optional $collapsed parameter.
2470
2471           $worksheet->set_column( 'H:H', undef, undef, 0, 0, 1 );
2472
2473       For a more complete example see the "outline.pl" and
2474       "outline_collapsed.pl" programs in the examples directory of the
2475       distro.
2476
2477       Excel allows up to 7 outline levels. Therefore the $level parameter
2478       should be in the range "0 <= $level <= 7".
2479
2480   set_default_row( $height, $hide_unused_rows )
2481       The "set_default_row()" method is used to set the limited number of
2482       default row properties allowed by Excel. These are the default height
2483       and the option to hide unused rows.
2484
2485           $worksheet->set_default_row( 24 );  # Set the default row height to 24.
2486
2487       The option to hide unused rows is used by Excel as an optimisation so
2488       that the user can hide a large number of rows without generating a very
2489       large file with an entry for each hidden row.
2490
2491           $worksheet->set_default_row( undef, 1 );
2492
2493       See the "hide_row_col.pl" example program.
2494
2495   outline_settings( $visible, $symbols_below, $symbols_right, $auto_style )
2496       The "outline_settings()" method is used to control the appearance of
2497       outlines in Excel. Outlines are described in "OUTLINES AND GROUPING IN
2498       EXCEL".
2499
2500       The $visible parameter is used to control whether or not outlines are
2501       visible. Setting this parameter to 0 will cause all outlines on the
2502       worksheet to be hidden. They can be unhidden in Excel by means of the
2503       "Show Outline Symbols" command button. The default setting is 1 for
2504       visible outlines.
2505
2506           $worksheet->outline_settings( 0 );
2507
2508       The $symbols_below parameter is used to control whether the row outline
2509       symbol will appear above or below the outline level bar. The default
2510       setting is 1 for symbols to appear below the outline level bar.
2511
2512       The $symbols_right parameter is used to control whether the column
2513       outline symbol will appear to the left or the right of the outline
2514       level bar. The default setting is 1 for symbols to appear to the right
2515       of the outline level bar.
2516
2517       The $auto_style parameter is used to control whether the automatic
2518       outline generator in Excel uses automatic styles when creating an
2519       outline. This has no effect on a file generated by
2520       "Excel::Writer::XLSX" but it does have an effect on how the worksheet
2521       behaves after it is created. The default setting is 0 for "Automatic
2522       Styles" to be turned off.
2523
2524       The default settings for all of these parameters correspond to Excel's
2525       default parameters.
2526
2527       The worksheet parameters controlled by "outline_settings()" are rarely
2528       used.
2529
2530   freeze_panes( $row, $col, $top_row, $left_col )
2531       This method can be used to divide a worksheet into horizontal or
2532       vertical regions known as panes and to also "freeze" these panes so
2533       that the splitter bars are not visible. This is the same as the
2534       "Window->Freeze Panes" menu command in Excel
2535
2536       The parameters $row and $col are used to specify the location of the
2537       split. It should be noted that the split is specified at the top or
2538       left of a cell and that the method uses zero based indexing. Therefore
2539       to freeze the first row of a worksheet it is necessary to specify the
2540       split at row 2 (which is 1 as the zero-based index). This might lead
2541       you to think that you are using a 1 based index but this is not the
2542       case.
2543
2544       You can set one of the $row and $col parameters as zero if you do not
2545       want either a vertical or horizontal split.
2546
2547       Examples:
2548
2549           $worksheet->freeze_panes( 1, 0 );    # Freeze the first row
2550           $worksheet->freeze_panes( 'A2' );    # Same using A1 notation
2551           $worksheet->freeze_panes( 0, 1 );    # Freeze the first column
2552           $worksheet->freeze_panes( 'B1' );    # Same using A1 notation
2553           $worksheet->freeze_panes( 1, 2 );    # Freeze first row and first 2 columns
2554           $worksheet->freeze_panes( 'C2' );    # Same using A1 notation
2555
2556       The parameters $top_row and $left_col are optional. They are used to
2557       specify the top-most or left-most visible row or column in the
2558       scrolling region of the panes. For example to freeze the first row and
2559       to have the scrolling region begin at row twenty:
2560
2561           $worksheet->freeze_panes( 1, 0, 20, 0 );
2562
2563       You cannot use A1 notation for the $top_row and $left_col parameters.
2564
2565       See also the "panes.pl" program in the "examples" directory of the
2566       distribution.
2567
2568   split_panes( $y, $x, $top_row, $left_col )
2569       This method can be used to divide a worksheet into horizontal or
2570       vertical regions known as panes. This method is different from the
2571       "freeze_panes()" method in that the splits between the panes will be
2572       visible to the user and each pane will have its own scroll bars.
2573
2574       The parameters $y and $x are used to specify the vertical and
2575       horizontal position of the split. The units for $y and $x are the same
2576       as those used by Excel to specify row height and column width. However,
2577       the vertical and horizontal units are different from each other.
2578       Therefore you must specify the $y and $x parameters in terms of the row
2579       heights and column widths that you have set or the default values which
2580       are 15 for a row and 8.43 for a column.
2581
2582       You can set one of the $y and $x parameters as zero if you do not want
2583       either a vertical or horizontal split. The parameters $top_row and
2584       $left_col are optional. They are used to specify the top-most or left-
2585       most visible row or column in the bottom-right pane.
2586
2587       Example:
2588
2589           $worksheet->split_panes( 15, 0,   );    # First row
2590           $worksheet->split_panes( 0,  8.43 );    # First column
2591           $worksheet->split_panes( 15, 8.43 );    # First row and column
2592
2593       You cannot use A1 notation with this method.
2594
2595       See also the "freeze_panes()" method and the "panes.pl" program in the
2596       "examples" directory of the distribution.
2597
2598   merge_range( $first_row, $first_col, $last_row, $last_col, $token, $format
2599       )
2600       The "merge_range()" method allows you to merge cells that contain other
2601       types of alignment in addition to the merging:
2602
2603           my $format = $workbook->add_format(
2604               border => 6,
2605               valign => 'vcenter',
2606               align  => 'center',
2607           );
2608
2609           $worksheet->merge_range( 'B3:D4', 'Vertical and horizontal', $format );
2610
2611       "merge_range()" writes its $token argument using the worksheet
2612       "write()" method. Therefore it will handle numbers, strings, formulas
2613       or urls as required. If you need to specify the required "write_*()"
2614       method use the "merge_range_type()" method, see below.
2615
2616       The full possibilities of this method are shown in the "merge3.pl" to
2617       "merge6.pl" programs in the "examples" directory of the distribution.
2618
2619   merge_range_type( $type, $first_row, $first_col, $last_row, $last_col, ...
2620       )
2621       The "merge_range()" method, see above, uses "write()" to insert the
2622       required data into to a merged range. However, there may be times where
2623       this isn't what you require so as an alternative the "merge_range_type
2624       ()" method allows you to specify the type of data you wish to write.
2625       For example:
2626
2627           $worksheet->merge_range_type( 'number',  'B2:C2', 123,    $format1 );
2628           $worksheet->merge_range_type( 'string',  'B4:C4', 'foo',  $format2 );
2629           $worksheet->merge_range_type( 'formula', 'B6:C6', '=1+2', $format3 );
2630
2631       The $type must be one of the following, which corresponds to a
2632       "write_*()" method:
2633
2634           'number'
2635           'string'
2636           'formula'
2637           'array_formula'
2638           'blank'
2639           'rich_string'
2640           'date_time'
2641           'url'
2642
2643       Any arguments after the range should be whatever the appropriate method
2644       accepts:
2645
2646           $worksheet->merge_range_type( 'rich_string', 'B8:C8',
2647                                         'This is ', $bold, 'bold', $format4 );
2648
2649       Note, you must always pass a $format object as an argument, even if it
2650       is a default format.
2651
2652   set_zoom( $scale )
2653       Set the worksheet zoom factor in the range "10 <= $scale <= 400":
2654
2655           $worksheet1->set_zoom( 50 );
2656           $worksheet2->set_zoom( 75 );
2657           $worksheet3->set_zoom( 300 );
2658           $worksheet4->set_zoom( 400 );
2659
2660       The default zoom factor is 100. You cannot zoom to "Selection" because
2661       it is calculated by Excel at run-time.
2662
2663       Note, "set_zoom()" does not affect the scale of the printed page. For
2664       that you should use "set_print_scale()".
2665
2666   right_to_left()
2667       The "right_to_left()" method is used to change the default direction of
2668       the worksheet from left-to-right, with the A1 cell in the top left, to
2669       right-to-left, with the A1 cell in the top right.
2670
2671           $worksheet->right_to_left();
2672
2673       This is useful when creating Arabic, Hebrew or other near or far
2674       eastern worksheets that use right-to-left as the default direction.
2675
2676   hide_zero()
2677       The "hide_zero()" method is used to hide any zero values that appear in
2678       cells.
2679
2680           $worksheet->hide_zero();
2681
2682       In Excel this option is found under Tools->Options->View.
2683
2684   set_tab_color()
2685       The "set_tab_color()" method is used to change the colour of the
2686       worksheet tab. You can use one of the standard colour names provided by
2687       the Format object or a Html style "#RRGGBB" colour. See "WORKING WITH
2688       COLOURS".
2689
2690           $worksheet1->set_tab_color( 'red' );
2691           $worksheet2->set_tab_color( '#FF6600' );
2692
2693       See the "tab_colors.pl" program in the examples directory of the
2694       distro.
2695
2696   autofilter( $first_row, $first_col, $last_row, $last_col )
2697       This method allows an autofilter to be added to a worksheet. An
2698       autofilter is a way of adding drop down lists to the headers of a 2D
2699       range of worksheet data. This allows users to filter the data based on
2700       simple criteria so that some data is shown and some is hidden.
2701
2702       To add an autofilter to a worksheet:
2703
2704           $worksheet->autofilter( 0, 0, 10, 3 );
2705           $worksheet->autofilter( 'A1:D11' );    # Same as above in A1 notation.
2706
2707       Filter conditions can be applied using the "filter_column()" or
2708       "filter_column_list()" method.
2709
2710       See the "autofilter.pl" program in the examples directory of the distro
2711       for a more detailed example.
2712
2713   filter_column( $column, $expression )
2714       The "filter_column" method can be used to filter columns in a
2715       autofilter range based on simple conditions.
2716
2717       NOTE: It isn't sufficient to just specify the filter condition. You
2718       must also hide any rows that don't match the filter condition. Rows are
2719       hidden using the "set_row()" "visible" parameter. "Excel::Writer::XLSX"
2720       cannot do this automatically since it isn't part of the file format.
2721       See the "autofilter.pl" program in the examples directory of the distro
2722       for an example.
2723
2724       The conditions for the filter are specified using simple expressions:
2725
2726           $worksheet->filter_column( 'A', 'x > 2000' );
2727           $worksheet->filter_column( 'B', 'x > 2000 and x < 5000' );
2728
2729       The $column parameter can either be a zero indexed column number or a
2730       string column name.
2731
2732       The following operators are available:
2733
2734           Operator        Synonyms
2735              ==           =   eq  =~
2736              !=           <>  ne  !=
2737              >
2738              <
2739              >=
2740              <=
2741
2742              and          &&
2743              or           ||
2744
2745       The operator synonyms are just syntactic sugar to make you more
2746       comfortable using the expressions. It is important to remember that the
2747       expressions will be interpreted by Excel and not by perl.
2748
2749       An expression can comprise a single statement or two statements
2750       separated by the "and" and "or" operators. For example:
2751
2752           'x <  2000'
2753           'x >  2000'
2754           'x == 2000'
2755           'x >  2000 and x <  5000'
2756           'x == 2000 or  x == 5000'
2757
2758       Filtering of blank or non-blank data can be achieved by using a value
2759       of "Blanks" or "NonBlanks" in the expression:
2760
2761           'x == Blanks'
2762           'x == NonBlanks'
2763
2764       Excel also allows some simple string matching operations:
2765
2766           'x =~ b*'   # begins with b
2767           'x !~ b*'   # doesn't begin with b
2768           'x =~ *b'   # ends with b
2769           'x !~ *b'   # doesn't end with b
2770           'x =~ *b*'  # contains b
2771           'x !~ *b*'  # doesn't contains b
2772
2773       You can also use "*" to match any character or number and "?" to match
2774       any single character or number. No other regular expression quantifier
2775       is supported by Excel's filters. Excel's regular expression characters
2776       can be escaped using "~".
2777
2778       The placeholder variable "x" in the above examples can be replaced by
2779       any simple string. The actual placeholder name is ignored internally so
2780       the following are all equivalent:
2781
2782           'x     < 2000'
2783           'col   < 2000'
2784           'Price < 2000'
2785
2786       Also, note that a filter condition can only be applied to a column in a
2787       range specified by the "autofilter()" Worksheet method.
2788
2789       See the "autofilter.pl" program in the examples directory of the distro
2790       for a more detailed example.
2791
2792       Note Spreadsheet::WriteExcel supports Top 10 style filters. These
2793       aren't currently supported by Excel::Writer::XLSX but may be added
2794       later.
2795
2796   filter_column_list( $column, @matches )
2797       Prior to Excel 2007 it was only possible to have either 1 or 2 filter
2798       conditions such as the ones shown above in the "filter_column" method.
2799
2800       Excel 2007 introduced a new list style filter where it is possible to
2801       specify 1 or more 'or' style criteria. For example if your column
2802       contained data for the first six months the initial data would be
2803       displayed as all selected as shown on the left. Then if you selected
2804       'March', 'April' and 'May' they would be displayed as shown on the
2805       right.
2806
2807           No criteria selected      Some criteria selected.
2808
2809           [/] (Select all)          [X] (Select all)
2810           [/] January               [ ] January
2811           [/] February              [ ] February
2812           [/] March                 [/] March
2813           [/] April                 [/] April
2814           [/] May                   [/] May
2815           [/] June                  [ ] June
2816
2817       The "filter_column_list()" method can be used to represent these types
2818       of filters:
2819
2820           $worksheet->filter_column_list( 'A', 'March', 'April', 'May' );
2821
2822       The $column parameter can either be a zero indexed column number or a
2823       string column name.
2824
2825       One or more criteria can be selected:
2826
2827           $worksheet->filter_column_list( 0, 'March' );
2828           $worksheet->filter_column_list( 1, 100, 110, 120, 130 );
2829
2830       NOTE: It isn't sufficient to just specify the filter condition. You
2831       must also hide any rows that don't match the filter condition. Rows are
2832       hidden using the "set_row()" "visible" parameter. "Excel::Writer::XLSX"
2833       cannot do this automatically since it isn't part of the file format.
2834       See the "autofilter.pl" program in the examples directory of the distro
2835       for an example.
2836
2837   convert_date_time( $date_string )
2838       The "convert_date_time()" method is used internally by the
2839       "write_date_time()" method to convert date strings to a number that
2840       represents an Excel date and time.
2841
2842       It is exposed as a public method for utility purposes.
2843
2844       The $date_string format is detailed in the "write_date_time()" method.
2845
2846   Worksheet set_vba_name()
2847       The Worksheet "set_vba_name()" method can be used to set the VBA
2848       codename for the worksheet (there is a similar method for the workbook
2849       VBA name). This is sometimes required when a "vbaProject" macro
2850       included via "add_vba_project()" refers to the worksheet. The default
2851       Excel VBA name of "Sheet1", etc., is used if a user defined name isn't
2852       specified.
2853
2854       See also "WORKING WITH VBA MACROS".
2855

PAGE SET-UP METHODS

2857       Page set-up methods affect the way that a worksheet looks when it is
2858       printed. They control features such as page headers and footers and
2859       margins. These methods are really just standard worksheet methods. They
2860       are documented here in a separate section for the sake of clarity.
2861
2862       The following methods are available for page set-up:
2863
2864           set_landscape()
2865           set_portrait()
2866           set_page_view()
2867           set_paper()
2868           center_horizontally()
2869           center_vertically()
2870           set_margins()
2871           set_header()
2872           set_footer()
2873           repeat_rows()
2874           repeat_columns()
2875           hide_gridlines()
2876           print_row_col_headers()
2877           print_area()
2878           print_across()
2879           fit_to_pages()
2880           set_start_page()
2881           set_print_scale()
2882           print_black_and_white()
2883           set_h_pagebreaks()
2884           set_v_pagebreaks()
2885
2886       A common requirement when working with Excel::Writer::XLSX is to apply
2887       the same page set-up features to all of the worksheets in a workbook.
2888       To do this you can use the "sheets()" method of the "workbook" class to
2889       access the array of worksheets in a workbook:
2890
2891           for $worksheet ( $workbook->sheets() ) {
2892               $worksheet->set_landscape();
2893           }
2894
2895   set_landscape()
2896       This method is used to set the orientation of a worksheet's printed
2897       page to landscape:
2898
2899           $worksheet->set_landscape();    # Landscape mode
2900
2901   set_portrait()
2902       This method is used to set the orientation of a worksheet's printed
2903       page to portrait. The default worksheet orientation is portrait, so you
2904       won't generally need to call this method.
2905
2906           $worksheet->set_portrait();    # Portrait mode
2907
2908   set_page_view()
2909       This method is used to display the worksheet in "Page View/Layout"
2910       mode.
2911
2912           $worksheet->set_page_view();
2913
2914   set_paper( $index )
2915       This method is used to set the paper format for the printed output of a
2916       worksheet. The following paper styles are available:
2917
2918           Index   Paper format            Paper size
2919           =====   ============            ==========
2920             0     Printer default         -
2921             1     Letter                  8 1/2 x 11 in
2922             2     Letter Small            8 1/2 x 11 in
2923             3     Tabloid                 11 x 17 in
2924             4     Ledger                  17 x 11 in
2925             5     Legal                   8 1/2 x 14 in
2926             6     Statement               5 1/2 x 8 1/2 in
2927             7     Executive               7 1/4 x 10 1/2 in
2928             8     A3                      297 x 420 mm
2929             9     A4                      210 x 297 mm
2930            10     A4 Small                210 x 297 mm
2931            11     A5                      148 x 210 mm
2932            12     B4                      250 x 354 mm
2933            13     B5                      182 x 257 mm
2934            14     Folio                   8 1/2 x 13 in
2935            15     Quarto                  215 x 275 mm
2936            16     -                       10x14 in
2937            17     -                       11x17 in
2938            18     Note                    8 1/2 x 11 in
2939            19     Envelope  9             3 7/8 x 8 7/8
2940            20     Envelope 10             4 1/8 x 9 1/2
2941            21     Envelope 11             4 1/2 x 10 3/8
2942            22     Envelope 12             4 3/4 x 11
2943            23     Envelope 14             5 x 11 1/2
2944            24     C size sheet            -
2945            25     D size sheet            -
2946            26     E size sheet            -
2947            27     Envelope DL             110 x 220 mm
2948            28     Envelope C3             324 x 458 mm
2949            29     Envelope C4             229 x 324 mm
2950            30     Envelope C5             162 x 229 mm
2951            31     Envelope C6             114 x 162 mm
2952            32     Envelope C65            114 x 229 mm
2953            33     Envelope B4             250 x 353 mm
2954            34     Envelope B5             176 x 250 mm
2955            35     Envelope B6             176 x 125 mm
2956            36     Envelope                110 x 230 mm
2957            37     Monarch                 3.875 x 7.5 in
2958            38     Envelope                3 5/8 x 6 1/2 in
2959            39     Fanfold                 14 7/8 x 11 in
2960            40     German Std Fanfold      8 1/2 x 12 in
2961            41     German Legal Fanfold    8 1/2 x 13 in
2962
2963       Note, it is likely that not all of these paper types will be available
2964       to the end user since it will depend on the paper formats that the
2965       user's printer supports. Therefore, it is best to stick to standard
2966       paper types.
2967
2968           $worksheet->set_paper( 1 );    # US Letter
2969           $worksheet->set_paper( 9 );    # A4
2970
2971       If you do not specify a paper type the worksheet will print using the
2972       printer's default paper.
2973
2974   center_horizontally()
2975       Center the worksheet data horizontally between the margins on the
2976       printed page:
2977
2978           $worksheet->center_horizontally();
2979
2980   center_vertically()
2981       Center the worksheet data vertically between the margins on the printed
2982       page:
2983
2984           $worksheet->center_vertically();
2985
2986   set_margins( $inches )
2987       There are several methods available for setting the worksheet margins
2988       on the printed page:
2989
2990           set_margins()        # Set all margins to the same value
2991           set_margins_LR()     # Set left and right margins to the same value
2992           set_margins_TB()     # Set top and bottom margins to the same value
2993           set_margin_left();   # Set left margin
2994           set_margin_right();  # Set right margin
2995           set_margin_top();    # Set top margin
2996           set_margin_bottom(); # Set bottom margin
2997
2998       All of these methods take a distance in inches as a parameter. Note: 1
2999       inch = 25.4mm. ";-)" The default left and right margin is 0.7 inch. The
3000       default top and bottom margin is 0.75 inch. Note, these defaults are
3001       different from the defaults used in the binary file format by
3002       Spreadsheet::WriteExcel.
3003
3004   set_header( $string, $margin )
3005       Headers and footers are generated using a $string which is a
3006       combination of plain text and control characters. The $margin parameter
3007       is optional.
3008
3009       The available control character are:
3010
3011           Control             Category            Description
3012           =======             ========            ===========
3013           &L                  Justification       Left
3014           &C                                      Center
3015           &R                                      Right
3016
3017           &P                  Information         Page number
3018           &N                                      Total number of pages
3019           &D                                      Date
3020           &T                                      Time
3021           &F                                      File name
3022           &A                                      Worksheet name
3023           &Z                                      Workbook path
3024
3025           &fontsize           Font                Font size
3026           &"font,style"                           Font name and style
3027           &U                                      Single underline
3028           &E                                      Double underline
3029           &S                                      Strikethrough
3030           &X                                      Superscript
3031           &Y                                      Subscript
3032
3033           &[Picture]          Images              Image placeholder
3034           &G                                      Same as &[Picture]
3035
3036           &&                  Miscellaneous       Literal ampersand &
3037
3038       Text in headers and footers can be justified (aligned) to the left,
3039       center and right by prefixing the text with the control characters &L,
3040       &C and &R.
3041
3042       For example (with ASCII art representation of the results):
3043
3044           $worksheet->set_header('&LHello');
3045
3046            ---------------------------------------------------------------
3047           |                                                               |
3048           | Hello                                                         |
3049           |                                                               |
3050
3051
3052           $worksheet->set_header('&CHello');
3053
3054            ---------------------------------------------------------------
3055           |                                                               |
3056           |                          Hello                                |
3057           |                                                               |
3058
3059
3060           $worksheet->set_header('&RHello');
3061
3062            ---------------------------------------------------------------
3063           |                                                               |
3064           |                                                         Hello |
3065           |                                                               |
3066
3067       For simple text, if you do not specify any justification the text will
3068       be centred. However, you must prefix the text with &C if you specify a
3069       font name or any other formatting:
3070
3071           $worksheet->set_header('Hello');
3072
3073            ---------------------------------------------------------------
3074           |                                                               |
3075           |                          Hello                                |
3076           |                                                               |
3077
3078       You can have text in each of the justification regions:
3079
3080           $worksheet->set_header('&LCiao&CBello&RCielo');
3081
3082            ---------------------------------------------------------------
3083           |                                                               |
3084           | Ciao                     Bello                          Cielo |
3085           |                                                               |
3086
3087       The information control characters act as variables that Excel will
3088       update as the workbook or worksheet changes. Times and dates are in the
3089       users default format:
3090
3091           $worksheet->set_header('&CPage &P of &N');
3092
3093            ---------------------------------------------------------------
3094           |                                                               |
3095           |                        Page 1 of 6                            |
3096           |                                                               |
3097
3098
3099           $worksheet->set_header('&CUpdated at &T');
3100
3101            ---------------------------------------------------------------
3102           |                                                               |
3103           |                    Updated at 12:30 PM                        |
3104           |                                                               |
3105
3106       Images can be inserted using the options shown below. Each image must
3107       have a placeholder in header string using the "&[Picture]" or &G
3108       control characters:
3109
3110           $worksheet->set_header( '&L&G', 0.3, { image_left => 'logo.jpg' });
3111
3112       You can specify the font size of a section of the text by prefixing it
3113       with the control character &n where "n" is the font size:
3114
3115           $worksheet1->set_header( '&C&30Hello Big' );
3116           $worksheet2->set_header( '&C&10Hello Small' );
3117
3118       You can specify the font of a section of the text by prefixing it with
3119       the control sequence "&"font,style"" where "fontname" is a font name
3120       such as "Courier New" or "Times New Roman" and "style" is one of the
3121       standard Windows font descriptions: "Regular", "Italic", "Bold" or
3122       "Bold Italic":
3123
3124           $worksheet1->set_header( '&C&"Courier New,Italic"Hello' );
3125           $worksheet2->set_header( '&C&"Courier New,Bold Italic"Hello' );
3126           $worksheet3->set_header( '&C&"Times New Roman,Regular"Hello' );
3127
3128       It is possible to combine all of these features together to create
3129       sophisticated headers and footers. As an aid to setting up complicated
3130       headers and footers you can record a page set-up as a macro in Excel
3131       and look at the format strings that VBA produces. Remember however that
3132       VBA uses two double quotes "" to indicate a single double quote. For
3133       the last example above the equivalent VBA code looks like this:
3134
3135           .LeftHeader   = ""
3136           .CenterHeader = "&""Times New Roman,Regular""Hello"
3137           .RightHeader  = ""
3138
3139       To include a single literal ampersand "&" in a header or footer you
3140       should use a double ampersand "&&":
3141
3142           $worksheet1->set_header('&CCuriouser && Curiouser - Attorneys at Law');
3143
3144       As stated above the margin parameter is optional. As with the other
3145       margins the value should be in inches. The default header and footer
3146       margin is 0.3 inch. Note, the default margin is different from the
3147       default used in the binary file format by Spreadsheet::WriteExcel. The
3148       header and footer margin size can be set as follows:
3149
3150           $worksheet->set_header( '&CHello', 0.75 );
3151
3152       The header and footer margins are independent of the top and bottom
3153       margins.
3154
3155       The available options are:
3156
3157       ·   "image_left" The path to the image. Requires a &G or "&[Picture]"
3158           placeholder.
3159
3160       ·   "image_center" Same as above.
3161
3162       ·   "image_right" Same as above.
3163
3164       ·   "scale_with_doc" Scale header with document. Defaults to true.
3165
3166       ·   "align_with_margins" Align header to margins. Defaults to true.
3167
3168       The image options must have an accompanying "&[Picture]" or &G control
3169       character in the header string:
3170
3171           $worksheet->set_header(
3172               '&L&[Picture]&C&[Picture]&R&[Picture]',
3173               undef, # If you don't want to change the margin.
3174               {
3175                   image_left   => 'red.jpg',
3176                   image_center => 'blue.jpg',
3177                   image_right  => 'yellow.jpg'
3178               }
3179             );
3180
3181       Note, the header or footer string must be less than 255 characters.
3182       Strings longer than this will not be written and a warning will be
3183       generated.
3184
3185       The "set_header()" method can also handle Unicode strings in "UTF-8"
3186       format.
3187
3188           $worksheet->set_header( "&C\x{263a}" )
3189
3190       See, also the "headers.pl" program in the "examples" directory of the
3191       distribution.
3192
3193   set_footer( $string, $margin )
3194       The syntax of the "set_footer()" method is the same as "set_header()",
3195       see above.
3196
3197   repeat_rows( $first_row, $last_row )
3198       Set the number of rows to repeat at the top of each printed page.
3199
3200       For large Excel documents it is often desirable to have the first row
3201       or rows of the worksheet print out at the top of each page. This can be
3202       achieved by using the "repeat_rows()" method. The parameters $first_row
3203       and $last_row are zero based. The $last_row parameter is optional if
3204       you only wish to specify one row:
3205
3206           $worksheet1->repeat_rows( 0 );    # Repeat the first row
3207           $worksheet2->repeat_rows( 0, 1 ); # Repeat the first two rows
3208
3209   repeat_columns( $first_col, $last_col )
3210       Set the columns to repeat at the left hand side of each printed page.
3211
3212       For large Excel documents it is often desirable to have the first
3213       column or columns of the worksheet print out at the left hand side of
3214       each page. This can be achieved by using the "repeat_columns()" method.
3215       The parameters $first_column and $last_column are zero based. The
3216       $last_column parameter is optional if you only wish to specify one
3217       column. You can also specify the columns using A1 column notation, see
3218       the note about "Cell notation".
3219
3220           $worksheet1->repeat_columns( 0 );        # Repeat the first column
3221           $worksheet2->repeat_columns( 0, 1 );     # Repeat the first two columns
3222           $worksheet3->repeat_columns( 'A:A' );    # Repeat the first column
3223           $worksheet4->repeat_columns( 'A:B' );    # Repeat the first two columns
3224
3225   hide_gridlines( $option )
3226       This method is used to hide the gridlines on the screen and printed
3227       page. Gridlines are the lines that divide the cells on a worksheet.
3228       Screen and printed gridlines are turned on by default in an Excel
3229       worksheet. If you have defined your own cell borders you may wish to
3230       hide the default gridlines.
3231
3232           $worksheet->hide_gridlines();
3233
3234       The following values of $option are valid:
3235
3236           0 : Don't hide gridlines
3237           1 : Hide printed gridlines only
3238           2 : Hide screen and printed gridlines
3239
3240       If you don't supply an argument or use "undef" the default option is 1,
3241       i.e. only the printed gridlines are hidden.
3242
3243   print_row_col_headers()
3244       Set the option to print the row and column headers on the printed page.
3245
3246       An Excel worksheet looks something like the following;
3247
3248            ------------------------------------------
3249           |   |   A   |   B   |   C   |   D   |  ...
3250            ------------------------------------------
3251           | 1 |       |       |       |       |  ...
3252           | 2 |       |       |       |       |  ...
3253           | 3 |       |       |       |       |  ...
3254           | 4 |       |       |       |       |  ...
3255           |...|  ...  |  ...  |  ...  |  ...  |  ...
3256
3257       The headers are the letters and numbers at the top and the left of the
3258       worksheet. Since these headers serve mainly as a indication of position
3259       on the worksheet they generally do not appear on the printed page. If
3260       you wish to have them printed you can use the "print_row_col_headers()"
3261       method:
3262
3263           $worksheet->print_row_col_headers();
3264
3265       Do not confuse these headers with page headers as described in the
3266       "set_header()" section above.
3267
3268   hide_row_col_headers()
3269       Similar to "print_row_col_headers()" above but set the option to hide
3270       the row and column headers within Excel so that they aren't visible to
3271       the user:
3272
3273           $worksheet->hide_row_col_headers();
3274
3275   print_area( $first_row, $first_col, $last_row, $last_col )
3276       This method is used to specify the area of the worksheet that will be
3277       printed. All four parameters must be specified. You can also use A1
3278       notation, see the note about "Cell notation".
3279
3280           $worksheet1->print_area( 'A1:H20' );    # Cells A1 to H20
3281           $worksheet2->print_area( 0, 0, 19, 7 ); # The same
3282           $worksheet2->print_area( 'A:H' );       # Columns A to H if rows have data
3283
3284   print_across()
3285       The "print_across" method is used to change the default print
3286       direction. This is referred to by Excel as the sheet "page order".
3287
3288           $worksheet->print_across();
3289
3290       The default page order is shown below for a worksheet that extends over
3291       4 pages. The order is called "down then across":
3292
3293           [1] [3]
3294           [2] [4]
3295
3296       However, by using the "print_across" method the print order will be
3297       changed to "across then down":
3298
3299           [1] [2]
3300           [3] [4]
3301
3302   fit_to_pages( $width, $height )
3303       The "fit_to_pages()" method is used to fit the printed area to a
3304       specific number of pages both vertically and horizontally. If the
3305       printed area exceeds the specified number of pages it will be scaled
3306       down to fit. This guarantees that the printed area will always appear
3307       on the specified number of pages even if the page size or margins
3308       change.
3309
3310           $worksheet1->fit_to_pages( 1, 1 );    # Fit to 1x1 pages
3311           $worksheet2->fit_to_pages( 2, 1 );    # Fit to 2x1 pages
3312           $worksheet3->fit_to_pages( 1, 2 );    # Fit to 1x2 pages
3313
3314       The print area can be defined using the "print_area()" method as
3315       described above.
3316
3317       A common requirement is to fit the printed output to n pages wide but
3318       have the height be as long as necessary. To achieve this set the
3319       $height to zero:
3320
3321           $worksheet1->fit_to_pages( 1, 0 );    # 1 page wide and as long as necessary
3322
3323       Note that although it is valid to use both "fit_to_pages()" and
3324       "set_print_scale()" on the same worksheet only one of these options can
3325       be active at a time. The last method call made will set the active
3326       option.
3327
3328       Note that "fit_to_pages()" will override any manual page breaks that
3329       are defined in the worksheet.
3330
3331       Note: When using "fit_to_pages()" it may also be required to set the
3332       printer paper size using "set_paper()" or else Excel will default to
3333       "US Letter".
3334
3335   set_start_page( $start_page )
3336       The "set_start_page()" method is used to set the number of the starting
3337       page when the worksheet is printed out. The default value is 1.
3338
3339           $worksheet->set_start_page( 2 );
3340
3341   set_print_scale( $scale )
3342       Set the scale factor of the printed page. Scale factors in the range
3343       "10 <= $scale <= 400" are valid:
3344
3345           $worksheet1->set_print_scale( 50 );
3346           $worksheet2->set_print_scale( 75 );
3347           $worksheet3->set_print_scale( 300 );
3348           $worksheet4->set_print_scale( 400 );
3349
3350       The default scale factor is 100. Note, "set_print_scale()" does not
3351       affect the scale of the visible page in Excel. For that you should use
3352       "set_zoom()".
3353
3354       Note also that although it is valid to use both "fit_to_pages()" and
3355       "set_print_scale()" on the same worksheet only one of these options can
3356       be active at a time. The last method call made will set the active
3357       option.
3358
3359   print_black_and_white()
3360       Set the option to print the worksheet in black and white:
3361
3362           $worksheet->print_black_and_white();
3363
3364   set_h_pagebreaks( @breaks )
3365       Add horizontal page breaks to a worksheet. A page break causes all the
3366       data that follows it to be printed on the next page. Horizontal page
3367       breaks act between rows. To create a page break between rows 20 and 21
3368       you must specify the break at row 21. However in zero index notation
3369       this is actually row 20. So you can pretend for a small while that you
3370       are using 1 index notation:
3371
3372           $worksheet1->set_h_pagebreaks( 20 );    # Break between row 20 and 21
3373
3374       The "set_h_pagebreaks()" method will accept a list of page breaks and
3375       you can call it more than once:
3376
3377           $worksheet2->set_h_pagebreaks( 20,  40,  60,  80,  100 );    # Add breaks
3378           $worksheet2->set_h_pagebreaks( 120, 140, 160, 180, 200 );    # Add some more
3379
3380       Note: If you specify the "fit to page" option via the "fit_to_pages()"
3381       method it will override all manual page breaks.
3382
3383       There is a silent limitation of about 1000 horizontal page breaks per
3384       worksheet in line with an Excel internal limitation.
3385
3386   set_v_pagebreaks( @breaks )
3387       Add vertical page breaks to a worksheet. A page break causes all the
3388       data that follows it to be printed on the next page. Vertical page
3389       breaks act between columns. To create a page break between columns 20
3390       and 21 you must specify the break at column 21. However in zero index
3391       notation this is actually column 20. So you can pretend for a small
3392       while that you are using 1 index notation:
3393
3394           $worksheet1->set_v_pagebreaks(20); # Break between column 20 and 21
3395
3396       The "set_v_pagebreaks()" method will accept a list of page breaks and
3397       you can call it more than once:
3398
3399           $worksheet2->set_v_pagebreaks( 20,  40,  60,  80,  100 );    # Add breaks
3400           $worksheet2->set_v_pagebreaks( 120, 140, 160, 180, 200 );    # Add some more
3401
3402       Note: If you specify the "fit to page" option via the "fit_to_pages()"
3403       method it will override all manual page breaks.
3404

CELL FORMATTING

3406       This section describes the methods and properties that are available
3407       for formatting cells in Excel. The properties of a cell that can be
3408       formatted include: fonts, colours, patterns, borders, alignment and
3409       number formatting.
3410
3411   Creating and using a Format object
3412       Cell formatting is defined through a Format object. Format objects are
3413       created by calling the workbook "add_format()" method as follows:
3414
3415           my $format1 = $workbook->add_format();            # Set properties later
3416           my $format2 = $workbook->add_format( %props );    # Set at creation
3417
3418       The format object holds all the formatting properties that can be
3419       applied to a cell, a row or a column. The process of setting these
3420       properties is discussed in the next section.
3421
3422       Once a Format object has been constructed and its properties have been
3423       set it can be passed as an argument to the worksheet "write" methods as
3424       follows:
3425
3426           $worksheet->write( 0, 0, 'One', $format );
3427           $worksheet->write_string( 1, 0, 'Two', $format );
3428           $worksheet->write_number( 2, 0, 3, $format );
3429           $worksheet->write_blank( 3, 0, $format );
3430
3431       Formats can also be passed to the worksheet "set_row()" and
3432       "set_column()" methods to define the default property for a row or
3433       column.
3434
3435           $worksheet->set_row( 0, 15, $format );
3436           $worksheet->set_column( 0, 0, 15, $format );
3437
3438   Format methods and Format properties
3439       The following table shows the Excel format categories, the formatting
3440       properties that can be applied and the equivalent object method:
3441
3442           Category   Description       Property        Method Name
3443           --------   -----------       --------        -----------
3444           Font       Font type         font            set_font()
3445                      Font size         size            set_size()
3446                      Font color        color           set_color()
3447                      Bold              bold            set_bold()
3448                      Italic            italic          set_italic()
3449                      Underline         underline       set_underline()
3450                      Strikeout         font_strikeout  set_font_strikeout()
3451                      Super/Subscript   font_script     set_font_script()
3452                      Outline           font_outline    set_font_outline()
3453                      Shadow            font_shadow     set_font_shadow()
3454
3455           Number     Numeric format    num_format      set_num_format()
3456
3457           Protection Lock cells        locked          set_locked()
3458                      Hide formulas     hidden          set_hidden()
3459
3460           Alignment  Horizontal align  align           set_align()
3461                      Vertical align    valign          set_align()
3462                      Rotation          rotation        set_rotation()
3463                      Text wrap         text_wrap       set_text_wrap()
3464                      Justify last      text_justlast   set_text_justlast()
3465                      Center across     center_across   set_center_across()
3466                      Indentation       indent          set_indent()
3467                      Shrink to fit     shrink          set_shrink()
3468
3469           Pattern    Cell pattern      pattern         set_pattern()
3470                      Background color  bg_color        set_bg_color()
3471                      Foreground color  fg_color        set_fg_color()
3472
3473           Border     Cell border       border          set_border()
3474                      Bottom border     bottom          set_bottom()
3475                      Top border        top             set_top()
3476                      Left border       left            set_left()
3477                      Right border      right           set_right()
3478                      Border color      border_color    set_border_color()
3479                      Bottom color      bottom_color    set_bottom_color()
3480                      Top color         top_color       set_top_color()
3481                      Left color        left_color      set_left_color()
3482                      Right color       right_color     set_right_color()
3483                      Diagonal type     diag_type       set_diag_type()
3484                      Diagonal border   diag_border     set_diag_border()
3485                      Diagonal color    diag_color      set_diag_color()
3486
3487       There are two ways of setting Format properties: by using the object
3488       method interface or by setting the property directly. For example, a
3489       typical use of the method interface would be as follows:
3490
3491           my $format = $workbook->add_format();
3492           $format->set_bold();
3493           $format->set_color( 'red' );
3494
3495       By comparison the properties can be set directly by passing a hash of
3496       properties to the Format constructor:
3497
3498           my $format = $workbook->add_format( bold => 1, color => 'red' );
3499
3500       or after the Format has been constructed by means of the
3501       "set_format_properties()" method as follows:
3502
3503           my $format = $workbook->add_format();
3504           $format->set_format_properties( bold => 1, color => 'red' );
3505
3506       You can also store the properties in one or more named hashes and pass
3507       them to the required method:
3508
3509           my %font = (
3510               font  => 'Calibri',
3511               size  => 12,
3512               color => 'blue',
3513               bold  => 1,
3514           );
3515
3516           my %shading = (
3517               bg_color => 'green',
3518               pattern  => 1,
3519           );
3520
3521
3522           my $format1 = $workbook->add_format( %font );            # Font only
3523           my $format2 = $workbook->add_format( %font, %shading );  # Font and shading
3524
3525       The provision of two ways of setting properties might lead you to
3526       wonder which is the best way. The method mechanism may be better if you
3527       prefer setting properties via method calls (which the author did when
3528       the code was first written) otherwise passing properties to the
3529       constructor has proved to be a little more flexible and self
3530       documenting in practice. An additional advantage of working with
3531       property hashes is that it allows you to share formatting between
3532       workbook objects as shown in the example above.
3533
3534       The Perl/Tk style of adding properties is also supported:
3535
3536           my %font = (
3537               -font  => 'Calibri',
3538               -size  => 12,
3539               -color => 'blue',
3540               -bold  => 1,
3541           );
3542
3543   Working with formats
3544       The default format is Calibri 11 with all other properties off.
3545
3546       Each unique format in Excel::Writer::XLSX must have a corresponding
3547       Format object. It isn't possible to use a Format with a write() method
3548       and then redefine the Format for use at a later stage. This is because
3549       a Format is applied to a cell not in its current state but in its final
3550       state. Consider the following example:
3551
3552           my $format = $workbook->add_format();
3553           $format->set_bold();
3554           $format->set_color( 'red' );
3555           $worksheet->write( 'A1', 'Cell A1', $format );
3556           $format->set_color( 'green' );
3557           $worksheet->write( 'B1', 'Cell B1', $format );
3558
3559       Cell A1 is assigned the Format $format which is initially set to the
3560       colour red. However, the colour is subsequently set to green. When
3561       Excel displays Cell A1 it will display the final state of the Format
3562       which in this case will be the colour green.
3563
3564       In general a method call without an argument will turn a property on,
3565       for example:
3566
3567           my $format1 = $workbook->add_format();
3568           $format1->set_bold();       # Turns bold on
3569           $format1->set_bold( 1 );    # Also turns bold on
3570           $format1->set_bold( 0 );    # Turns bold off
3571

FORMAT METHODS

3573       The Format object methods are described in more detail in the following
3574       sections. In addition, there is a Perl program called "formats.pl" in
3575       the "examples" directory of the WriteExcel distribution. This program
3576       creates an Excel workbook called "formats.xlsx" which contains examples
3577       of almost all the format types.
3578
3579       The following Format methods are available:
3580
3581           set_font()
3582           set_size()
3583           set_color()
3584           set_bold()
3585           set_italic()
3586           set_underline()
3587           set_font_strikeout()
3588           set_font_script()
3589           set_font_outline()
3590           set_font_shadow()
3591           set_num_format()
3592           set_locked()
3593           set_hidden()
3594           set_align()
3595           set_rotation()
3596           set_text_wrap()
3597           set_text_justlast()
3598           set_center_across()
3599           set_indent()
3600           set_shrink()
3601           set_pattern()
3602           set_bg_color()
3603           set_fg_color()
3604           set_border()
3605           set_bottom()
3606           set_top()
3607           set_left()
3608           set_right()
3609           set_border_color()
3610           set_bottom_color()
3611           set_top_color()
3612           set_left_color()
3613           set_right_color()
3614           set_diag_type()
3615           set_diag_border()
3616           set_diag_color()
3617
3618       The above methods can also be applied directly as properties. For
3619       example "$format->set_bold()" is equivalent to
3620       "$workbook->add_format(bold => 1)".
3621
3622   set_format_properties( %properties )
3623       The properties of an existing Format object can be also be set by means
3624       of "set_format_properties()":
3625
3626           my $format = $workbook->add_format();
3627           $format->set_format_properties( bold => 1, color => 'red' );
3628
3629       However, this method is here mainly for legacy reasons. It is
3630       preferable to set the properties in the format constructor:
3631
3632           my $format = $workbook->add_format( bold => 1, color => 'red' );
3633
3634   set_font( $fontname )
3635           Default state:      Font is Calibri
3636           Default action:     None
3637           Valid args:         Any valid font name
3638
3639       Specify the font used:
3640
3641           $format->set_font('Times New Roman');
3642
3643       Excel can only display fonts that are installed on the system that it
3644       is running on. Therefore it is best to use the fonts that come as
3645       standard such as 'Calibri', 'Times New Roman' and 'Courier New'. See
3646       also the Fonts worksheet created by formats.pl
3647
3648   set_size()
3649           Default state:      Font size is 10
3650           Default action:     Set font size to 1
3651           Valid args:         Integer values from 1 to as big as your screen.
3652
3653       Set the font size. Excel adjusts the height of a row to accommodate the
3654       largest font size in the row. You can also explicitly specify the
3655       height of a row using the set_row() worksheet method.
3656
3657           my $format = $workbook->add_format();
3658           $format->set_size( 30 );
3659
3660   set_color()
3661           Default state:      Excels default color, usually black
3662           Default action:     Set the default color
3663           Valid args:         Integers from 8..63 or the following strings:
3664                               'black'
3665                               'blue'
3666                               'brown'
3667                               'cyan'
3668                               'gray'
3669                               'green'
3670                               'lime'
3671                               'magenta'
3672                               'navy'
3673                               'orange'
3674                               'pink'
3675                               'purple'
3676                               'red'
3677                               'silver'
3678                               'white'
3679                               'yellow'
3680
3681       Set the font colour. The "set_color()" method is used as follows:
3682
3683           my $format = $workbook->add_format();
3684           $format->set_color( 'red' );
3685           $worksheet->write( 0, 0, 'wheelbarrow', $format );
3686
3687       Note: The "set_color()" method is used to set the colour of the font in
3688       a cell. To set the colour of a cell use the "set_bg_color()" and
3689       "set_pattern()" methods.
3690
3691       For additional examples see the 'Named colors' and 'Standard colors'
3692       worksheets created by formats.pl in the examples directory.
3693
3694       See also "WORKING WITH COLOURS".
3695
3696   set_bold()
3697           Default state:      bold is off
3698           Default action:     Turn bold on
3699           Valid args:         0, 1
3700
3701       Set the bold property of the font:
3702
3703           $format->set_bold();  # Turn bold on
3704
3705   set_italic()
3706           Default state:      Italic is off
3707           Default action:     Turn italic on
3708           Valid args:         0, 1
3709
3710       Set the italic property of the font:
3711
3712           $format->set_italic();  # Turn italic on
3713
3714   set_underline()
3715           Default state:      Underline is off
3716           Default action:     Turn on single underline
3717           Valid args:         0  = No underline
3718                               1  = Single underline
3719                               2  = Double underline
3720                               33 = Single accounting underline
3721                               34 = Double accounting underline
3722
3723       Set the underline property of the font.
3724
3725           $format->set_underline();   # Single underline
3726
3727   set_font_strikeout()
3728           Default state:      Strikeout is off
3729           Default action:     Turn strikeout on
3730           Valid args:         0, 1
3731
3732       Set the strikeout property of the font.
3733
3734   set_font_script()
3735           Default state:      Super/Subscript is off
3736           Default action:     Turn Superscript on
3737           Valid args:         0  = Normal
3738                               1  = Superscript
3739                               2  = Subscript
3740
3741       Set the superscript/subscript property of the font.
3742
3743   set_font_outline()
3744           Default state:      Outline is off
3745           Default action:     Turn outline on
3746           Valid args:         0, 1
3747
3748       Macintosh only.
3749
3750   set_font_shadow()
3751           Default state:      Shadow is off
3752           Default action:     Turn shadow on
3753           Valid args:         0, 1
3754
3755       Macintosh only.
3756
3757   set_num_format()
3758           Default state:      General format
3759           Default action:     Format index 1
3760           Valid args:         See the following table
3761
3762       This method is used to define the numerical format of a number in
3763       Excel. It controls whether a number is displayed as an integer, a
3764       floating point number, a date, a currency value or some other user
3765       defined format.
3766
3767       The numerical format of a cell can be specified by using a format
3768       string or an index to one of Excel's built-in formats:
3769
3770           my $format1 = $workbook->add_format();
3771           my $format2 = $workbook->add_format();
3772           $format1->set_num_format( 'd mmm yyyy' );    # Format string
3773           $format2->set_num_format( 0x0f );            # Format index
3774
3775           $worksheet->write( 0, 0, 36892.521, $format1 );    # 1 Jan 2001
3776           $worksheet->write( 0, 0, 36892.521, $format2 );    # 1-Jan-01
3777
3778       Using format strings you can define very sophisticated formatting of
3779       numbers.
3780
3781           $format01->set_num_format( '0.000' );
3782           $worksheet->write( 0, 0, 3.1415926, $format01 );    # 3.142
3783
3784           $format02->set_num_format( '#,##0' );
3785           $worksheet->write( 1, 0, 1234.56, $format02 );      # 1,235
3786
3787           $format03->set_num_format( '#,##0.00' );
3788           $worksheet->write( 2, 0, 1234.56, $format03 );      # 1,234.56
3789
3790           $format04->set_num_format( '$0.00' );
3791           $worksheet->write( 3, 0, 49.99, $format04 );        # $49.99
3792
3793           # Note you can use other currency symbols such as the pound or yen as well.
3794           # Other currencies may require the use of Unicode.
3795
3796           $format07->set_num_format( 'mm/dd/yy' );
3797           $worksheet->write( 6, 0, 36892.521, $format07 );    # 01/01/01
3798
3799           $format08->set_num_format( 'mmm d yyyy' );
3800           $worksheet->write( 7, 0, 36892.521, $format08 );    # Jan 1 2001
3801
3802           $format09->set_num_format( 'd mmmm yyyy' );
3803           $worksheet->write( 8, 0, 36892.521, $format09 );    # 1 January 2001
3804
3805           $format10->set_num_format( 'dd/mm/yyyy hh:mm AM/PM' );
3806           $worksheet->write( 9, 0, 36892.521, $format10 );    # 01/01/2001 12:30 AM
3807
3808           $format11->set_num_format( '0 "dollar and" .00 "cents"' );
3809           $worksheet->write( 10, 0, 1.87, $format11 );        # 1 dollar and .87 cents
3810
3811           # Conditional numerical formatting.
3812           $format12->set_num_format( '[Green]General;[Red]-General;General' );
3813           $worksheet->write( 11, 0, 123, $format12 );         # > 0 Green
3814           $worksheet->write( 12, 0, -45, $format12 );         # < 0 Red
3815           $worksheet->write( 13, 0, 0,   $format12 );         # = 0 Default colour
3816
3817           # Zip code
3818           $format13->set_num_format( '00000' );
3819           $worksheet->write( 14, 0, '01209', $format13 );
3820
3821       The number system used for dates is described in "DATES AND TIME IN
3822       EXCEL".
3823
3824       The colour format should have one of the following values:
3825
3826           [Black] [Blue] [Cyan] [Green] [Magenta] [Red] [White] [Yellow]
3827
3828       Alternatively you can specify the colour based on a colour index as
3829       follows: "[Color n]", where n is a standard Excel colour index - 7. See
3830       the 'Standard colors' worksheet created by formats.pl.
3831
3832       For more information refer to the documentation on formatting in the
3833       "docs" directory of the Excel::Writer::XLSX distro, the Excel on-line
3834       help or
3835       <http://office.microsoft.com/en-gb/assistance/HP051995001033.aspx>.
3836
3837       You should ensure that the format string is valid in Excel prior to
3838       using it in WriteExcel.
3839
3840       Excel's built-in formats are shown in the following table:
3841
3842           Index   Index   Format String
3843           0       0x00    General
3844           1       0x01    0
3845           2       0x02    0.00
3846           3       0x03    #,##0
3847           4       0x04    #,##0.00
3848           5       0x05    ($#,##0_);($#,##0)
3849           6       0x06    ($#,##0_);[Red]($#,##0)
3850           7       0x07    ($#,##0.00_);($#,##0.00)
3851           8       0x08    ($#,##0.00_);[Red]($#,##0.00)
3852           9       0x09    0%
3853           10      0x0a    0.00%
3854           11      0x0b    0.00E+00
3855           12      0x0c    # ?/?
3856           13      0x0d    # ??/??
3857           14      0x0e    m/d/yy
3858           15      0x0f    d-mmm-yy
3859           16      0x10    d-mmm
3860           17      0x11    mmm-yy
3861           18      0x12    h:mm AM/PM
3862           19      0x13    h:mm:ss AM/PM
3863           20      0x14    h:mm
3864           21      0x15    h:mm:ss
3865           22      0x16    m/d/yy h:mm
3866           ..      ....    ...........
3867           37      0x25    (#,##0_);(#,##0)
3868           38      0x26    (#,##0_);[Red](#,##0)
3869           39      0x27    (#,##0.00_);(#,##0.00)
3870           40      0x28    (#,##0.00_);[Red](#,##0.00)
3871           41      0x29    _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)
3872           42      0x2a    _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)
3873           43      0x2b    _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
3874           44      0x2c    _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)
3875           45      0x2d    mm:ss
3876           46      0x2e    [h]:mm:ss
3877           47      0x2f    mm:ss.0
3878           48      0x30    ##0.0E+0
3879           49      0x31    @
3880
3881       For examples of these formatting codes see the 'Numerical formats'
3882       worksheet created by formats.pl. See also the number_formats1.html and
3883       the number_formats2.html documents in the "docs" directory of the
3884       distro.
3885
3886       Note 1. Numeric formats 23 to 36 are not documented by Microsoft and
3887       may differ in international versions.
3888
3889       Note 2. The dollar sign appears as the defined local currency symbol.
3890
3891   set_locked()
3892           Default state:      Cell locking is on
3893           Default action:     Turn locking on
3894           Valid args:         0, 1
3895
3896       This property can be used to prevent modification of a cells contents.
3897       Following Excel's convention, cell locking is turned on by default.
3898       However, it only has an effect if the worksheet has been protected, see
3899       the worksheet "protect()" method.
3900
3901           my $locked = $workbook->add_format();
3902           $locked->set_locked( 1 );    # A non-op
3903
3904           my $unlocked = $workbook->add_format();
3905           $locked->set_locked( 0 );
3906
3907           # Enable worksheet protection
3908           $worksheet->protect();
3909
3910           # This cell cannot be edited.
3911           $worksheet->write( 'A1', '=1+2', $locked );
3912
3913           # This cell can be edited.
3914           $worksheet->write( 'A2', '=1+2', $unlocked );
3915
3916       Note: This offers weak protection even with a password, see the note in
3917       relation to the "protect()" method.
3918
3919   set_hidden()
3920           Default state:      Formula hiding is off
3921           Default action:     Turn hiding on
3922           Valid args:         0, 1
3923
3924       This property is used to hide a formula while still displaying its
3925       result. This is generally used to hide complex calculations from end
3926       users who are only interested in the result. It only has an effect if
3927       the worksheet has been protected, see the worksheet "protect()" method.
3928
3929           my $hidden = $workbook->add_format();
3930           $hidden->set_hidden();
3931
3932           # Enable worksheet protection
3933           $worksheet->protect();
3934
3935           # The formula in this cell isn't visible
3936           $worksheet->write( 'A1', '=1+2', $hidden );
3937
3938       Note: This offers weak protection even with a password, see the note in
3939       relation to the "protect()" method.
3940
3941   set_align()
3942           Default state:      Alignment is off
3943           Default action:     Left alignment
3944           Valid args:         'left'              Horizontal
3945                               'center'
3946                               'right'
3947                               'fill'
3948                               'justify'
3949                               'center_across'
3950
3951                               'top'               Vertical
3952                               'vcenter'
3953                               'bottom'
3954                               'vjustify'
3955
3956       This method is used to set the horizontal and vertical text alignment
3957       within a cell. Vertical and horizontal alignments can be combined. The
3958       method is used as follows:
3959
3960           my $format = $workbook->add_format();
3961           $format->set_align( 'center' );
3962           $format->set_align( 'vcenter' );
3963           $worksheet->set_row( 0, 30 );
3964           $worksheet->write( 0, 0, 'X', $format );
3965
3966       Text can be aligned across two or more adjacent cells using the
3967       "center_across" property. However, for genuine merged cells it is
3968       better to use the "merge_range()" worksheet method.
3969
3970       The "vjustify" (vertical justify) option can be used to provide
3971       automatic text wrapping in a cell. The height of the cell will be
3972       adjusted to accommodate the wrapped text. To specify where the text
3973       wraps use the "set_text_wrap()" method.
3974
3975       For further examples see the 'Alignment' worksheet created by
3976       formats.pl.
3977
3978   set_center_across()
3979           Default state:      Center across selection is off
3980           Default action:     Turn center across on
3981           Valid args:         1
3982
3983       Text can be aligned across two or more adjacent cells using the
3984       "set_center_across()" method. This is an alias for the
3985       "set_align('center_across')" method call.
3986
3987       Only one cell should contain the text, the other cells should be blank:
3988
3989           my $format = $workbook->add_format();
3990           $format->set_center_across();
3991
3992           $worksheet->write( 1, 1, 'Center across selection', $format );
3993           $worksheet->write_blank( 1, 2, $format );
3994
3995       See also the "merge1.pl" to "merge6.pl" programs in the "examples"
3996       directory and the "merge_range()" method.
3997
3998   set_text_wrap()
3999           Default state:      Text wrap is off
4000           Default action:     Turn text wrap on
4001           Valid args:         0, 1
4002
4003       Here is an example using the text wrap property, the escape character
4004       "\n" is used to indicate the end of line:
4005
4006           my $format = $workbook->add_format();
4007           $format->set_text_wrap();
4008           $worksheet->write( 0, 0, "It's\na bum\nwrap", $format );
4009
4010       Excel will adjust the height of the row to accommodate the wrapped
4011       text. A similar effect can be obtained without newlines using the
4012       "set_align('vjustify')" method. See the "textwrap.pl" program in the
4013       "examples" directory.
4014
4015   set_rotation()
4016           Default state:      Text rotation is off
4017           Default action:     None
4018           Valid args:         Integers in the range -90 to 90 and 270
4019
4020       Set the rotation of the text in a cell. The rotation can be any angle
4021       in the range -90 to 90 degrees.
4022
4023           my $format = $workbook->add_format();
4024           $format->set_rotation( 30 );
4025           $worksheet->write( 0, 0, 'This text is rotated', $format );
4026
4027       The angle 270 is also supported. This indicates text where the letters
4028       run from top to bottom.
4029
4030   set_indent()
4031           Default state:      Text indentation is off
4032           Default action:     Indent text 1 level
4033           Valid args:         Positive integers
4034
4035       This method can be used to indent text. The argument, which should be
4036       an integer, is taken as the level of indentation:
4037
4038           my $format = $workbook->add_format();
4039           $format->set_indent( 2 );
4040           $worksheet->write( 0, 0, 'This text is indented', $format );
4041
4042       Indentation is a horizontal alignment property. It will override any
4043       other horizontal properties but it can be used in conjunction with
4044       vertical properties.
4045
4046   set_shrink()
4047           Default state:      Text shrinking is off
4048           Default action:     Turn "shrink to fit" on
4049           Valid args:         1
4050
4051       This method can be used to shrink text so that it fits in a cell.
4052
4053           my $format = $workbook->add_format();
4054           $format->set_shrink();
4055           $worksheet->write( 0, 0, 'Honey, I shrunk the text!', $format );
4056
4057   set_text_justlast()
4058           Default state:      Justify last is off
4059           Default action:     Turn justify last on
4060           Valid args:         0, 1
4061
4062       Only applies to Far Eastern versions of Excel.
4063
4064   set_pattern()
4065           Default state:      Pattern is off
4066           Default action:     Solid fill is on
4067           Valid args:         0 .. 18
4068
4069       Set the background pattern of a cell.
4070
4071       Examples of the available patterns are shown in the 'Patterns'
4072       worksheet created by formats.pl. However, it is unlikely that you will
4073       ever need anything other than Pattern 1 which is a solid fill of the
4074       background color.
4075
4076   set_bg_color()
4077           Default state:      Color is off
4078           Default action:     Solid fill.
4079           Valid args:         See set_color()
4080
4081       The "set_bg_color()" method can be used to set the background colour of
4082       a pattern. Patterns are defined via the "set_pattern()" method. If a
4083       pattern hasn't been defined then a solid fill pattern is used as the
4084       default.
4085
4086       Here is an example of how to set up a solid fill in a cell:
4087
4088           my $format = $workbook->add_format();
4089
4090           $format->set_pattern();    # This is optional when using a solid fill
4091
4092           $format->set_bg_color( 'green' );
4093           $worksheet->write( 'A1', 'Ray', $format );
4094
4095       For further examples see the 'Patterns' worksheet created by
4096       formats.pl.
4097
4098   set_fg_color()
4099           Default state:      Color is off
4100           Default action:     Solid fill.
4101           Valid args:         See set_color()
4102
4103       The "set_fg_color()" method can be used to set the foreground colour of
4104       a pattern.
4105
4106       For further examples see the 'Patterns' worksheet created by
4107       formats.pl.
4108
4109   set_border()
4110           Also applies to:    set_bottom()
4111                               set_top()
4112                               set_left()
4113                               set_right()
4114
4115           Default state:      Border is off
4116           Default action:     Set border type 1
4117           Valid args:         0-13, See below.
4118
4119       A cell border is comprised of a border on the bottom, top, left and
4120       right. These can be set to the same value using "set_border()" or
4121       individually using the relevant method calls shown above.
4122
4123       The following shows the border styles sorted by Excel::Writer::XLSX
4124       index number:
4125
4126           Index   Name            Weight   Style
4127           =====   =============   ======   ===========
4128           0       None            0
4129           1       Continuous      1        -----------
4130           2       Continuous      2        -----------
4131           3       Dash            1        - - - - - -
4132           4       Dot             1        . . . . . .
4133           5       Continuous      3        -----------
4134           6       Double          3        ===========
4135           7       Continuous      0        -----------
4136           8       Dash            2        - - - - - -
4137           9       Dash Dot        1        - . - . - .
4138           10      Dash Dot        2        - . - . - .
4139           11      Dash Dot Dot    1        - . . - . .
4140           12      Dash Dot Dot    2        - . . - . .
4141           13      SlantDash Dot   2        / - . / - .
4142
4143       The following shows the borders sorted by style:
4144
4145           Name            Weight   Style         Index
4146           =============   ======   ===========   =====
4147           Continuous      0        -----------   7
4148           Continuous      1        -----------   1
4149           Continuous      2        -----------   2
4150           Continuous      3        -----------   5
4151           Dash            1        - - - - - -   3
4152           Dash            2        - - - - - -   8
4153           Dash Dot        1        - . - . - .   9
4154           Dash Dot        2        - . - . - .   10
4155           Dash Dot Dot    1        - . . - . .   11
4156           Dash Dot Dot    2        - . . - . .   12
4157           Dot             1        . . . . . .   4
4158           Double          3        ===========   6
4159           None            0                      0
4160           SlantDash Dot   2        / - . / - .   13
4161
4162       The following shows the borders in the order shown in the Excel Dialog.
4163
4164           Index   Style             Index   Style
4165           =====   =====             =====   =====
4166           0       None              12      - . . - . .
4167           7       -----------       13      / - . / - .
4168           4       . . . . . .       10      - . - . - .
4169           11      - . . - . .       8       - - - - - -
4170           9       - . - . - .       2       -----------
4171           3       - - - - - -       5       -----------
4172           1       -----------       6       ===========
4173
4174       Examples of the available border styles are shown in the 'Borders'
4175       worksheet created by formats.pl.
4176
4177   set_border_color()
4178           Also applies to:    set_bottom_color()
4179                               set_top_color()
4180                               set_left_color()
4181                               set_right_color()
4182
4183           Default state:      Color is off
4184           Default action:     Undefined
4185           Valid args:         See set_color()
4186
4187       Set the colour of the cell borders. A cell border is comprised of a
4188       border on the bottom, top, left and right. These can be set to the same
4189       colour using "set_border_color()" or individually using the relevant
4190       method calls shown above. Examples of the border styles and colours are
4191       shown in the 'Borders' worksheet created by formats.pl.
4192
4193   set_diag_type()
4194           Default state:      Diagonal border is off.
4195           Default action:     None.
4196           Valid args:         1-3, See below.
4197
4198       Set the diagonal border type for the cell. Three types of diagonal
4199       borders are available in Excel:
4200
4201          1: From bottom left to top right.
4202          2: From top left to bottom right.
4203          3: Same as 1 and 2 combined.
4204
4205       For example:
4206
4207           $format->set_diag_type( 3 );
4208
4209   set_diag_border()
4210           Default state:      Border is off
4211           Default action:     Set border type 1
4212           Valid args:         0-13, See below.
4213
4214       Set the diagonal border style. Same as the parameter to "set_border()"
4215       above.
4216
4217   set_diag_color()
4218           Default state:      Color is off
4219           Default action:     Undefined
4220           Valid args:         See set_color()
4221
4222       Set the colour of the diagonal cell border:
4223
4224           $format->set_diag_type( 3 );
4225           $format->set_diag_border( 7 );
4226           $format->set_diag_color( 'red' );
4227
4228   copy( $format )
4229       This method is used to copy all of the properties from one Format
4230       object to another:
4231
4232           my $lorry1 = $workbook->add_format();
4233           $lorry1->set_bold();
4234           $lorry1->set_italic();
4235           $lorry1->set_color( 'red' );    # lorry1 is bold, italic and red
4236
4237           my $lorry2 = $workbook->add_format();
4238           $lorry2->copy( $lorry1 );
4239           $lorry2->set_color( 'yellow' );    # lorry2 is bold, italic and yellow
4240
4241       The "copy()" method is only useful if you are using the method
4242       interface to Format properties. It generally isn't required if you are
4243       setting Format properties directly using hashes.
4244
4245       Note: this is not a copy constructor, both objects must exist prior to
4246       copying.
4247

UNICODE IN EXCEL

4249       The following is a brief introduction to handling Unicode in
4250       "Excel::Writer::XLSX".
4251
4252       For a more general introduction to Unicode handling in Perl see
4253       perlunitut and perluniintro.
4254
4255       Excel::Writer::XLSX writer differs from Spreadsheet::WriteExcel in that
4256       it only handles Unicode data in "UTF-8" format and doesn't try to
4257       handle legacy UTF-16 Excel formats.
4258
4259       If the data is in "UTF-8" format then Excel::Writer::XLSX will handle
4260       it automatically.
4261
4262       If you are dealing with non-ASCII characters that aren't in "UTF-8"
4263       then perl provides useful tools in the guise of the "Encode" module to
4264       help you to convert to the required format. For example:
4265
4266           use Encode 'decode';
4267
4268           my $string = 'some string with koi8-r characters';
4269              $string = decode('koi8-r', $string); # koi8-r to utf8
4270
4271       Alternatively you can read data from an encoded file and convert it to
4272       "UTF-8" as you read it in:
4273
4274           my $file = 'unicode_koi8r.txt';
4275           open FH, '<:encoding(koi8-r)', $file or die "Couldn't open $file: $!\n";
4276
4277           my $row = 0;
4278           while ( <FH> ) {
4279               # Data read in is now in utf8 format.
4280               chomp;
4281               $worksheet->write( $row++, 0, $_ );
4282           }
4283
4284       These methodologies are explained in more detail in perlunitut,
4285       perluniintro and perlunicode.
4286
4287       If the program contains UTF-8 text then you will also need to add "use
4288       utf8" to the includes:
4289
4290           use utf8;
4291
4292           ...
4293
4294           $worksheet->write( 'A1', 'Some UTF-8 string' );
4295
4296       See also the "unicode_*.pl" programs in the examples directory of the
4297       distro.
4298

WORKING WITH COLOURS

4300       Throughout Excel::Writer::XLSX colours can be specified using a Html
4301       style "#RRGGBB" value. For example with a Format object:
4302
4303           $format->set_font_color( '#FF0000' );
4304
4305       For backward compatibility a limited number of color names are
4306       supported:
4307
4308           $format->set_font_color( 'red' );
4309
4310       The color names supported are:
4311
4312           black
4313           blue
4314           brown
4315           cyan
4316           gray
4317           green
4318           lime
4319           magenta
4320           navy
4321           orange
4322           pink
4323           purple
4324           red
4325           silver
4326           white
4327           yellow
4328
4329       See also "colors.pl" in the "examples" directory.
4330

DATES AND TIME IN EXCEL

4332       There are two important things to understand about dates and times in
4333       Excel:
4334
4335       1 A date/time in Excel is a real number plus an Excel number format.
4336       2 Excel::Writer::XLSX doesn't automatically convert date/time strings
4337       in "write()" to an Excel date/time.
4338
4339       These two points are explained in more detail below along with some
4340       suggestions on how to convert times and dates to the required format.
4341
4342   An Excel date/time is a number plus a format
4343       If you write a date string with "write()" then all you will get is a
4344       string:
4345
4346           $worksheet->write( 'A1', '02/03/04' );   # !! Writes a string not a date. !!
4347
4348       Dates and times in Excel are represented by real numbers, for example
4349       "Jan 1 2001 12:30 AM" is represented by the number 36892.521.
4350
4351       The integer part of the number stores the number of days since the
4352       epoch and the fractional part stores the percentage of the day.
4353
4354       A date or time in Excel is just like any other number. To have the
4355       number display as a date you must apply an Excel number format to it.
4356       Here are some examples.
4357
4358           #!/usr/bin/perl -w
4359
4360           use strict;
4361           use Excel::Writer::XLSX;
4362
4363           my $workbook  = Excel::Writer::XLSX->new( 'date_examples.xlsx' );
4364           my $worksheet = $workbook->add_worksheet();
4365
4366           $worksheet->set_column( 'A:A', 30 );    # For extra visibility.
4367
4368           my $number = 39506.5;
4369
4370           $worksheet->write( 'A1', $number );             #   39506.5
4371
4372           my $format2 = $workbook->add_format( num_format => 'dd/mm/yy' );
4373           $worksheet->write( 'A2', $number, $format2 );    #  28/02/08
4374
4375           my $format3 = $workbook->add_format( num_format => 'mm/dd/yy' );
4376           $worksheet->write( 'A3', $number, $format3 );    #  02/28/08
4377
4378           my $format4 = $workbook->add_format( num_format => 'd-m-yyyy' );
4379           $worksheet->write( 'A4', $number, $format4 );    #  28-2-2008
4380
4381           my $format5 = $workbook->add_format( num_format => 'dd/mm/yy hh:mm' );
4382           $worksheet->write( 'A5', $number, $format5 );    #  28/02/08 12:00
4383
4384           my $format6 = $workbook->add_format( num_format => 'd mmm yyyy' );
4385           $worksheet->write( 'A6', $number, $format6 );    # 28 Feb 2008
4386
4387           my $format7 = $workbook->add_format( num_format => 'mmm d yyyy hh:mm AM/PM' );
4388           $worksheet->write('A7', $number , $format7);     #  Feb 28 2008 12:00 PM
4389
4390           $workbook->close();
4391
4392   Excel::Writer::XLSX doesn't automatically convert date/time strings
4393       Excel::Writer::XLSX doesn't automatically convert input date strings
4394       into Excel's formatted date numbers due to the large number of possible
4395       date formats and also due to the possibility of misinterpretation.
4396
4397       For example, does "02/03/04" mean March 2 2004, February 3 2004 or even
4398       March 4 2002.
4399
4400       Therefore, in order to handle dates you will have to convert them to
4401       numbers and apply an Excel format. Some methods for converting dates
4402       are listed in the next section.
4403
4404       The most direct way is to convert your dates to the ISO8601
4405       "yyyy-mm-ddThh:mm:ss.sss" date format and use the "write_date_time()"
4406       worksheet method:
4407
4408           $worksheet->write_date_time( 'A2', '2001-01-01T12:20', $format );
4409
4410       See the "write_date_time()" section of the documentation for more
4411       details.
4412
4413       A general methodology for handling date strings with
4414       "write_date_time()" is:
4415
4416           1. Identify incoming date/time strings with a regex.
4417           2. Extract the component parts of the date/time using the same regex.
4418           3. Convert the date/time to the ISO8601 format.
4419           4. Write the date/time using write_date_time() and a number format.
4420
4421       Here is an example:
4422
4423           #!/usr/bin/perl -w
4424
4425           use strict;
4426           use Excel::Writer::XLSX;
4427
4428           my $workbook  = Excel::Writer::XLSX->new( 'example.xlsx' );
4429           my $worksheet = $workbook->add_worksheet();
4430
4431           # Set the default format for dates.
4432           my $date_format = $workbook->add_format( num_format => 'mmm d yyyy' );
4433
4434           # Increase column width to improve visibility of data.
4435           $worksheet->set_column( 'A:C', 20 );
4436
4437           # Simulate reading from a data source.
4438           my $row = 0;
4439
4440           while ( <DATA> ) {
4441               chomp;
4442
4443               my $col  = 0;
4444               my @data = split ' ';
4445
4446               for my $item ( @data ) {
4447
4448                   # Match dates in the following formats: d/m/yy, d/m/yyyy
4449                   if ( $item =~ qr[^(\d{1,2})/(\d{1,2})/(\d{4})$] ) {
4450
4451                       # Change to the date format required by write_date_time().
4452                       my $date = sprintf "%4d-%02d-%02dT", $3, $2, $1;
4453
4454                       $worksheet->write_date_time( $row, $col++, $date,
4455                           $date_format );
4456                   }
4457                   else {
4458
4459                       # Just plain data
4460                       $worksheet->write( $row, $col++, $item );
4461                   }
4462               }
4463               $row++;
4464           }
4465
4466           $workbook->close();
4467
4468           __DATA__
4469           Item    Cost    Date
4470           Book    10      1/9/2007
4471           Beer    4       12/9/2007
4472           Bed     500     5/10/2007
4473
4474       For a slightly more advanced solution you can modify the "write()"
4475       method to handle date formats of your choice via the
4476       "add_write_handler()" method. See the "add_write_handler()" section of
4477       the docs and the write_handler3.pl and write_handler4.pl programs in
4478       the examples directory of the distro.
4479
4480   Converting dates and times to an Excel date or time
4481       The "write_date_time()" method above is just one way of handling dates
4482       and times.
4483
4484       You can also use the "convert_date_time()" worksheet method to convert
4485       from an ISO8601 style date string to an Excel date and time number.
4486
4487       The Excel::Writer::XLSX::Utility module which is included in the distro
4488       has date/time handling functions:
4489
4490           use Excel::Writer::XLSX::Utility;
4491
4492           $date           = xl_date_list(2002, 1, 1);         # 37257
4493           $date           = xl_parse_date("11 July 1997");    # 35622
4494           $time           = xl_parse_time('3:21:36 PM');      # 0.64
4495           $date           = xl_decode_date_EU("13 May 2002"); # 37389
4496
4497       Note: some of these functions require additional CPAN modules.
4498
4499       For date conversions using the CPAN "DateTime" framework see
4500       DateTime::Format::Excel
4501       <http://search.cpan.org/search?dist=DateTime-Format-Excel>.
4502

OUTLINES AND GROUPING IN EXCEL

4504       Excel allows you to group rows or columns so that they can be hidden or
4505       displayed with a single mouse click. This feature is referred to as
4506       outlines.
4507
4508       Outlines can reduce complex data down to a few salient sub-totals or
4509       summaries.
4510
4511       This feature is best viewed in Excel but the following is an ASCII
4512       representation of what a worksheet with three outlines might look like.
4513       Rows 3-4 and rows 7-8 are grouped at level 2. Rows 2-9 are grouped at
4514       level 1. The lines at the left hand side are called outline level bars.
4515
4516                   ------------------------------------------
4517            1 2 3 |   |   A   |   B   |   C   |   D   |  ...
4518                   ------------------------------------------
4519             _    | 1 |   A   |       |       |       |  ...
4520            |  _  | 2 |   B   |       |       |       |  ...
4521            | |   | 3 |  (C)  |       |       |       |  ...
4522            | |   | 4 |  (D)  |       |       |       |  ...
4523            | -   | 5 |   E   |       |       |       |  ...
4524            |  _  | 6 |   F   |       |       |       |  ...
4525            | |   | 7 |  (G)  |       |       |       |  ...
4526            | |   | 8 |  (H)  |       |       |       |  ...
4527            | -   | 9 |   I   |       |       |       |  ...
4528            -     | . |  ...  |  ...  |  ...  |  ...  |  ...
4529
4530       Clicking the minus sign on each of the level 2 outlines will collapse
4531       and hide the data as shown in the next figure. The minus sign changes
4532       to a plus sign to indicate that the data in the outline is hidden.
4533
4534                   ------------------------------------------
4535            1 2 3 |   |   A   |   B   |   C   |   D   |  ...
4536                   ------------------------------------------
4537             _    | 1 |   A   |       |       |       |  ...
4538            |     | 2 |   B   |       |       |       |  ...
4539            | +   | 5 |   E   |       |       |       |  ...
4540            |     | 6 |   F   |       |       |       |  ...
4541            | +   | 9 |   I   |       |       |       |  ...
4542            -     | . |  ...  |  ...  |  ...  |  ...  |  ...
4543
4544       Clicking on the minus sign on the level 1 outline will collapse the
4545       remaining rows as follows:
4546
4547                   ------------------------------------------
4548            1 2 3 |   |   A   |   B   |   C   |   D   |  ...
4549                   ------------------------------------------
4550                  | 1 |   A   |       |       |       |  ...
4551            +     | . |  ...  |  ...  |  ...  |  ...  |  ...
4552
4553       Grouping in "Excel::Writer::XLSX" is achieved by setting the outline
4554       level via the "set_row()" and "set_column()" worksheet methods:
4555
4556           set_row( $row, $height, $format, $hidden, $level, $collapsed )
4557           set_column( $first_col, $last_col, $width, $format, $hidden, $level, $collapsed )
4558
4559       The following example sets an outline level of 1 for rows 2 and 3
4560       (zero-indexed) and columns B to G. The parameters $height and $XF are
4561       assigned default values since they are undefined:
4562
4563           $worksheet->set_row( 1, undef, undef, 0, 1 );
4564           $worksheet->set_row( 2, undef, undef, 0, 1 );
4565           $worksheet->set_column( 'B:G', undef, undef, 0, 1 );
4566
4567       Excel allows up to 7 outline levels. Therefore the $level parameter
4568       should be in the range "0 <= $level <= 7".
4569
4570       Rows and columns can be collapsed by setting the $hidden flag for the
4571       hidden rows/columns and setting the $collapsed flag for the row/column
4572       that has the collapsed "+" symbol:
4573
4574           $worksheet->set_row( 1, undef, undef, 1, 1 );
4575           $worksheet->set_row( 2, undef, undef, 1, 1 );
4576           $worksheet->set_row( 3, undef, undef, 0, 0, 1 );          # Collapsed flag.
4577
4578           $worksheet->set_column( 'B:G', undef, undef, 1, 1 );
4579           $worksheet->set_column( 'H:H', undef, undef, 0, 0, 1 );   # Collapsed flag.
4580
4581       Note: Setting the $collapsed flag is particularly important for
4582       compatibility with OpenOffice.org and Gnumeric.
4583
4584       For a more complete example see the "outline.pl" and
4585       "outline_collapsed.pl" programs in the examples directory of the
4586       distro.
4587
4588       Some additional outline properties can be set via the
4589       "outline_settings()" worksheet method, see above.
4590

DATA VALIDATION IN EXCEL

4592       Data validation is a feature of Excel which allows you to restrict the
4593       data that a users enters in a cell and to display help and warning
4594       messages. It also allows you to restrict input to values in a drop down
4595       list.
4596
4597       A typical use case might be to restrict data in a cell to integer
4598       values in a certain range, to provide a help message to indicate the
4599       required value and to issue a warning if the input data doesn't meet
4600       the stated criteria. In Excel::Writer::XLSX we could do that as
4601       follows:
4602
4603           $worksheet->data_validation('B3',
4604               {
4605                   validate        => 'integer',
4606                   criteria        => 'between',
4607                   minimum         => 1,
4608                   maximum         => 100,
4609                   input_title     => 'Input an integer:',
4610                   input_message   => 'Between 1 and 100',
4611                   error_message   => 'Sorry, try again.',
4612               });
4613
4614       For more information on data validation see the following Microsoft
4615       support article "Description and examples of data validation in Excel":
4616       <http://support.microsoft.com/kb/211485>.
4617
4618       The following sections describe how to use the "data_validation()"
4619       method and its various options.
4620
4621   data_validation( $row, $col, { parameter => 'value', ... } )
4622       The "data_validation()" method is used to construct an Excel data
4623       validation.
4624
4625       It can be applied to a single cell or a range of cells. You can pass 3
4626       parameters such as "($row, $col, {...})" or 5 parameters such as
4627       "($first_row, $first_col, $last_row, $last_col, {...})". You can also
4628       use "A1" style notation. For example:
4629
4630           $worksheet->data_validation( 0, 0,       {...} );
4631           $worksheet->data_validation( 0, 0, 4, 1, {...} );
4632
4633           # Which are the same as:
4634
4635           $worksheet->data_validation( 'A1',       {...} );
4636           $worksheet->data_validation( 'A1:B5',    {...} );
4637
4638       See also the note about "Cell notation" for more information.
4639
4640       The last parameter in "data_validation()" must be a hash ref containing
4641       the parameters that describe the type and style of the data validation.
4642       The allowable parameters are:
4643
4644           validate
4645           criteria
4646           value | minimum | source
4647           maximum
4648           ignore_blank
4649           dropdown
4650
4651           input_title
4652           input_message
4653           show_input
4654
4655           error_title
4656           error_message
4657           error_type
4658           show_error
4659
4660       These parameters are explained in the following sections. Most of the
4661       parameters are optional, however, you will generally require the three
4662       main options "validate", "criteria" and "value".
4663
4664           $worksheet->data_validation('B3',
4665               {
4666                   validate => 'integer',
4667                   criteria => '>',
4668                   value    => 100,
4669               });
4670
4671       The "data_validation" method returns:
4672
4673            0 for success.
4674           -1 for insufficient number of arguments.
4675           -2 for row or column out of bounds.
4676           -3 for incorrect parameter or value.
4677
4678   validate
4679       This parameter is passed in a hash ref to "data_validation()".
4680
4681       The "validate" parameter is used to set the type of data that you wish
4682       to validate. It is always required and it has no default value.
4683       Allowable values are:
4684
4685           any
4686           integer
4687           decimal
4688           list
4689           date
4690           time
4691           length
4692           custom
4693
4694       ·   any is used to specify that the type of data is unrestricted. This
4695           is useful to display an input message without restricting the data
4696           that can be entered.
4697
4698       ·   integer restricts the cell to integer values. Excel refers to this
4699           as 'whole number'.
4700
4701               validate => 'integer',
4702               criteria => '>',
4703               value    => 100,
4704
4705       ·   decimal restricts the cell to decimal values.
4706
4707               validate => 'decimal',
4708               criteria => '>',
4709               value    => 38.6,
4710
4711       ·   list restricts the cell to a set of user specified values. These
4712           can be passed in an array ref or as a cell range (named ranges
4713           aren't currently supported):
4714
4715               validate => 'list',
4716               value    => ['open', 'high', 'close'],
4717               # Or like this:
4718               value    => 'B1:B3',
4719
4720           Excel requires that range references are only to cells on the same
4721           worksheet.
4722
4723       ·   date restricts the cell to date values. Dates in Excel are
4724           expressed as integer values but you can also pass an ISO8601 style
4725           string as used in "write_date_time()". See also "DATES AND TIME IN
4726           EXCEL" for more information about working with Excel's dates.
4727
4728               validate => 'date',
4729               criteria => '>',
4730               value    => 39653, # 24 July 2008
4731               # Or like this:
4732               value    => '2008-07-24T',
4733
4734       ·   time restricts the cell to time values. Times in Excel are
4735           expressed as decimal values but you can also pass an ISO8601 style
4736           string as used in "write_date_time()". See also "DATES AND TIME IN
4737           EXCEL" for more information about working with Excel's times.
4738
4739               validate => 'time',
4740               criteria => '>',
4741               value    => 0.5, # Noon
4742               # Or like this:
4743               value    => 'T12:00:00',
4744
4745       ·   length restricts the cell data based on an integer string length.
4746           Excel refers to this as 'Text length'.
4747
4748               validate => 'length',
4749               criteria => '>',
4750               value    => 10,
4751
4752       ·   custom restricts the cell based on an external Excel formula that
4753           returns a "TRUE/FALSE" value.
4754
4755               validate => 'custom',
4756               value    => '=IF(A10>B10,TRUE,FALSE)',
4757
4758   criteria
4759       This parameter is passed in a hash ref to "data_validation()".
4760
4761       The "criteria" parameter is used to set the criteria by which the data
4762       in the cell is validated. It is almost always required except for the
4763       "list" and "custom" validate options. It has no default value.
4764       Allowable values are:
4765
4766           'between'
4767           'not between'
4768           'equal to'                  |  '=='  |  '='
4769           'not equal to'              |  '!='  |  '<>'
4770           'greater than'              |  '>'
4771           'less than'                 |  '<'
4772           'greater than or equal to'  |  '>='
4773           'less than or equal to'     |  '<='
4774
4775       You can either use Excel's textual description strings, in the first
4776       column above, or the more common symbolic alternatives. The following
4777       are equivalent:
4778
4779           validate => 'integer',
4780           criteria => 'greater than',
4781           value    => 100,
4782
4783           validate => 'integer',
4784           criteria => '>',
4785           value    => 100,
4786
4787       The "list" and "custom" validate options don't require a "criteria". If
4788       you specify one it will be ignored.
4789
4790           validate => 'list',
4791           value    => ['open', 'high', 'close'],
4792
4793           validate => 'custom',
4794           value    => '=IF(A10>B10,TRUE,FALSE)',
4795
4796   value | minimum | source
4797       This parameter is passed in a hash ref to "data_validation()".
4798
4799       The "value" parameter is used to set the limiting value to which the
4800       "criteria" is applied. It is always required and it has no default
4801       value. You can also use the synonyms "minimum" or "source" to make the
4802       validation a little clearer and closer to Excel's description of the
4803       parameter:
4804
4805           # Use 'value'
4806           validate => 'integer',
4807           criteria => '>',
4808           value    => 100,
4809
4810           # Use 'minimum'
4811           validate => 'integer',
4812           criteria => 'between',
4813           minimum  => 1,
4814           maximum  => 100,
4815
4816           # Use 'source'
4817           validate => 'list',
4818           source   => '$B$1:$B$3',
4819
4820   maximum
4821       This parameter is passed in a hash ref to "data_validation()".
4822
4823       The "maximum" parameter is used to set the upper limiting value when
4824       the "criteria" is either 'between' or 'not between':
4825
4826           validate => 'integer',
4827           criteria => 'between',
4828           minimum  => 1,
4829           maximum  => 100,
4830
4831   ignore_blank
4832       This parameter is passed in a hash ref to "data_validation()".
4833
4834       The "ignore_blank" parameter is used to toggle on and off the 'Ignore
4835       blank' option in the Excel data validation dialog. When the option is
4836       on the data validation is not applied to blank data in the cell. It is
4837       on by default.
4838
4839           ignore_blank => 0,  # Turn the option off
4840
4841   dropdown
4842       This parameter is passed in a hash ref to "data_validation()".
4843
4844       The "dropdown" parameter is used to toggle on and off the 'In-cell
4845       dropdown' option in the Excel data validation dialog. When the option
4846       is on a dropdown list will be shown for "list" validations. It is on by
4847       default.
4848
4849           dropdown => 0,      # Turn the option off
4850
4851   input_title
4852       This parameter is passed in a hash ref to "data_validation()".
4853
4854       The "input_title" parameter is used to set the title of the input
4855       message that is displayed when a cell is entered. It has no default
4856       value and is only displayed if the input message is displayed. See the
4857       "input_message" parameter below.
4858
4859           input_title   => 'This is the input title',
4860
4861       The maximum title length is 32 characters.
4862
4863   input_message
4864       This parameter is passed in a hash ref to "data_validation()".
4865
4866       The "input_message" parameter is used to set the input message that is
4867       displayed when a cell is entered. It has no default value.
4868
4869           validate      => 'integer',
4870           criteria      => 'between',
4871           minimum       => 1,
4872           maximum       => 100,
4873           input_title   => 'Enter the applied discount:',
4874           input_message => 'between 1 and 100',
4875
4876       The message can be split over several lines using newlines, "\n" in
4877       double quoted strings.
4878
4879           input_message => "This is\na test.",
4880
4881       The maximum message length is 255 characters.
4882
4883   show_input
4884       This parameter is passed in a hash ref to "data_validation()".
4885
4886       The "show_input" parameter is used to toggle on and off the 'Show input
4887       message when cell is selected' option in the Excel data validation
4888       dialog. When the option is off an input message is not displayed even
4889       if it has been set using "input_message". It is on by default.
4890
4891           show_input => 0,      # Turn the option off
4892
4893   error_title
4894       This parameter is passed in a hash ref to "data_validation()".
4895
4896       The "error_title" parameter is used to set the title of the error
4897       message that is displayed when the data validation criteria is not met.
4898       The default error title is 'Microsoft Excel'.
4899
4900           error_title   => 'Input value is not valid',
4901
4902       The maximum title length is 32 characters.
4903
4904   error_message
4905       This parameter is passed in a hash ref to "data_validation()".
4906
4907       The "error_message" parameter is used to set the error message that is
4908       displayed when a cell is entered. The default error message is "The
4909       value you entered is not valid.\nA user has restricted values that can
4910       be entered into the cell.".
4911
4912           validate      => 'integer',
4913           criteria      => 'between',
4914           minimum       => 1,
4915           maximum       => 100,
4916           error_title   => 'Input value is not valid',
4917           error_message => 'It should be an integer between 1 and 100',
4918
4919       The message can be split over several lines using newlines, "\n" in
4920       double quoted strings.
4921
4922           input_message => "This is\na test.",
4923
4924       The maximum message length is 255 characters.
4925
4926   error_type
4927       This parameter is passed in a hash ref to "data_validation()".
4928
4929       The "error_type" parameter is used to specify the type of error dialog
4930       that is displayed. There are 3 options:
4931
4932           'stop'
4933           'warning'
4934           'information'
4935
4936       The default is 'stop'.
4937
4938   show_error
4939       This parameter is passed in a hash ref to "data_validation()".
4940
4941       The "show_error" parameter is used to toggle on and off the 'Show error
4942       alert after invalid data is entered' option in the Excel data
4943       validation dialog. When the option is off an error message is not
4944       displayed even if it has been set using "error_message". It is on by
4945       default.
4946
4947           show_error => 0,      # Turn the option off
4948
4949   Data Validation Examples
4950       Example 1. Limiting input to an integer greater than a fixed value.
4951
4952           $worksheet->data_validation('A1',
4953               {
4954                   validate        => 'integer',
4955                   criteria        => '>',
4956                   value           => 0,
4957               });
4958
4959       Example 2. Limiting input to an integer greater than a fixed value
4960       where the value is referenced from a cell.
4961
4962           $worksheet->data_validation('A2',
4963               {
4964                   validate        => 'integer',
4965                   criteria        => '>',
4966                   value           => '=E3',
4967               });
4968
4969       Example 3. Limiting input to a decimal in a fixed range.
4970
4971           $worksheet->data_validation('A3',
4972               {
4973                   validate        => 'decimal',
4974                   criteria        => 'between',
4975                   minimum         => 0.1,
4976                   maximum         => 0.5,
4977               });
4978
4979       Example 4. Limiting input to a value in a dropdown list.
4980
4981           $worksheet->data_validation('A4',
4982               {
4983                   validate        => 'list',
4984                   source          => ['open', 'high', 'close'],
4985               });
4986
4987       Example 5. Limiting input to a value in a dropdown list where the list
4988       is specified as a cell range.
4989
4990           $worksheet->data_validation('A5',
4991               {
4992                   validate        => 'list',
4993                   source          => '=$E$4:$G$4',
4994               });
4995
4996       Example 6. Limiting input to a date in a fixed range.
4997
4998           $worksheet->data_validation('A6',
4999               {
5000                   validate        => 'date',
5001                   criteria        => 'between',
5002                   minimum         => '2008-01-01T',
5003                   maximum         => '2008-12-12T',
5004               });
5005
5006       Example 7. Displaying a message when the cell is selected.
5007
5008           $worksheet->data_validation('A7',
5009               {
5010                   validate      => 'integer',
5011                   criteria      => 'between',
5012                   minimum       => 1,
5013                   maximum       => 100,
5014                   input_title   => 'Enter an integer:',
5015                   input_message => 'between 1 and 100',
5016               });
5017
5018       See also the "data_validate.pl" program in the examples directory of
5019       the distro.
5020

CONDITIONAL FORMATTING IN EXCEL

5022       Conditional formatting is a feature of Excel which allows you to apply
5023       a format to a cell or a range of cells based on a certain criteria.
5024
5025       For example the following criteria is used to highlight cells >= 50 in
5026       red in the "conditional_format.pl" example from the distro:
5027
5028           # Write a conditional format over a range.
5029           $worksheet->conditional_formatting( 'B3:K12',
5030               {
5031                   type     => 'cell',
5032                   criteria => '>=',
5033                   value    => 50,
5034                   format   => $format1,
5035               }
5036           );
5037
5038   conditional_formatting( $row, $col, { parameter => 'value', ... } )
5039       The "conditional_formatting()" method is used to apply formatting
5040       based on user defined criteria to an Excel::Writer::XLSX file.
5041
5042       It can be applied to a single cell or a range of cells. You can pass 3
5043       parameters such as "($row, $col, {...})" or 5 parameters such as
5044       "($first_row, $first_col, $last_row, $last_col, {...})". You can also
5045       use "A1" style notation. For example:
5046
5047           $worksheet->conditional_formatting( 0, 0,       {...} );
5048           $worksheet->conditional_formatting( 0, 0, 4, 1, {...} );
5049
5050           # Which are the same as:
5051
5052           $worksheet->conditional_formatting( 'A1',       {...} );
5053           $worksheet->conditional_formatting( 'A1:B5',    {...} );
5054
5055       See also the note about "Cell notation" for more information.
5056
5057       Using "A1" style notation is also possible to specify non-contiguous
5058       ranges, separated by a comma. For example:
5059
5060           $worksheet->conditional_formatting( 'A1:D5,A8:D12', {...} );
5061
5062       The last parameter in "conditional_formatting()" must be a hash ref
5063       containing the parameters that describe the type and style of the data
5064       validation. The main parameters are:
5065
5066           type
5067           format
5068           criteria
5069           value
5070           minimum
5071           maximum
5072
5073       Other, less commonly used parameters are:
5074
5075           min_type
5076           mid_type
5077           max_type
5078           min_value
5079           mid_value
5080           max_value
5081           min_color
5082           mid_color
5083           max_color
5084           bar_color
5085           bar_only
5086           bar_solid
5087           bar_negative_color
5088           bar_border_color
5089           bar_negative_border_color
5090           bar_negative_color_same
5091           bar_negative_border_color_same
5092           bar_no_border
5093           bar_direction
5094           bar_axis_position
5095           bar_axis_color
5096           data_bar_2010
5097           icon_style
5098           icons
5099           reverse_icons
5100           icons_only
5101           stop_if_true
5102           multi_range
5103
5104       Additional parameters which are used for specific conditional format
5105       types are shown in the relevant sections below.
5106
5107   type
5108       This parameter is passed in a hash ref to "conditional_formatting()".
5109
5110       The "type" parameter is used to set the type of conditional formatting
5111       that you wish to apply. It is always required and it has no default
5112       value. Allowable "type" values and their associated parameters are:
5113
5114           Type            Parameters
5115           ====            ==========
5116           cell            criteria
5117                           value
5118                           minimum
5119                           maximum
5120                           format
5121
5122           date            criteria
5123                           value
5124                           minimum
5125                           maximum
5126                           format
5127
5128           time_period     criteria
5129                           format
5130
5131           text            criteria
5132                           value
5133                           format
5134
5135           average         criteria
5136                           format
5137
5138           duplicate       format
5139
5140           unique          format
5141
5142           top             criteria
5143                           value
5144                           format
5145
5146           bottom          criteria
5147                           value
5148                           format
5149
5150           blanks          format
5151
5152           no_blanks       format
5153
5154           errors          format
5155
5156           no_errors       format
5157
5158           formula         criteria
5159                           format
5160
5161           2_color_scale   min_type
5162                           max_type
5163                           min_value
5164                           max_value
5165                           min_color
5166                           max_color
5167
5168           3_color_scale   min_type
5169                           mid_type
5170                           max_type
5171                           min_value
5172                           mid_value
5173                           max_value
5174                           min_color
5175                           mid_color
5176                           max_color
5177
5178           data_bar        min_type
5179                           max_type
5180                           min_value
5181                           max_value
5182                           bar_only
5183                           bar_color
5184                           bar_solid*
5185                           bar_negative_color*
5186                           bar_border_color*
5187                           bar_negative_border_color*
5188                           bar_negative_color_same*
5189                           bar_negative_border_color_same*
5190                           bar_no_border*
5191                           bar_direction*
5192                           bar_axis_position*
5193                           bar_axis_color*
5194                           data_bar_2010*
5195
5196           icon_set        icon_style
5197                           reverse_icons
5198                           icons
5199                           icons_only
5200
5201       Data bar parameters marked with (*) are only available in Excel 2010
5202       and later. Files that use these properties can still be opened in Excel
5203       2007 but the data bars will be displayed without them.
5204
5205   type => 'cell'
5206       This is the most common conditional formatting type. It is used when a
5207       format is applied to a cell based on a simple criterion. For example:
5208
5209           $worksheet->conditional_formatting( 'A1',
5210               {
5211                   type     => 'cell',
5212                   criteria => 'greater than',
5213                   value    => 5,
5214                   format   => $red_format,
5215               }
5216           );
5217
5218       Or, using the "between" criteria:
5219
5220           $worksheet->conditional_formatting( 'C1:C4',
5221               {
5222                   type     => 'cell',
5223                   criteria => 'between',
5224                   minimum  => 20,
5225                   maximum  => 30,
5226                   format   => $green_format,
5227               }
5228           );
5229
5230   criteria
5231       The "criteria" parameter is used to set the criteria by which the cell
5232       data will be evaluated. It has no default value. The most common
5233       criteria as applied to "{ type => 'cell' }" are:
5234
5235           'between'
5236           'not between'
5237           'equal to'                  |  '=='  |  '='
5238           'not equal to'              |  '!='  |  '<>'
5239           'greater than'              |  '>'
5240           'less than'                 |  '<'
5241           'greater than or equal to'  |  '>='
5242           'less than or equal to'     |  '<='
5243
5244       You can either use Excel's textual description strings, in the first
5245       column above, or the more common symbolic alternatives.
5246
5247       Additional criteria which are specific to other conditional format
5248       types are shown in the relevant sections below.
5249
5250   value
5251       The "value" is generally used along with the "criteria" parameter to
5252       set the rule by which the cell data  will be evaluated.
5253
5254           type     => 'cell',
5255           criteria => '>',
5256           value    => 5
5257           format   => $format,
5258
5259       The "value" property can also be an cell reference.
5260
5261           type     => 'cell',
5262           criteria => '>',
5263           value    => '$C$1',
5264           format   => $format,
5265
5266   format
5267       The "format" parameter is used to specify the format that will be
5268       applied to the cell when the conditional formatting criterion is met.
5269       The format is created using the "add_format()" method in the same way
5270       as cell formats:
5271
5272           $format = $workbook->add_format( bold => 1, italic => 1 );
5273
5274           $worksheet->conditional_formatting( 'A1',
5275               {
5276                   type     => 'cell',
5277                   criteria => '>',
5278                   value    => 5
5279                   format   => $format,
5280               }
5281           );
5282
5283       The conditional format follows the same rules as in Excel: it is
5284       superimposed over the existing cell format and not all font and border
5285       properties can be modified. Font properties that can't be modified are
5286       font name, font size, superscript and subscript. The border property
5287       that cannot be modified is diagonal borders.
5288
5289       Excel specifies some default formats to be used with conditional
5290       formatting. You can replicate them using the following
5291       Excel::Writer::XLSX formats:
5292
5293           # Light red fill with dark red text.
5294
5295           my $format1 = $workbook->add_format(
5296               bg_color => '#FFC7CE',
5297               color    => '#9C0006',
5298           );
5299
5300           # Light yellow fill with dark yellow text.
5301
5302           my $format2 = $workbook->add_format(
5303               bg_color => '#FFEB9C',
5304               color    => '#9C6500',
5305           );
5306
5307           # Green fill with dark green text.
5308
5309           my $format3 = $workbook->add_format(
5310               bg_color => '#C6EFCE',
5311               color    => '#006100',
5312           );
5313
5314   minimum
5315       The "minimum" parameter is used to set the lower limiting value when
5316       the "criteria" is either 'between' or 'not between':
5317
5318           validate => 'integer',
5319           criteria => 'between',
5320           minimum  => 1,
5321           maximum  => 100,
5322
5323   maximum
5324       The "maximum" parameter is used to set the upper limiting value when
5325       the "criteria" is either 'between' or 'not between'. See the previous
5326       example.
5327
5328   type => 'date'
5329       The "date" type is the same as the "cell" type and uses the same
5330       criteria and values. However it allows the "value", "minimum" and
5331       "maximum" properties to be specified in the ISO8601
5332       "yyyy-mm-ddThh:mm:ss.sss" date format which is detailed in the
5333       "write_date_time()" method.
5334
5335           $worksheet->conditional_formatting( 'A1:A4',
5336               {
5337                   type     => 'date',
5338                   criteria => 'greater than',
5339                   value    => '2011-01-01T',
5340                   format   => $format,
5341               }
5342           );
5343
5344   type => 'time_period'
5345       The "time_period" type is used to specify Excel's "Dates Occurring"
5346       style conditional format.
5347
5348           $worksheet->conditional_formatting( 'A1:A4',
5349               {
5350                   type     => 'time_period',
5351                   criteria => 'yesterday',
5352                   format   => $format,
5353               }
5354           );
5355
5356       The period is set in the "criteria" and can have one of the following
5357       values:
5358
5359               criteria => 'yesterday',
5360               criteria => 'today',
5361               criteria => 'last 7 days',
5362               criteria => 'last week',
5363               criteria => 'this week',
5364               criteria => 'next week',
5365               criteria => 'last month',
5366               criteria => 'this month',
5367               criteria => 'next month'
5368
5369   type => 'text'
5370       The "text" type is used to specify Excel's "Specific Text" style
5371       conditional format. It is used to do simple string matching using the
5372       "criteria" and "value" parameters:
5373
5374           $worksheet->conditional_formatting( 'A1:A4',
5375               {
5376                   type     => 'text',
5377                   criteria => 'containing',
5378                   value    => 'foo',
5379                   format   => $format,
5380               }
5381           );
5382
5383       The "criteria" can have one of the following values:
5384
5385           criteria => 'containing',
5386           criteria => 'not containing',
5387           criteria => 'begins with',
5388           criteria => 'ends with',
5389
5390       The "value" parameter should be a string or single character.
5391
5392   type => 'average'
5393       The "average" type is used to specify Excel's "Average" style
5394       conditional format.
5395
5396           $worksheet->conditional_formatting( 'A1:A4',
5397               {
5398                   type     => 'average',
5399                   criteria => 'above',
5400                   format   => $format,
5401               }
5402           );
5403
5404       The type of average for the conditional format range is specified by
5405       the "criteria":
5406
5407           criteria => 'above',
5408           criteria => 'below',
5409           criteria => 'equal or above',
5410           criteria => 'equal or below',
5411           criteria => '1 std dev above',
5412           criteria => '1 std dev below',
5413           criteria => '2 std dev above',
5414           criteria => '2 std dev below',
5415           criteria => '3 std dev above',
5416           criteria => '3 std dev below',
5417
5418   type => 'duplicate'
5419       The "duplicate" type is used to highlight duplicate cells in a range:
5420
5421           $worksheet->conditional_formatting( 'A1:A4',
5422               {
5423                   type     => 'duplicate',
5424                   format   => $format,
5425               }
5426           );
5427
5428   type => 'unique'
5429       The "unique" type is used to highlight unique cells in a range:
5430
5431           $worksheet->conditional_formatting( 'A1:A4',
5432               {
5433                   type     => 'unique',
5434                   format   => $format,
5435               }
5436           );
5437
5438   type => 'top'
5439       The "top" type is used to specify the top "n" values by number or
5440       percentage in a range:
5441
5442           $worksheet->conditional_formatting( 'A1:A4',
5443               {
5444                   type     => 'top',
5445                   value    => 10,
5446                   format   => $format,
5447               }
5448           );
5449
5450       The "criteria" can be used to indicate that a percentage condition is
5451       required:
5452
5453           $worksheet->conditional_formatting( 'A1:A4',
5454               {
5455                   type     => 'top',
5456                   value    => 10,
5457                   criteria => '%',
5458                   format   => $format,
5459               }
5460           );
5461
5462   type => 'bottom'
5463       The "bottom" type is used to specify the bottom "n" values by number or
5464       percentage in a range.
5465
5466       It takes the same parameters as "top", see above.
5467
5468   type => 'blanks'
5469       The "blanks" type is used to highlight blank cells in a range:
5470
5471           $worksheet->conditional_formatting( 'A1:A4',
5472               {
5473                   type     => 'blanks',
5474                   format   => $format,
5475               }
5476           );
5477
5478   type => 'no_blanks'
5479       The "no_blanks" type is used to highlight non blank cells in a range:
5480
5481           $worksheet->conditional_formatting( 'A1:A4',
5482               {
5483                   type     => 'no_blanks',
5484                   format   => $format,
5485               }
5486           );
5487
5488   type => 'errors'
5489       The "errors" type is used to highlight error cells in a range:
5490
5491           $worksheet->conditional_formatting( 'A1:A4',
5492               {
5493                   type     => 'errors',
5494                   format   => $format,
5495               }
5496           );
5497
5498   type => 'no_errors'
5499       The "no_errors" type is used to highlight non error cells in a range:
5500
5501           $worksheet->conditional_formatting( 'A1:A4',
5502               {
5503                   type     => 'no_errors',
5504                   format   => $format,
5505               }
5506           );
5507
5508   type => 'formula'
5509       The "formula" type is used to specify a conditional format based on a
5510       user defined formula:
5511
5512           $worksheet->conditional_formatting( 'A1:A4',
5513               {
5514                   type     => 'formula',
5515                   criteria => '=$A$1 > 5',
5516                   format   => $format,
5517               }
5518           );
5519
5520       The formula is specified in the "criteria".
5521
5522   type => '2_color_scale'
5523       The "2_color_scale" type is used to specify Excel's "2 Color Scale"
5524       style conditional format.
5525
5526           $worksheet->conditional_formatting( 'A1:A12',
5527               {
5528                   type  => '2_color_scale',
5529               }
5530           );
5531
5532       This conditional type can be modified with "min_type", "max_type",
5533       "min_value", "max_value", "min_color" and "max_color", see below.
5534
5535   type => '3_color_scale'
5536       The "3_color_scale" type is used to specify Excel's "3 Color Scale"
5537       style conditional format.
5538
5539           $worksheet->conditional_formatting( 'A1:A12',
5540               {
5541                   type  => '3_color_scale',
5542               }
5543           );
5544
5545       This conditional type can be modified with "min_type", "mid_type",
5546       "max_type", "min_value", "mid_value", "max_value", "min_color",
5547       "mid_color" and "max_color", see below.
5548
5549   type => 'data_bar'
5550       The "data_bar" type is used to specify Excel's "Data Bar" style
5551       conditional format.
5552
5553           $worksheet->conditional_formatting( 'A1:A12',
5554               {
5555                   type  => 'data_bar',
5556               }
5557           );
5558
5559       This data bar conditional type can be modified with the following
5560       parameters, which are explained in the sections below. These properties
5561       were available in the original xlsx file specification used in Excel
5562       2007::
5563
5564           min_type
5565           max_type
5566           min_value
5567           max_value
5568           bar_color
5569           bar_only
5570
5571       In Excel 2010 additional data bar properties were added such as solid
5572       (non-gradient) bars and control over how negative values are displayed.
5573       These properties can be set using the following parameters:
5574
5575           bar_solid
5576           bar_negative_color
5577           bar_border_color
5578           bar_negative_border_color
5579           bar_negative_color_same
5580           bar_negative_border_color_same
5581           bar_no_border
5582           bar_direction
5583           bar_axis_position
5584           bar_axis_color
5585           data_bar_2010
5586
5587       Files that use these Excel 2010 properties can still be opened in Excel
5588       2007 but the data bars will be displayed without them.
5589
5590   type => 'icon_set'
5591       The "icon_set" type is used to specify a conditional format with a set
5592       of icons such as traffic lights or arrows:
5593
5594           $worksheet->conditional_formatting( 'A1:C1',
5595               {
5596                   type         => 'icon_set',
5597                   icon_style   => '3_traffic_lights',
5598               }
5599           );
5600
5601       The icon set style is specified by the "icon_style" parameter. Valid
5602       options are:
5603
5604           3_arrows
5605           3_arrows_gray
5606           3_flags
5607           3_signs
5608           3_symbols
5609           3_symbols_circled
5610           3_traffic_lights
5611           3_traffic_lights_rimmed
5612
5613           4_arrows
5614           4_arrows_gray
5615           4_ratings
5616           4_red_to_black
5617           4_traffic_lights
5618
5619           5_arrows
5620           5_arrows_gray
5621           5_quarters
5622           5_ratings
5623
5624       The criteria, type and value of each icon can be specified using the
5625       "icon" array of hash refs with optional "criteria", "type" and "value"
5626       parameters:
5627
5628           $worksheet->conditional_formatting( 'A1:D1',
5629               {
5630                   type         => 'icon_set',
5631                   icon_style   => '4_red_to_black',
5632                   icons        => [ {criteria => '>',  type => 'number',     value => 90},
5633                                     {criteria => '>=', type => 'percentile', value => 50},
5634                                     {criteria => '>',  type => 'percent',    value => 25},
5635                                   ],
5636               }
5637           );
5638
5639       The "icons criteria" parameter should be either ">=" or ">". The
5640       default "criteria" is ">=".
5641
5642       The "icons type" parameter should be one of the following values:
5643
5644           number
5645           percentile
5646           percent
5647           formula
5648
5649       The default "type" is "percent".
5650
5651       The "icons value" parameter can be a value or formula:
5652
5653           $worksheet->conditional_formatting( 'A1:D1',
5654               {
5655                   type         => 'icon_set',
5656                   icon_style   => '4_red_to_black',
5657                   icons        => [ {value => 90},
5658                                     {value => 50},
5659                                     {value => 25},
5660                                   ],
5661               }
5662           );
5663
5664       Note: The "icons" parameters should start with the highest value and
5665       with each subsequent one being lower. The default "value" is "(n * 100)
5666       / number_of_icons". The lowest number icon in an icon set has
5667       properties defined by Excel. Therefore in a "n" icon set, there is no
5668       "n-1" hash of parameters.
5669
5670       The order of the icons can be reversed using the "reverse_icons"
5671       parameter:
5672
5673           $worksheet->conditional_formatting( 'A1:C1',
5674               {
5675                   type          => 'icon_set',
5676                   icon_style    => '3_arrows',
5677                   reverse_icons => 1,
5678               }
5679           );
5680
5681       The icons can be displayed without the cell value using the
5682       "icons_only" parameter:
5683
5684           $worksheet->conditional_formatting( 'A1:C1',
5685               {
5686                   type         => 'icon_set',
5687                   icon_style   => '3_flags',
5688                   icons_only   => 1,
5689               }
5690           );
5691
5692   min_type, mid_type, max_type
5693       The "min_type" and "max_type" properties are available when the
5694       conditional formatting type is "2_color_scale", "3_color_scale" or
5695       "data_bar". The "mid_type" is available for "3_color_scale". The
5696       properties are used as follows:
5697
5698           $worksheet->conditional_formatting( 'A1:A12',
5699               {
5700                   type      => '2_color_scale',
5701                   min_type  => 'percent',
5702                   max_type  => 'percent',
5703               }
5704           );
5705
5706       The available min/mid/max types are:
5707
5708           min        (for min_type only)
5709           num
5710           percent
5711           percentile
5712           formula
5713           max        (for max_type only)
5714
5715   min_value, mid_value, max_value
5716       The "min_value" and "max_value" properties are available when the
5717       conditional formatting type is "2_color_scale", "3_color_scale" or
5718       "data_bar". The "mid_value" is available for "3_color_scale". The
5719       properties are used as follows:
5720
5721           $worksheet->conditional_formatting( 'A1:A12',
5722               {
5723                   type       => '2_color_scale',
5724                   min_value  => 10,
5725                   max_value  => 90,
5726               }
5727           );
5728
5729   min_color, mid_color,  max_color, bar_color
5730       The "min_color" and "max_color" properties are available when the
5731       conditional formatting type is "2_color_scale", "3_color_scale" or
5732       "data_bar". The "mid_color" is available for "3_color_scale". The
5733       properties are used as follows:
5734
5735           $worksheet->conditional_formatting( 'A1:A12',
5736               {
5737                   type      => '2_color_scale',
5738                   min_color => "#C5D9F1",
5739                   max_color => "#538ED5",
5740               }
5741           );
5742
5743       The color can be specified as an Excel::Writer::XLSX color index or,
5744       more usefully, as a HTML style RGB hex number, as shown above.
5745
5746   bar_only
5747       The "bar_only" parameter property displays a bar data but not the data
5748       in the cells:
5749
5750           $worksheet->conditional_formatting( 'D3:D14',
5751               {
5752                   type     => 'data_bar',
5753                   bar_only => 1
5754               }
5755           );
5756
5757   bar_solid
5758       The "bar_solid" parameter turns on a solid (non-gradient) fill for data
5759       bars:
5760
5761           $worksheet->conditional_formatting( 'H3:H14',
5762               {
5763                   type      => 'data_bar',
5764                   bar_solid => 1
5765               }
5766           );
5767
5768       Note, this property is only visible in Excel 2010 and later.
5769
5770   bar_negative_color
5771       The "bar_negative_color" parameter is used to set the color fill for
5772       the negative portion of a data bar.
5773
5774       The color can be specified as an Excel::Writer::XLSX color index or as
5775       a HTML style RGB hex number, as shown in the other examples.
5776
5777       Note, this property is only visible in Excel 2010 and later.
5778
5779   bar_border_color
5780       The "bar_border_color" parameter is used to set the border color of a
5781       data bar.
5782
5783       The color can be specified as an Excel::Writer::XLSX color index or as
5784       a HTML style RGB hex number, as shown in the other examples.
5785
5786       Note, this property is only visible in Excel 2010 and later.
5787
5788   bar_negative_border_color
5789       The "bar_negative_border_color" parameter is used to set the border
5790       color of the negative portion of a data bar.
5791
5792       The color can be specified as an Excel::Writer::XLSX color index or as
5793       a HTML style RGB hex number, as shown in the other examples.
5794
5795       Note, this property is only visible in Excel 2010 and later.
5796
5797   bar_negative_color_same
5798       The "bar_negative_color_same" parameter sets the fill color for the
5799       negative portion of a data bar to be the same as the fill color for the
5800       positive portion of the data bar:
5801
5802           $worksheet->conditional_formatting( 'N3:N14',
5803               {
5804                   type                           => 'data_bar',
5805                   bar_negative_color_same        => 1,
5806                   bar_negative_border_color_same => 1
5807               }
5808           );
5809
5810       Note, this property is only visible in Excel 2010 and later.
5811
5812   bar_negative_border_color_same
5813       The "bar_negative_border_color_same" parameter sets the border color
5814       for the negative portion of a data bar to be the same as the border
5815       color for the positive portion of the data bar.
5816
5817       Note, this property is only visible in Excel 2010 and later.
5818
5819   bar_no_border
5820       The "bar_no_border" parameter turns off the border of a data bar.
5821
5822       Note, this property is only visible in Excel 2010 and later, however
5823       the default in Excel 2007 is not to have a border.
5824
5825   bar_direction
5826       The "bar_direction" parameter sets the direction for data bars. This
5827       property can be either "left" for left-to-right or "right" for right-
5828       to-left. If the property isn't set then Excel will adjust the position
5829       automatically based on the context:
5830
5831           $worksheet->conditional_formatting( 'J3:J14',
5832               {
5833                   type          => 'data_bar',
5834                   bar_direction => 'right'
5835               }
5836           );
5837
5838       Note, this property is only visible in Excel 2010 and later.
5839
5840   bar_axis_position
5841       The "bar_axis_position" parameter sets the position within the cells
5842       for the axis that is shown in data bars when there are negative values
5843       to display. The property can be either "middle" or "none". If the
5844       property isn't set then Excel will position the axis based on the range
5845       of positive and negative values.
5846
5847       Note, this property is only visible in Excel 2010 and later.
5848
5849   bar_axis_color
5850       The "bar_axis_color" parameter sets the color for the axis that is
5851       shown in data bars when there are negative values to display.
5852
5853       The color can be specified as an Excel::Writer::XLSX color index or as
5854       a HTML style RGB hex number, as shown in the other examples.
5855
5856       Note, this property is only visible in Excel 2010 and later.
5857
5858   data_bar_2010
5859       The "data_bar_2010" parameter sets Excel 2010 style data bars even when
5860       Excel 2010 specific properties aren't used. This can be used to create
5861       consistency across all the data bar formatting in a worksheet:
5862
5863           $worksheet->conditional_formatting( 'L3:L14',
5864               {
5865                   type          => 'data_bar',
5866                   data_bar_2010 => 1
5867               }
5868           );
5869
5870       Note, this property is only visible in Excel 2010 and later.
5871
5872   stop_if_true
5873       The "stop_if_true" parameter, if set to a true value, will enable the
5874       "stop if true" feature on the conditional formatting rule, so that
5875       subsequent rules are not examined for any cell on which the conditions
5876       for this rule are met.
5877
5878   Conditional Formatting Examples
5879       Example 1. Highlight cells greater than an integer value.
5880
5881           $worksheet->conditional_formatting( 'A1:F10',
5882               {
5883                   type     => 'cell',
5884                   criteria => 'greater than',
5885                   value    => 5,
5886                   format   => $format,
5887               }
5888           );
5889
5890       Example 2. Highlight cells greater than a value in a reference cell.
5891
5892           $worksheet->conditional_formatting( 'A1:F10',
5893               {
5894                   type     => 'cell',
5895                   criteria => 'greater than',
5896                   value    => '$H$1',
5897                   format   => $format,
5898               }
5899           );
5900
5901       Example 3. Highlight cells greater than a certain date:
5902
5903           $worksheet->conditional_formatting( 'A1:F10',
5904               {
5905                   type     => 'date',
5906                   criteria => 'greater than',
5907                   value    => '2011-01-01T',
5908                   format   => $format,
5909               }
5910           );
5911
5912       Example 4. Highlight cells with a date in the last seven days:
5913
5914           $worksheet->conditional_formatting( 'A1:F10',
5915               {
5916                   type     => 'time_period',
5917                   criteria => 'last 7 days',
5918                   format   => $format,
5919               }
5920           );
5921
5922       Example 5. Highlight cells with strings starting with the letter "b":
5923
5924           $worksheet->conditional_formatting( 'A1:F10',
5925               {
5926                   type     => 'text',
5927                   criteria => 'begins with',
5928                   value    => 'b',
5929                   format   => $format,
5930               }
5931           );
5932
5933       Example 6. Highlight cells that are 1 std deviation above the average
5934       for the range:
5935
5936           $worksheet->conditional_formatting( 'A1:F10',
5937               {
5938                   type     => 'average',
5939                   format   => $format,
5940               }
5941           );
5942
5943       Example 7. Highlight duplicate cells in a range:
5944
5945           $worksheet->conditional_formatting( 'A1:F10',
5946               {
5947                   type     => 'duplicate',
5948                   format   => $format,
5949               }
5950           );
5951
5952       Example 8. Highlight unique cells in a range.
5953
5954           $worksheet->conditional_formatting( 'A1:F10',
5955               {
5956                   type     => 'unique',
5957                   format   => $format,
5958               }
5959           );
5960
5961       Example 9. Highlight the top 10 cells.
5962
5963           $worksheet->conditional_formatting( 'A1:F10',
5964               {
5965                   type     => 'top',
5966                   value    => 10,
5967                   format   => $format,
5968               }
5969           );
5970
5971       Example 10. Highlight blank cells.
5972
5973           $worksheet->conditional_formatting( 'A1:F10',
5974               {
5975                   type     => 'blanks',
5976                   format   => $format,
5977               }
5978           );
5979
5980       Example 11. Set traffic light icons in 3 cells:
5981
5982           $worksheet->conditional_formatting( 'A1:C1',
5983               {
5984                   type         => 'icon_set',
5985                   icon_style   => '3_traffic_lights',
5986               }
5987           );
5988
5989       See also the "conditional_format.pl" example program in "EXAMPLES".
5990

SPARKLINES IN EXCEL

5992       Sparklines are a feature of Excel 2010+ which allows you to add small
5993       charts to worksheet cells. These are useful for showing visual trends
5994       in data in a compact format.
5995
5996       In Excel::Writer::XLSX Sparklines can be added to cells using the
5997       "add_sparkline()" worksheet method:
5998
5999           $worksheet->add_sparkline(
6000               {
6001                   location => 'F2',
6002                   range    => 'Sheet1!A2:E2',
6003                   type     => 'column',
6004                   style    => 12,
6005               }
6006           );
6007
6008       Note: Sparklines are a feature of Excel 2010+ only. You can write them
6009       to an XLSX file that can be read by Excel 2007 but they won't be
6010       displayed.
6011
6012   add_sparkline( { parameter => 'value', ... } )
6013       The "add_sparkline()" worksheet method is used to add sparklines to a
6014       cell or a range of cells.
6015
6016       The parameters to "add_sparkline()" must be passed in a hash ref. The
6017       main sparkline parameters are:
6018
6019           location        (required)
6020           range           (required)
6021           type
6022           style
6023
6024           markers
6025           negative_points
6026           axis
6027           reverse
6028
6029       Other, less commonly used parameters are:
6030
6031           high_point
6032           low_point
6033           first_point
6034           last_point
6035           max
6036           min
6037           empty_cells
6038           show_hidden
6039           date_axis
6040           weight
6041
6042           series_color
6043           negative_color
6044           markers_color
6045           first_color
6046           last_color
6047           high_color
6048           low_color
6049
6050       These parameters are explained in the sections below:
6051
6052   location
6053       This is the cell where the sparkline will be displayed:
6054
6055           location => 'F1'
6056
6057       The "location" should be a single cell. (For multiple cells see
6058       "Grouped Sparklines" below).
6059
6060       To specify the location in row-column notation use the
6061       "xl_rowcol_to_cell()" function from the Excel::Writer::XLSX::Utility
6062       module.
6063
6064           use Excel::Writer::XLSX::Utility ':rowcol';
6065           ...
6066           location => xl_rowcol_to_cell( 0, 5 ), # F1
6067
6068   range
6069       This specifies the cell data range that the sparkline will plot:
6070
6071           $worksheet->add_sparkline(
6072               {
6073                   location => 'F1',
6074                   range    => 'A1:E1',
6075               }
6076           );
6077
6078       The "range" should be a 2D array. (For 3D arrays of cells see "Grouped
6079       Sparklines" below).
6080
6081       If "range" is not on the same worksheet you can specify its location
6082       using the usual Excel notation:
6083
6084                   range => 'Sheet1!A1:E1',
6085
6086       If the worksheet contains spaces or special characters you should quote
6087       the worksheet name in the same way that Excel does:
6088
6089                   range => q('Monthly Data'!A1:E1),
6090
6091       To specify the location in row-column notation use the "xl_range()" or
6092       "xl_range_formula()" functions from the Excel::Writer::XLSX::Utility
6093       module.
6094
6095           use Excel::Writer::XLSX::Utility ':rowcol';
6096           ...
6097           range => xl_range( 1, 1,  0, 4 ),                   # 'A1:E1'
6098           range => xl_range_formula( 'Sheet1', 0, 0,  0, 4 ), # 'Sheet1!A2:E2'
6099
6100   type
6101       Specifies the type of sparkline. There are 3 available sparkline types:
6102
6103           line    (default)
6104           column
6105           win_loss
6106
6107       For example:
6108
6109           {
6110               location => 'F1',
6111               range    => 'A1:E1',
6112               type     => 'column',
6113           }
6114
6115   style
6116       Excel provides 36 built-in Sparkline styles in 6 groups of 6. The
6117       "style" parameter can be used to replicate these and should be a
6118       corresponding number from 1 .. 36.
6119
6120           {
6121               location => 'A14',
6122               range    => 'Sheet2!A2:J2',
6123               style    => 3,
6124           }
6125
6126       The style number starts in the top left of the style grid and runs left
6127       to right. The default style is 1. It is possible to override colour
6128       elements of the sparklines using the *_color parameters below.
6129
6130   markers
6131       Turn on the markers for "line" style sparklines.
6132
6133           {
6134               location => 'A6',
6135               range    => 'Sheet2!A1:J1',
6136               markers  => 1,
6137           }
6138
6139       Markers aren't shown in Excel for "column" and "win_loss" sparklines.
6140
6141   negative_points
6142       Highlight negative values in a sparkline range. This is usually
6143       required with "win_loss" sparklines.
6144
6145           {
6146               location        => 'A21',
6147               range           => 'Sheet2!A3:J3',
6148               type            => 'win_loss',
6149               negative_points => 1,
6150           }
6151
6152   axis
6153       Display a horizontal axis in the sparkline:
6154
6155           {
6156               location => 'A10',
6157               range    => 'Sheet2!A1:J1',
6158               axis     => 1,
6159           }
6160
6161   reverse
6162       Plot the data from right-to-left instead of the default left-to-right:
6163
6164           {
6165               location => 'A24',
6166               range    => 'Sheet2!A4:J4',
6167               type     => 'column',
6168               reverse  => 1,
6169           }
6170
6171   weight
6172       Adjust the default line weight (thickness) for "line" style sparklines.
6173
6174            weight => 0.25,
6175
6176       The weight value should be one of the following values allowed by
6177       Excel:
6178
6179           0.25  0.5   0.75
6180           1     1.25
6181           2.25
6182           3
6183           4.25
6184           6
6185
6186   high_point, low_point, first_point, last_point
6187       Highlight points in a sparkline range.
6188
6189               high_point  => 1,
6190               low_point   => 1,
6191               first_point => 1,
6192               last_point  => 1,
6193
6194   max, min
6195       Specify the maximum and minimum vertical axis values:
6196
6197               max         => 0.5,
6198               min         => -0.5,
6199
6200       As a special case you can set the maximum and minimum to be for a group
6201       of sparklines rather than one:
6202
6203               max         => 'group',
6204
6205       See "Grouped Sparklines" below.
6206
6207   empty_cells
6208       Define how empty cells are handled in a sparkline.
6209
6210           empty_cells => 'zero',
6211
6212       The available options are:
6213
6214           gaps   : show empty cells as gaps (the default).
6215           zero   : plot empty cells as 0.
6216           connect: Connect points with a line ("line" type  sparklines only).
6217
6218   show_hidden
6219       Plot data in hidden rows and columns:
6220
6221           show_hidden => 1,
6222
6223       Note, this option is off by default.
6224
6225   date_axis
6226       Specify an alternative date axis for the sparkline. This is useful if
6227       the data being plotted isn't at fixed width intervals:
6228
6229           {
6230               location  => 'F3',
6231               range     => 'A3:E3',
6232               date_axis => 'A4:E4',
6233           }
6234
6235       The number of cells in the date range should correspond to the number
6236       of cells in the data range.
6237
6238   series_color
6239       It is possible to override the colour of a sparkline style using the
6240       following parameters:
6241
6242           series_color
6243           negative_color
6244           markers_color
6245           first_color
6246           last_color
6247           high_color
6248           low_color
6249
6250       The color should be specified as a HTML style "#rrggbb" hex value:
6251
6252           {
6253               location     => 'A18',
6254               range        => 'Sheet2!A2:J2',
6255               type         => 'column',
6256               series_color => '#E965E0',
6257           }
6258
6259   Grouped Sparklines
6260       The "add_sparkline()" worksheet method can be used multiple times to
6261       write as many sparklines as are required in a worksheet.
6262
6263       However, it is sometimes necessary to group contiguous sparklines so
6264       that changes that are applied to one are applied to all. In Excel this
6265       is achieved by selecting a 3D range of cells for the data "range" and a
6266       2D range of cells for the "location".
6267
6268       In Excel::Writer::XLSX, you can simulate this by passing an array refs
6269       of values to "location" and "range":
6270
6271           {
6272               location => [ 'A27',          'A28',          'A29'          ],
6273               range    => [ 'Sheet2!A5:J5', 'Sheet2!A6:J6', 'Sheet2!A7:J7' ],
6274               markers  => 1,
6275           }
6276
6277   Sparkline examples
6278       See the "sparklines1.pl" and "sparklines2.pl" example programs in the
6279       "examples" directory of the distro.
6280

TABLES IN EXCEL

6282       Tables in Excel are a way of grouping a range of cells into a single
6283       entity that has common formatting or that can be referenced from
6284       formulas. Tables can have column headers, autofilters, total rows,
6285       column formulas and default formatting.
6286
6287       For more information see "An Overview of Excel Tables"
6288       <http://office.microsoft.com/en-us/excel-help/overview-of-excel-tables-HA010048546.aspx>.
6289
6290       Note, tables don't work in Excel::Writer::XLSX when
6291       "set_optimization()" mode in on.
6292
6293   add_table( $row1, $col1, $row2, $col2, { parameter => 'value', ... })
6294       Tables are added to a worksheet using the "add_table()" method:
6295
6296           $worksheet->add_table( 'B3:F7', { %parameters } );
6297
6298       The data range can be specified in 'A1' or 'row/col' notation (see also
6299       the note about "Cell notation" for more information):
6300
6301           $worksheet->add_table( 'B3:F7' );
6302           # Same as:
6303           $worksheet->add_table(  2, 1, 6, 5 );
6304
6305       The last parameter in "add_table()" should be a hash ref containing the
6306       parameters that describe the table options and data. The available
6307       parameters are:
6308
6309               data
6310               autofilter
6311               header_row
6312               banded_columns
6313               banded_rows
6314               first_column
6315               last_column
6316               style
6317               total_row
6318               columns
6319               name
6320
6321       The table parameters are detailed below. There are no required
6322       parameters and the hash ref isn't required if no options are specified.
6323
6324   data
6325       The "data" parameter can be used to specify the data in the cells of
6326       the table.
6327
6328           my $data = [
6329               [ 'Apples',  10000, 5000, 8000, 6000 ],
6330               [ 'Pears',   2000,  3000, 4000, 5000 ],
6331               [ 'Bananas', 6000,  6000, 6500, 6000 ],
6332               [ 'Oranges', 500,   300,  200,  700 ],
6333
6334           ];
6335
6336           $worksheet->add_table( 'B3:F7', { data => $data } );
6337
6338       Table data can also be written separately, as an array or individual
6339       cells.
6340
6341           # These two statements are the same as the single statement above.
6342           $worksheet->add_table( 'B3:F7' );
6343           $worksheet->write_col( 'B4', $data );
6344
6345       Writing the cell data separately is occasionally required when you need
6346       to control the "write_*()" method used to populate the cells or if you
6347       wish to tweak the cell formatting.
6348
6349       The "data" structure should be an array ref of array refs holding row
6350       data as shown above.
6351
6352   header_row
6353       The "header_row" parameter can be used to turn on or off the header row
6354       in the table. It is on by default.
6355
6356           $worksheet->add_table( 'B4:F7', { header_row => 0 } ); # Turn header off.
6357
6358       The header row will contain default captions such as "Column 1",
6359       "Column 2",  etc. These captions can be overridden using the "columns"
6360       parameter below.
6361
6362   autofilter
6363       The "autofilter" parameter can be used to turn on or off the autofilter
6364       in the header row. It is on by default.
6365
6366           $worksheet->add_table( 'B3:F7', { autofilter => 0 } ); # Turn autofilter off.
6367
6368       The "autofilter" is only shown if the "header_row" is on. Filters
6369       within the table are not supported.
6370
6371   banded_rows
6372       The "banded_rows" parameter can be used to used to create rows of
6373       alternating colour in the table. It is on by default.
6374
6375           $worksheet->add_table( 'B3:F7', { banded_rows => 0 } );
6376
6377   banded_columns
6378       The "banded_columns" parameter can be used to used to create columns of
6379       alternating colour in the table. It is off by default.
6380
6381           $worksheet->add_table( 'B3:F7', { banded_columns => 1 } );
6382
6383   first_column
6384       The "first_column" parameter can be used to highlight the first column
6385       of the table. The type of highlighting will depend on the "style" of
6386       the table. It may be bold text or a different colour. It is off by
6387       default.
6388
6389           $worksheet->add_table( 'B3:F7', { first_column => 1 } );
6390
6391   last_column
6392       The "last_column" parameter can be used to highlight the last column of
6393       the table. The type of highlighting will depend on the "style" of the
6394       table. It may be bold text or a different colour. It is off by default.
6395
6396           $worksheet->add_table( 'B3:F7', { last_column => 1 } );
6397
6398   style
6399       The "style" parameter can be used to set the style of the table.
6400       Standard Excel table format names should be used (with matching
6401       capitalisation):
6402
6403           $worksheet11->add_table(
6404               'B3:F7',
6405               {
6406                   data      => $data,
6407                   style     => 'Table Style Light 11',
6408               }
6409           );
6410
6411       The default table style is 'Table Style Medium 9'.
6412
6413       You can also turn the table style off by setting it to 'None':
6414
6415           $worksheet11->add_table( 'B3:F7', { style => 'None' } );
6416
6417   name
6418       By default tables are named "Table1", "Table2", etc. The "name"
6419       parameter can be used to set the name of the table:
6420
6421           $worksheet->add_table( 'B3:F7', { name => 'SalesData' } );
6422
6423       If you override the table name you must ensure that it doesn't clash
6424       with an existing table name and that it follows Excel's requirements
6425       for table names
6426       <http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010147120.aspx#BMsyntax_rules_for_names>.
6427
6428       If you need to know the name of the table, for example to use it in a
6429       formula, you can get it as follows:
6430
6431           my $table      = $worksheet2->add_table( 'B3:F7' );
6432           my $table_name = $table->{_name};
6433
6434   total_row
6435       The "total_row" parameter can be used to turn on the total row in the
6436       last row of a table. It is distinguished from the other rows by a
6437       different formatting and also with dropdown "SUBTOTAL" functions.
6438
6439           $worksheet->add_table( 'B3:F7', { total_row => 1 } );
6440
6441       The default total row doesn't have any captions or functions. These
6442       must by specified via the "columns" parameter below.
6443
6444   columns
6445       The "columns" parameter can be used to set properties for columns
6446       within the table.
6447
6448       The sub-properties that can be set are:
6449
6450           header
6451           formula
6452           total_string
6453           total_function
6454           total_value
6455           format
6456           header_format
6457
6458       The column data must be specified as an array ref of hash refs. For
6459       example to override the default 'Column n' style table headers:
6460
6461           $worksheet->add_table(
6462               'B3:F7',
6463               {
6464                   data    => $data,
6465                   columns => [
6466                       { header => 'Product' },
6467                       { header => 'Quarter 1' },
6468                       { header => 'Quarter 2' },
6469                       { header => 'Quarter 3' },
6470                       { header => 'Quarter 4' },
6471                   ]
6472               }
6473           );
6474
6475       If you don't wish to specify properties for a specific column you pass
6476       an empty hash ref and the defaults will be applied:
6477
6478                   ...
6479                   columns => [
6480                       { header => 'Product' },
6481                       { header => 'Quarter 1' },
6482                       { },                        # Defaults to 'Column 3'.
6483                       { header => 'Quarter 3' },
6484                       { header => 'Quarter 4' },
6485                   ]
6486                   ...
6487
6488       Column formulas can by applied using the "formula" column property:
6489
6490           $worksheet8->add_table(
6491               'B3:G7',
6492               {
6493                   data    => $data,
6494                   columns => [
6495                       { header => 'Product' },
6496                       { header => 'Quarter 1' },
6497                       { header => 'Quarter 2' },
6498                       { header => 'Quarter 3' },
6499                       { header => 'Quarter 4' },
6500                       {
6501                           header  => 'Year',
6502                           formula => '=SUM(Table8[@[Quarter 1]:[Quarter 4]])'
6503                       },
6504                   ]
6505               }
6506           );
6507
6508       The Excel 2007 "[#This Row]" and Excel 2010 "@" structural references
6509       are supported within the formula.
6510
6511       As stated above the "total_row" table parameter turns on the "Total"
6512       row in the table but it doesn't populate it with any defaults. Total
6513       captions and functions must be specified via the "columns" property and
6514       the "total_string", "total_function" and "total_value" sub properties:
6515
6516           $worksheet10->add_table(
6517               'B3:F8',
6518               {
6519                   data      => $data,
6520                   total_row => 1,
6521                   columns   => [
6522                       { header => 'Product',   total_string   => 'Totals' },
6523                       { header => 'Quarter 1', total_function => 'sum' },
6524                       { header => 'Quarter 2', total_function => 'sum' },
6525                       { header => 'Quarter 3', total_function => 'sum' },
6526                       { header => 'Quarter 4', total_function => 'sum' },
6527                   ]
6528               }
6529           );
6530
6531       The supported totals row "SUBTOTAL" functions are:
6532
6533               average
6534               count_nums
6535               count
6536               max
6537               min
6538               std_dev
6539               sum
6540               var
6541
6542       User defined functions or formulas aren't supported.
6543
6544       It is also possible to set a calculated value for the "total_function"
6545       using the "total_value" sub property. This is only necessary when
6546       creating workbooks for applications that cannot calculate the value of
6547       formulas automatically. This is similar to setting the "value" optional
6548       property in "write_formula()":
6549
6550           $worksheet10->add_table(
6551               'B3:F8',
6552               {
6553                   data      => $data,
6554                   total_row => 1,
6555                   columns   => [
6556                       { total_string   => 'Totals' },
6557                       { total_function => 'sum', total_value => 100 },
6558                       { total_function => 'sum', total_value => 200 },
6559                       { total_function => 'sum', total_value => 100 },
6560                       { total_function => 'sum', total_value => 400 },
6561                   ]
6562               }
6563           );
6564
6565       Formatting can also be applied to columns, to the column data using
6566       "format" and to the header using "header_format":
6567
6568           my $currency_format = $workbook->add_format( num_format => '$#,##0' );
6569
6570           $worksheet->add_table(
6571               'B3:D8',
6572               {
6573                   data      => $data,
6574                   total_row => 1,
6575                   columns   => [
6576                       { header => 'Product', total_string => 'Totals' },
6577                       {
6578                           header         => 'Quarter 1',
6579                           total_function => 'sum',
6580                           format         => $currency_format,
6581                       },
6582                       {
6583                           header         => 'Quarter 2',
6584                           header_format  => $bold,
6585                           total_function => 'sum',
6586                           format         => $currency_format,
6587                       },
6588                   ]
6589               }
6590           );
6591
6592       Standard Excel::Writer::XLSX format objects can be used. However, they
6593       should be limited to numerical formats for the columns and simple
6594       formatting like text wrap for the headers. Overriding other table
6595       formatting may produce inconsistent results.
6596

FORMULAS AND FUNCTIONS IN EXCEL

6598   Introduction
6599       The following is a brief introduction to formulas and functions in
6600       Excel and Excel::Writer::XLSX.
6601
6602       A formula is a string that begins with an equals sign:
6603
6604           '=A1+B1'
6605           '=AVERAGE(1, 2, 3)'
6606
6607       The formula can contain numbers, strings, boolean values, cell
6608       references, cell ranges and functions. Named ranges are not supported.
6609       Formulas should be written as they appear in Excel, that is cells and
6610       functions must be in uppercase.
6611
6612       Cells in Excel are referenced using the A1 notation system where the
6613       column is designated by a letter and the row by a number. Columns range
6614       from A to XFD i.e. 0 to 16384, rows range from 1 to 1048576. The
6615       "Excel::Writer::XLSX::Utility" module that is included in the distro
6616       contains helper functions for dealing with A1 notation, for example:
6617
6618           use Excel::Writer::XLSX::Utility;
6619
6620           ( $row, $col ) = xl_cell_to_rowcol( 'C2' );    # (1, 2)
6621           $str = xl_rowcol_to_cell( 1, 2 );              # C2
6622
6623       The Excel "$" notation in cell references is also supported. This
6624       allows you to specify whether a row or column is relative or absolute.
6625       This only has an effect if the cell is copied. The following examples
6626       show relative and absolute values.
6627
6628           '=A1'   # Column and row are relative
6629           '=$A1'  # Column is absolute and row is relative
6630           '=A$1'  # Column is relative and row is absolute
6631           '=$A$1' # Column and row are absolute
6632
6633       Formulas can also refer to cells in other worksheets of the current
6634       workbook. For example:
6635
6636           '=Sheet2!A1'
6637           '=Sheet2!A1:A5'
6638           '=Sheet2:Sheet3!A1'
6639           '=Sheet2:Sheet3!A1:A5'
6640           q{='Test Data'!A1}
6641           q{='Test Data1:Test Data2'!A1}
6642
6643       The sheet reference and the cell reference are separated by "!" the
6644       exclamation mark symbol. If worksheet names contain spaces, commas or
6645       parentheses then Excel requires that the name is enclosed in single
6646       quotes as shown in the last two examples above. In order to avoid using
6647       a lot of escape characters you can use the quote operator "q{}" to
6648       protect the quotes. See "perlop" in the main Perl documentation. Only
6649       valid sheet names that have been added using the "add_worksheet()"
6650       method can be used in formulas. You cannot reference external
6651       workbooks.
6652
6653       The following table lists the operators that are available in Excel's
6654       formulas. The majority of the operators are the same as Perl's,
6655       differences are indicated:
6656
6657           Arithmetic operators:
6658           =====================
6659           Operator  Meaning                   Example
6660              +      Addition                  1+2
6661              -      Subtraction               2-1
6662              *      Multiplication            2*3
6663              /      Division                  1/4
6664              ^      Exponentiation            2^3      # Equivalent to **
6665              -      Unary minus               -(1+2)
6666              %      Percent (Not modulus)     13%
6667
6668
6669           Comparison operators:
6670           =====================
6671           Operator  Meaning                   Example
6672               =     Equal to                  A1 =  B1 # Equivalent to ==
6673               <>    Not equal to              A1 <> B1 # Equivalent to !=
6674               >     Greater than              A1 >  B1
6675               <     Less than                 A1 <  B1
6676               >=    Greater than or equal to  A1 >= B1
6677               <=    Less than or equal to     A1 <= B1
6678
6679
6680           String operator:
6681           ================
6682           Operator  Meaning                   Example
6683               &     Concatenation             "Hello " & "World!" # [1]
6684
6685
6686           Reference operators:
6687           ====================
6688           Operator  Meaning                   Example
6689               :     Range operator            A1:A4               # [2]
6690               ,     Union operator            SUM(1, 2+2, B3)     # [3]
6691
6692
6693           Notes:
6694           [1]: Equivalent to "Hello " . "World!" in Perl.
6695           [2]: This range is equivalent to cells A1, A2, A3 and A4.
6696           [3]: The comma behaves like the list separator in Perl.
6697
6698       The range and comma operators can have different symbols in non-English
6699       versions of Excel, see below.
6700
6701       For a general introduction to Excel's formulas and an explanation of
6702       the syntax of the function refer to the Excel help files or the
6703       following:
6704       <http://office.microsoft.com/en-us/assistance/CH062528031033.aspx>.
6705
6706       In most cases a formula in Excel can be used directly in the
6707       "write_formula" method. However, there are a few potential issues and
6708       differences that the user should be aware of. These are explained in
6709       the following sections.
6710
6711   Non US Excel functions and syntax
6712       Excel stores formulas in the format of the US English version,
6713       regardless of the language or locale of the end-user's version of
6714       Excel. Therefore all formula function names written using
6715       Excel::Writer::XLSX must be in English:
6716
6717           worksheet->write_formula('A1', '=SUM(1, 2, 3)');   # OK
6718           worksheet->write_formula('A2', '=SOMME(1, 2, 3)'); # French. Error on load.
6719
6720       Also, formulas must be written with the US style separator/range
6721       operator which is a comma (not semi-colon). Therefore a formula with
6722       multiple values should be written as follows:
6723
6724           worksheet->write_formula('A1', '=SUM(1, 2, 3)'); # OK
6725           worksheet->write_formula('A2', '=SUM(1; 2; 3)'); # Semi-colon. Error on load.
6726
6727       If you have a non-English version of Excel you can use the following
6728       multi-lingual Formula Translator
6729       (<http://en.excel-translator.de/language/>) to help you convert the
6730       formula. It can also replace semi-colons with commas.
6731
6732   Formulas added in Excel 2010 and later
6733       Excel 2010 and later added functions which weren't defined in the
6734       original file specification. These functions are referred to by
6735       Microsoft as future functions. Examples of these functions are "ACOT",
6736       "CHISQ.DIST.RT" , "CONFIDENCE.NORM", "STDEV.P", "STDEV.S" and
6737       "WORKDAY.INTL".
6738
6739       When written using "write_formula()" these functions need to be fully
6740       qualified with a "_xlfn." (or other) prefix as they are shown the list
6741       below. For example:
6742
6743           worksheet->write_formula('A1', '=_xlfn.STDEV.S(B1:B10)')
6744
6745       They will appear without the prefix in Excel.
6746
6747       The following list is taken from the MS XLSX extensions documentation
6748       on future functions:
6749       <http://msdn.microsoft.com/en-us/library/dd907480%28v=office.12%29.aspx>:
6750
6751           _xlfn.ACOT
6752           _xlfn.ACOTH
6753           _xlfn.AGGREGATE
6754           _xlfn.ARABIC
6755           _xlfn.BASE
6756           _xlfn.BETA.DIST
6757           _xlfn.BETA.INV
6758           _xlfn.BINOM.DIST
6759           _xlfn.BINOM.DIST.RANGE
6760           _xlfn.BINOM.INV
6761           _xlfn.BITAND
6762           _xlfn.BITLSHIFT
6763           _xlfn.BITOR
6764           _xlfn.BITRSHIFT
6765           _xlfn.BITXOR
6766           _xlfn.CEILING.MATH
6767           _xlfn.CEILING.PRECISE
6768           _xlfn.CHISQ.DIST
6769           _xlfn.CHISQ.DIST.RT
6770           _xlfn.CHISQ.INV
6771           _xlfn.CHISQ.INV.RT
6772           _xlfn.CHISQ.TEST
6773           _xlfn.COMBINA
6774           _xlfn.CONFIDENCE.NORM
6775           _xlfn.CONFIDENCE.T
6776           _xlfn.COT
6777           _xlfn.COTH
6778           _xlfn.COVARIANCE.P
6779           _xlfn.COVARIANCE.S
6780           _xlfn.CSC
6781           _xlfn.CSCH
6782           _xlfn.DAYS
6783           _xlfn.DECIMAL
6784           ECMA.CEILING
6785           _xlfn.ERF.PRECISE
6786           _xlfn.ERFC.PRECISE
6787           _xlfn.EXPON.DIST
6788           _xlfn.F.DIST
6789           _xlfn.F.DIST.RT
6790           _xlfn.F.INV
6791           _xlfn.F.INV.RT
6792           _xlfn.F.TEST
6793           _xlfn.FILTERXML
6794           _xlfn.FLOOR.MATH
6795           _xlfn.FLOOR.PRECISE
6796           _xlfn.FORECAST.ETS
6797           _xlfn.FORECAST.ETS.CONFINT
6798           _xlfn.FORECAST.ETS.SEASONALITY
6799           _xlfn.FORECAST.ETS.STAT
6800           _xlfn.FORECAST.LINEAR
6801           _xlfn.FORMULATEXT
6802           _xlfn.GAMMA
6803           _xlfn.GAMMA.DIST
6804           _xlfn.GAMMA.INV
6805           _xlfn.GAMMALN.PRECISE
6806           _xlfn.GAUSS
6807           _xlfn.HYPGEOM.DIST
6808           _xlfn.IFNA
6809           _xlfn.IMCOSH
6810           _xlfn.IMCOT
6811           _xlfn.IMCSC
6812           _xlfn.IMCSCH
6813           _xlfn.IMSEC
6814           _xlfn.IMSECH
6815           _xlfn.IMSINH
6816           _xlfn.IMTAN
6817           _xlfn.ISFORMULA
6818           ISO.CEILING
6819           _xlfn.ISOWEEKNUM
6820           _xlfn.LOGNORM.DIST
6821           _xlfn.LOGNORM.INV
6822           _xlfn.MODE.MULT
6823           _xlfn.MODE.SNGL
6824           _xlfn.MUNIT
6825           _xlfn.NEGBINOM.DIST
6826           NETWORKDAYS.INTL
6827           _xlfn.NORM.DIST
6828           _xlfn.NORM.INV
6829           _xlfn.NORM.S.DIST
6830           _xlfn.NORM.S.INV
6831           _xlfn.NUMBERVALUE
6832           _xlfn.PDURATION
6833           _xlfn.PERCENTILE.EXC
6834           _xlfn.PERCENTILE.INC
6835           _xlfn.PERCENTRANK.EXC
6836           _xlfn.PERCENTRANK.INC
6837           _xlfn.PERMUTATIONA
6838           _xlfn.PHI
6839           _xlfn.POISSON.DIST
6840           _xlfn.QUARTILE.EXC
6841           _xlfn.QUARTILE.INC
6842           _xlfn.QUERYSTRING
6843           _xlfn.RANK.AVG
6844           _xlfn.RANK.EQ
6845           _xlfn.RRI
6846           _xlfn.SEC
6847           _xlfn.SECH
6848           _xlfn.SHEET
6849           _xlfn.SHEETS
6850           _xlfn.SKEW.P
6851           _xlfn.STDEV.P
6852           _xlfn.STDEV.S
6853           _xlfn.T.DIST
6854           _xlfn.T.DIST.2T
6855           _xlfn.T.DIST.RT
6856           _xlfn.T.INV
6857           _xlfn.T.INV.2T
6858           _xlfn.T.TEST
6859           _xlfn.UNICHAR
6860           _xlfn.UNICODE
6861           _xlfn.VAR.P
6862           _xlfn.VAR.S
6863           _xlfn.WEBSERVICE
6864           _xlfn.WEIBULL.DIST
6865           WORKDAY.INTL
6866           _xlfn.XOR
6867           _xlfn.Z.TEST
6868
6869   Using Tables in Formulas
6870       Worksheet tables can be added with Excel::Writer::XLSX using the
6871       "add_table()" method:
6872
6873           worksheet->add_table('B3:F7', {options});
6874
6875       By default tables are named "Table1", "Table2", etc., in the order that
6876       they are added. However it can also be set by the user using the "name"
6877       parameter:
6878
6879           worksheet->add_table('B3:F7', {'name': 'SalesData'});
6880
6881       If you need to know the name of the table, for example to use it in a
6882       formula, you can get it as follows:
6883
6884           table = worksheet->add_table('B3:F7');
6885           table_name = table->{_name};
6886
6887       When used in a formula a table name such as "TableX" should be referred
6888       to as "TableX[]" (like a Perl array):
6889
6890           worksheet->write_formula('A5', '=VLOOKUP("Sales", Table1[], 2, FALSE');
6891
6892   Dealing with #NAME? errors
6893       If there is an error in the syntax of a formula it is usually displayed
6894       in Excel as "#NAME?". If you encounter an error like this you can debug
6895       it as follows:
6896
6897       1. Ensure the formula is valid in Excel by copying and pasting it into
6898       a cell. Note, this should be done in Excel and not other applications
6899       such as OpenOffice or LibreOffice since they may have slightly
6900       different syntax.
6901       2. Ensure the formula is using comma separators instead of semi-colons,
6902       see "Non US Excel functions and syntax" above.
6903       3. Ensure the formula is in English, see "Non US Excel functions and
6904       syntax" above.
6905       4. Ensure that the formula doesn't contain an Excel 2010+ future
6906       function as listed in "Formulas added in Excel 2010 and later" above.
6907       If it does then ensure that the correct prefix is used.
6908
6909       Finally if you have completed all the previous steps and still get a
6910       "#NAME?" error you can examine a valid Excel file to see what the
6911       correct syntax should be. To do this you should create a valid formula
6912       in Excel and save the file. You can then examine the XML in the
6913       unzipped file.
6914
6915       The following shows how to do that using Linux "unzip" and libxml's
6916       xmllint <http://xmlsoft.org/xmllint.html> to format the XML for
6917       clarity:
6918
6919           $ unzip myfile.xlsx -d myfile
6920           $ xmllint --format myfile/xl/worksheets/sheet1.xml | grep '<f>'
6921
6922                   <f>SUM(1, 2, 3)</f>
6923
6924   Formula Results
6925       Excel::Writer::XLSX doesn't calculate the result of a formula and
6926       instead stores the value 0 as the formula result. It then sets a global
6927       flag in the XLSX file to say that all formulas and functions should be
6928       recalculated when the file is opened.
6929
6930       This is the method recommended in the Excel documentation and in
6931       general it works fine with spreadsheet applications. However,
6932       applications that don't have a facility to calculate formulas will only
6933       display the 0 results. Examples of such applications are Excel Viewer,
6934       PDF Converters, and some mobile device applications.
6935
6936       If required, it is also possible to specify the calculated result of
6937       the formula using the optional last "value" parameter in
6938       "write_formula":
6939
6940           worksheet->write_formula('A1', '=2+2', num_format, 4);
6941
6942       The "value" parameter can be a number, a string, a boolean sting
6943       ('TRUE' or 'FALSE') or one of the following Excel error codes:
6944
6945           #DIV/0!
6946           #N/A
6947           #NAME?
6948           #NULL!
6949           #NUM!
6950           #REF!
6951           #VALUE!
6952
6953       It is also possible to specify the calculated result of an array
6954       formula created with "write_array_formula":
6955
6956           # Specify the result for a single cell range.
6957           worksheet->write_array_formula('A1:A1', '{=SUM(B1:C1*B2:C2)}', format, 2005);
6958
6959       However, using this parameter only writes a single value to the upper
6960       left cell in the result array. For a multi-cell array formula where the
6961       results are required, the other result values can be specified by using
6962       "write_number()" to write to the appropriate cell:
6963
6964           # Specify the results for a multi cell range.
6965           worksheet->write_array_formula('A1:A3', '{=TREND(C1:C3,B1:B3)}', format, 15);
6966           worksheet->write_number('A2', 12, format);
6967           worksheet->write_number('A3', 14, format);
6968

WORKING WITH VBA MACROS

6970       An Excel "xlsm" file is exactly the same as a "xlsx" file except that
6971       is includes an additional "vbaProject.bin" file which contains
6972       functions and/or macros. Excel uses a different extension to
6973       differentiate between the two file formats since files containing
6974       macros are usually subject to additional security checks.
6975
6976       The "vbaProject.bin" file is a binary OLE COM container. This was the
6977       format used in older "xls" versions of Excel prior to Excel 2007.
6978       Unlike all of the other components of an xlsx/xlsm file the data isn't
6979       stored in XML format. Instead the functions and macros as stored as
6980       pre-parsed binary format. As such it wouldn't be feasible to define
6981       macros and create a "vbaProject.bin" file from scratch (at least not in
6982       the remaining lifespan and interest levels of the author).
6983
6984       Instead a workaround is used to extract "vbaProject.bin" files from
6985       existing xlsm files and then add these to Excel::Writer::XLSX files.
6986
6987   The extract_vba utility
6988       The "extract_vba" utility is used to extract the "vbaProject.bin"
6989       binary from an Excel 2007+ xlsm file. The utility is included in the
6990       Excel::Writer::XLSX bin directory and is also installed as a standalone
6991       executable file:
6992
6993           $ extract_vba macro_file.xlsm
6994           Extracted: vbaProject.bin
6995
6996   Adding the VBA macros to a Excel::Writer::XLSX file
6997       Once the "vbaProject.bin" file has been extracted it can be added to
6998       the Excel::Writer::XLSX workbook using the "add_vba_project()" method:
6999
7000           $workbook->add_vba_project( './vbaProject.bin' );
7001
7002       If the VBA file contains functions you can then refer to them in
7003       calculations using "write_formula":
7004
7005           $worksheet->write_formula( 'A1', '=MyMortgageCalc(200000, 25)' );
7006
7007       Excel files that contain functions and macros should use an "xlsm"
7008       extension or else Excel will complain and possibly not open the file:
7009
7010           my $workbook  = Excel::Writer::XLSX->new( 'file.xlsm' );
7011
7012       It is also possible to assign a macro to a button that is inserted into
7013       a worksheet using the "insert_button()" method:
7014
7015           my $workbook  = Excel::Writer::XLSX->new( 'file.xlsm' );
7016           ...
7017           $workbook->add_vba_project( './vbaProject.bin' );
7018
7019           $worksheet->insert_button( 'C2', { macro => 'my_macro' } );
7020
7021       It may be necessary to specify a more explicit macro name prefixed by
7022       the workbook VBA name as follows:
7023
7024           $worksheet->insert_button( 'C2', { macro => 'ThisWorkbook.my_macro' } );
7025
7026       See the "macros.pl" from the examples directory for a working example.
7027
7028       Note: Button is the only VBA Control supported by Excel::Writer::XLSX.
7029       Due to the large effort in implementation (1+ man months) it is
7030       unlikely that any other form elements will be added in the future.
7031
7032   Setting the VBA codenames
7033       VBA macros generally refer to workbook and worksheet objects. If the
7034       VBA codenames aren't specified then Excel::Writer::XLSX will use the
7035       Excel defaults of "ThisWorkbook" and "Sheet1", "Sheet2" etc.
7036
7037       If the macro uses other codenames you can set them using the workbook
7038       and worksheet "set_vba_name()" methods as follows:
7039
7040             $workbook->set_vba_name( 'MyWorkbook' );
7041             $worksheet->set_vba_name( 'MySheet' );
7042
7043       You can find the names that are used in the VBA editor or by unzipping
7044       the "xlsm" file and grepping the files. The following shows how to do
7045       that using libxml's xmllint <http://xmlsoft.org/xmllint.html> to format
7046       the XML for clarity:
7047
7048           $ unzip myfile.xlsm -d myfile
7049           $ xmllint --format `find myfile -name "*.xml" | xargs` | grep "Pr.*codeName"
7050
7051             <workbookPr codeName="MyWorkbook" defaultThemeVersion="124226"/>
7052             <sheetPr codeName="MySheet"/>
7053
7054       Note: This step is particularly important for macros created with non-
7055       English versions of Excel.
7056
7057   What to do if it doesn't work
7058       This feature should be considered experimental and there is no
7059       guarantee that it will work in all cases. Some effort may be required
7060       and some knowledge of VBA will certainly help. If things don't work out
7061       here are some things to try:
7062
7063       ·   Start with a simple macro file, ensure that it works and then add
7064           complexity.
7065
7066       ·   Try to extract the macros from an Excel 2007 file. The method
7067           should work with macros from later versions (it was also tested
7068           with Excel 2010 macros). However there may be features in the macro
7069           files of more recent version of Excel that aren't backward
7070           compatible.
7071
7072       ·   Check the code names that macros use to refer to the workbook and
7073           worksheets (see the previous section above). In general VBA uses a
7074           code name of "ThisWorkbook" to refer to the current workbook and
7075           the sheet name (such as "Sheet1") to refer to the worksheets. These
7076           are the defaults used by Excel::Writer::XLSX. If the macro uses
7077           other names then you can specify these using the workbook and
7078           worksheet "set_vba_name()" methods:
7079
7080                 $workbook>set_vba_name( 'MyWorkbook' );
7081                 $worksheet->set_vba_name( 'MySheet' );
7082

EXAMPLES

7084       See Excel::Writer::XLSX::Examples for a full list of examples.
7085
7086   Example 1
7087       The following example shows some of the basic features of
7088       Excel::Writer::XLSX.
7089
7090           #!/usr/bin/perl -w
7091
7092           use strict;
7093           use Excel::Writer::XLSX;
7094
7095           # Create a new workbook called simple.xlsx and add a worksheet
7096           my $workbook  = Excel::Writer::XLSX->new( 'simple.xlsx' );
7097           my $worksheet = $workbook->add_worksheet();
7098
7099           # The general syntax is write($row, $column, $token). Note that row and
7100           # column are zero indexed
7101
7102           # Write some text
7103           $worksheet->write( 0, 0, 'Hi Excel!' );
7104
7105
7106           # Write some numbers
7107           $worksheet->write( 2, 0, 3 );
7108           $worksheet->write( 3, 0, 3.00000 );
7109           $worksheet->write( 4, 0, 3.00001 );
7110           $worksheet->write( 5, 0, 3.14159 );
7111
7112
7113           # Write some formulas
7114           $worksheet->write( 7, 0, '=A3 + A6' );
7115           $worksheet->write( 8, 0, '=IF(A5>3,"Yes", "No")' );
7116
7117
7118           # Write a hyperlink
7119           my $hyperlink_format = $workbook->add_format(
7120               color     => 'blue',
7121               underline => 1,
7122           );
7123
7124           $worksheet->write( 10, 0, 'http://www.perl.com/', $hyperlink_format );
7125
7126           $workbook->close();
7127
7128   Example 2
7129       The following is a general example which demonstrates some features of
7130       working with multiple worksheets.
7131
7132           #!/usr/bin/perl -w
7133
7134           use strict;
7135           use Excel::Writer::XLSX;
7136
7137           # Create a new Excel workbook
7138           my $workbook = Excel::Writer::XLSX->new( 'regions.xlsx' );
7139
7140           # Add some worksheets
7141           my $north = $workbook->add_worksheet( 'North' );
7142           my $south = $workbook->add_worksheet( 'South' );
7143           my $east  = $workbook->add_worksheet( 'East' );
7144           my $west  = $workbook->add_worksheet( 'West' );
7145
7146           # Add a Format
7147           my $format = $workbook->add_format();
7148           $format->set_bold();
7149           $format->set_color( 'blue' );
7150
7151           # Add a caption to each worksheet
7152           for my $worksheet ( $workbook->sheets() ) {
7153               $worksheet->write( 0, 0, 'Sales', $format );
7154           }
7155
7156           # Write some data
7157           $north->write( 0, 1, 200000 );
7158           $south->write( 0, 1, 100000 );
7159           $east->write( 0, 1, 150000 );
7160           $west->write( 0, 1, 100000 );
7161
7162           # Set the active worksheet
7163           $south->activate();
7164
7165           # Set the width of the first column
7166           $south->set_column( 0, 0, 20 );
7167
7168           # Set the active cell
7169           $south->set_selection( 0, 1 );
7170
7171           $workbook->close();
7172
7173   Example 3
7174       Example of how to add conditional formatting to an Excel::Writer::XLSX
7175       file. The example below highlights cells that have a value greater than
7176       or equal to 50 in red and cells below that value in green.
7177
7178           #!/usr/bin/perl
7179
7180           use strict;
7181           use warnings;
7182           use Excel::Writer::XLSX;
7183
7184           my $workbook  = Excel::Writer::XLSX->new( 'conditional_format.xlsx' );
7185           my $worksheet = $workbook->add_worksheet();
7186
7187
7188           # This example below highlights cells that have a value greater than or
7189           # equal to 50 in red and cells below that value in green.
7190
7191           # Light red fill with dark red text.
7192           my $format1 = $workbook->add_format(
7193               bg_color => '#FFC7CE',
7194               color    => '#9C0006',
7195
7196           );
7197
7198           # Green fill with dark green text.
7199           my $format2 = $workbook->add_format(
7200               bg_color => '#C6EFCE',
7201               color    => '#006100',
7202
7203           );
7204
7205           # Some sample data to run the conditional formatting against.
7206           my $data = [
7207               [ 34, 72,  38, 30, 75, 48, 75, 66, 84, 86 ],
7208               [ 6,  24,  1,  84, 54, 62, 60, 3,  26, 59 ],
7209               [ 28, 79,  97, 13, 85, 93, 93, 22, 5,  14 ],
7210               [ 27, 71,  40, 17, 18, 79, 90, 93, 29, 47 ],
7211               [ 88, 25,  33, 23, 67, 1,  59, 79, 47, 36 ],
7212               [ 24, 100, 20, 88, 29, 33, 38, 54, 54, 88 ],
7213               [ 6,  57,  88, 28, 10, 26, 37, 7,  41, 48 ],
7214               [ 52, 78,  1,  96, 26, 45, 47, 33, 96, 36 ],
7215               [ 60, 54,  81, 66, 81, 90, 80, 93, 12, 55 ],
7216               [ 70, 5,   46, 14, 71, 19, 66, 36, 41, 21 ],
7217           ];
7218
7219           my $caption = 'Cells with values >= 50 are in light red. '
7220             . 'Values < 50 are in light green';
7221
7222           # Write the data.
7223           $worksheet->write( 'A1', $caption );
7224           $worksheet->write_col( 'B3', $data );
7225
7226           # Write a conditional format over a range.
7227           $worksheet->conditional_formatting( 'B3:K12',
7228               {
7229                   type     => 'cell',
7230                   criteria => '>=',
7231                   value    => 50,
7232                   format   => $format1,
7233               }
7234           );
7235
7236           # Write another conditional format over the same range.
7237           $worksheet->conditional_formatting( 'B3:K12',
7238               {
7239                   type     => 'cell',
7240                   criteria => '<',
7241                   value    => 50,
7242                   format   => $format2,
7243               }
7244           );
7245
7246           $workbook->close();
7247
7248   Example 4
7249       The following is a simple example of using functions.
7250
7251           #!/usr/bin/perl -w
7252
7253           use strict;
7254           use Excel::Writer::XLSX;
7255
7256           # Create a new workbook and add a worksheet
7257           my $workbook  = Excel::Writer::XLSX->new( 'stats.xlsx' );
7258           my $worksheet = $workbook->add_worksheet( 'Test data' );
7259
7260           # Set the column width for columns 1
7261           $worksheet->set_column( 0, 0, 20 );
7262
7263
7264           # Create a format for the headings
7265           my $format = $workbook->add_format();
7266           $format->set_bold();
7267
7268
7269           # Write the sample data
7270           $worksheet->write( 0, 0, 'Sample', $format );
7271           $worksheet->write( 0, 1, 1 );
7272           $worksheet->write( 0, 2, 2 );
7273           $worksheet->write( 0, 3, 3 );
7274           $worksheet->write( 0, 4, 4 );
7275           $worksheet->write( 0, 5, 5 );
7276           $worksheet->write( 0, 6, 6 );
7277           $worksheet->write( 0, 7, 7 );
7278           $worksheet->write( 0, 8, 8 );
7279
7280           $worksheet->write( 1, 0, 'Length', $format );
7281           $worksheet->write( 1, 1, 25.4 );
7282           $worksheet->write( 1, 2, 25.4 );
7283           $worksheet->write( 1, 3, 24.8 );
7284           $worksheet->write( 1, 4, 25.0 );
7285           $worksheet->write( 1, 5, 25.3 );
7286           $worksheet->write( 1, 6, 24.9 );
7287           $worksheet->write( 1, 7, 25.2 );
7288           $worksheet->write( 1, 8, 24.8 );
7289
7290           # Write some statistical functions
7291           $worksheet->write( 4, 0, 'Count', $format );
7292           $worksheet->write( 4, 1, '=COUNT(B1:I1)' );
7293
7294           $worksheet->write( 5, 0, 'Sum', $format );
7295           $worksheet->write( 5, 1, '=SUM(B2:I2)' );
7296
7297           $worksheet->write( 6, 0, 'Average', $format );
7298           $worksheet->write( 6, 1, '=AVERAGE(B2:I2)' );
7299
7300           $worksheet->write( 7, 0, 'Min', $format );
7301           $worksheet->write( 7, 1, '=MIN(B2:I2)' );
7302
7303           $worksheet->write( 8, 0, 'Max', $format );
7304           $worksheet->write( 8, 1, '=MAX(B2:I2)' );
7305
7306           $worksheet->write( 9, 0, 'Standard Deviation', $format );
7307           $worksheet->write( 9, 1, '=STDEV(B2:I2)' );
7308
7309           $worksheet->write( 10, 0, 'Kurtosis', $format );
7310           $worksheet->write( 10, 1, '=KURT(B2:I2)' );
7311
7312           $workbook->close();
7313
7314   Example 5
7315       The following example converts a tab separated file called "tab.txt"
7316       into an Excel file called "tab.xlsx".
7317
7318           #!/usr/bin/perl -w
7319
7320           use strict;
7321           use Excel::Writer::XLSX;
7322
7323           open( TABFILE, 'tab.txt' ) or die "tab.txt: $!";
7324
7325           my $workbook  = Excel::Writer::XLSX->new( 'tab.xlsx' );
7326           my $worksheet = $workbook->add_worksheet();
7327
7328           # Row and column are zero indexed
7329           my $row = 0;
7330
7331           while ( <TABFILE> ) {
7332               chomp;
7333
7334               # Split on single tab
7335               my @fields = split( '\t', $_ );
7336
7337               my $col = 0;
7338               for my $token ( @fields ) {
7339                   $worksheet->write( $row, $col, $token );
7340                   $col++;
7341               }
7342               $row++;
7343           }
7344
7345           $workbook->close();
7346
7347       NOTE: This is a simple conversion program for illustrative purposes
7348       only. For converting a CSV or Tab separated or any other type of
7349       delimited text file to Excel I recommend the more rigorous csv2xls
7350       program that is part of H.Merijn Brand's Text::CSV_XS module distro.
7351
7352       See the examples/csv2xls link here:
7353       <http://search.cpan.org/~hmbrand/Text-CSV_XS/MANIFEST>.
7354
7355   Additional Examples
7356       The following is a description of the example files that are provided
7357       in the standard Excel::Writer::XLSX distribution. They demonstrate the
7358       different features and options of the module. See
7359       Excel::Writer::XLSX::Examples for more details.
7360
7361           Getting started
7362           ===============
7363           a_simple.pl             A simple demo of some of the features.
7364           bug_report.pl           A template for submitting bug reports.
7365           demo.pl                 A demo of some of the available features.
7366           formats.pl              All the available formatting on several worksheets.
7367           regions.pl              A simple example of multiple worksheets.
7368           stats.pl                Basic formulas and functions.
7369
7370
7371           Intermediate
7372           ============
7373           autofilter.pl           Examples of worksheet autofilters.
7374           array_formula.pl        Examples of how to write array formulas.
7375           cgi.pl                  A simple CGI program.
7376           chart_area.pl           A demo of area style charts.
7377           chart_bar.pl            A demo of bar (vertical histogram) style charts.
7378           chart_column.pl         A demo of column (histogram) style charts.
7379           chart_line.pl           A demo of line style charts.
7380           chart_pie.pl            A demo of pie style charts.
7381           chart_doughnut.pl       A demo of doughnut style charts.
7382           chart_radar.pl          A demo of radar style charts.
7383           chart_scatter.pl        A demo of scatter style charts.
7384           chart_secondary_axis.pl A demo of a line chart with a secondary axis.
7385           chart_combined.pl       A demo of a combined column and line chart.
7386           chart_pareto.pl         A demo of a combined Pareto chart.
7387           chart_stock.pl          A demo of stock style charts.
7388           chart_data_table.pl     A demo of a chart with a data table on the axis.
7389           chart_data_tools.pl     A demo of charts with data highlighting options.
7390           chart_clustered.pl      A demo of a chart with a clustered axis.
7391           chart_styles.pl         A demo of the available chart styles.
7392           colors.pl               A demo of the colour palette and named colours.
7393           comments1.pl            Add comments to worksheet cells.
7394           comments2.pl            Add comments with advanced options.
7395           conditional_format.pl   Add conditional formats to a range of cells.
7396           data_validate.pl        An example of data validation and dropdown lists.
7397           date_time.pl            Write dates and times with write_date_time().
7398           defined_name.pl         Example of how to create defined names.
7399           diag_border.pl          A simple example of diagonal cell borders.
7400           filehandle.pl           Examples of working with filehandles.
7401           headers.pl              Examples of worksheet headers and footers.
7402           hide_row_col.pl         Example of hiding rows and columns.
7403           hide_sheet.pl           Simple example of hiding a worksheet.
7404           hyperlink1.pl           Shows how to create web hyperlinks.
7405           hyperlink2.pl           Examples of internal and external hyperlinks.
7406           indent.pl               An example of cell indentation.
7407           macros.pl               An example of adding macros from an existing file.
7408           merge1.pl               A simple example of cell merging.
7409           merge2.pl               A simple example of cell merging with formatting.
7410           merge3.pl               Add hyperlinks to merged cells.
7411           merge4.pl               An advanced example of merging with formatting.
7412           merge5.pl               An advanced example of merging with formatting.
7413           merge6.pl               An example of merging with Unicode strings.
7414           mod_perl1.pl            A simple mod_perl 1 program.
7415           mod_perl2.pl            A simple mod_perl 2 program.
7416           panes.pl                An examples of how to create panes.
7417           outline.pl              An example of outlines and grouping.
7418           outline_collapsed.pl    An example of collapsed outlines.
7419           protection.pl           Example of cell locking and formula hiding.
7420           rich_strings.pl         Example of strings with multiple formats.
7421           right_to_left.pl        Change default sheet direction to right to left.
7422           sales.pl                An example of a simple sales spreadsheet.
7423           shape1.pl               Insert shapes in worksheet.
7424           shape2.pl               Insert shapes in worksheet. With properties.
7425           shape3.pl               Insert shapes in worksheet. Scaled.
7426           shape4.pl               Insert shapes in worksheet. With modification.
7427           shape5.pl               Insert shapes in worksheet. With connections.
7428           shape6.pl               Insert shapes in worksheet. With connections.
7429           shape7.pl               Insert shapes in worksheet. One to many connections.
7430           shape8.pl               Insert shapes in worksheet. One to many connections.
7431           shape_all.pl            Demo of all the available shape and connector types.
7432           sparklines1.pl          Simple sparklines demo.
7433           sparklines2.pl          Sparklines demo showing formatting options.
7434           stats_ext.pl            Same as stats.pl with external references.
7435           stocks.pl               Demonstrates conditional formatting.
7436           tab_colors.pl           Example of how to set worksheet tab colours.
7437           tables.pl               Add Excel tables to a worksheet.
7438           write_handler1.pl       Example of extending the write() method. Step 1.
7439           write_handler2.pl       Example of extending the write() method. Step 2.
7440           write_handler3.pl       Example of extending the write() method. Step 3.
7441           write_handler4.pl       Example of extending the write() method. Step 4.
7442           write_to_scalar.pl      Example of writing an Excel file to a Perl scalar.
7443
7444           Unicode
7445           =======
7446           unicode_2022_jp.pl      Japanese: ISO-2022-JP.
7447           unicode_8859_11.pl      Thai:     ISO-8859_11.
7448           unicode_8859_7.pl       Greek:    ISO-8859_7.
7449           unicode_big5.pl         Chinese:  BIG5.
7450           unicode_cp1251.pl       Russian:  CP1251.
7451           unicode_cp1256.pl       Arabic:   CP1256.
7452           unicode_cyrillic.pl     Russian:  Cyrillic.
7453           unicode_koi8r.pl        Russian:  KOI8-R.
7454           unicode_polish_utf8.pl  Polish :  UTF8.
7455           unicode_shift_jis.pl    Japanese: Shift JIS.
7456

LIMITATIONS

7458       The following limits are imposed by Excel 2007+:
7459
7460           Description                                Limit
7461           --------------------------------------     ------
7462           Maximum number of chars in a string        32,767
7463           Maximum number of columns                  16,384
7464           Maximum number of rows                     1,048,576
7465           Maximum chars in a sheet name              31
7466           Maximum chars in a header/footer           254
7467
7468           Maximum characters in hyperlink url (1)    2079
7469           Maximum number of unique hyperlinks (2)    65,530
7470
7471       (1) Versions of Excel prior to Excel 2015 limited hyperlink links and
7472       anchor/locations to 255 characters each. Versions after that support
7473       urls up to 2079 characters. Excel::Writer::XLSX versions >= 1.0.2
7474       support the new longer limit by default.
7475
7476       (2) Per worksheet. Excel allows a greater number of non-unique
7477       hyperlinks if they are contiguous and can be grouped into a single
7478       range. This isn't supported by Excel::Writer::XLSX.
7479

Compatibility with Spreadsheet::WriteExcel

7481       The "Excel::Writer::XLSX" module is a drop-in replacement for
7482       "Spreadsheet::WriteExcel".
7483
7484       It supports all of the features of Spreadsheet::WriteExcel with some
7485       minor differences noted below.
7486
7487           Workbook Methods            Support
7488           ================            ======
7489           new()                       Yes
7490           add_worksheet()             Yes
7491           add_format()                Yes
7492           add_chart()                 Yes
7493           add_shape()                 Yes. Not in Spreadsheet::WriteExcel.
7494           add_vba_project()           Yes. Not in Spreadsheet::WriteExcel.
7495           close()                     Yes
7496           set_properties()            Yes
7497           define_name()               Yes
7498           set_tempdir()               Yes
7499           set_custom_color()          Yes
7500           sheets()                    Yes
7501           set_1904()                  Yes
7502           set_optimization()          Yes. Not required in Spreadsheet::WriteExcel.
7503           add_chart_ext()             Not supported. Not required in Excel::Writer::XLSX.
7504           compatibility_mode()        Deprecated. Not required in Excel::Writer::XLSX.
7505           set_codepage()              Deprecated. Not required in Excel::Writer::XLSX.
7506
7507
7508           Worksheet Methods           Support
7509           =================           =======
7510           write()                     Yes
7511           write_number()              Yes
7512           write_string()              Yes
7513           write_rich_string()         Yes. Not in Spreadsheet::WriteExcel.
7514           write_blank()               Yes
7515           write_row()                 Yes
7516           write_col()                 Yes
7517           write_date_time()           Yes
7518           write_url()                 Yes
7519           write_formula()             Yes
7520           write_array_formula()       Yes. Not in Spreadsheet::WriteExcel.
7521           keep_leading_zeros()        Yes
7522           write_comment()             Yes
7523           show_comments()             Yes
7524           set_comments_author()       Yes
7525           add_write_handler()         Yes
7526           insert_image()              Yes.
7527           insert_chart()              Yes
7528           insert_shape()              Yes. Not in Spreadsheet::WriteExcel.
7529           insert_button()             Yes. Not in Spreadsheet::WriteExcel.
7530           data_validation()           Yes
7531           conditional_formatting()    Yes. Not in Spreadsheet::WriteExcel.
7532           add_sparkline()             Yes. Not in Spreadsheet::WriteExcel.
7533           add_table()                 Yes. Not in Spreadsheet::WriteExcel.
7534           get_name()                  Yes
7535           activate()                  Yes
7536           select()                    Yes
7537           hide()                      Yes
7538           set_first_sheet()           Yes
7539           protect()                   Yes
7540           set_selection()             Yes
7541           set_row()                   Yes.
7542           set_column()                Yes.
7543           set_default_row()           Yes. Not in Spreadsheet::WriteExcel.
7544           outline_settings()          Yes
7545           freeze_panes()              Yes
7546           split_panes()               Yes
7547           merge_range()               Yes
7548           merge_range_type()          Yes. Not in Spreadsheet::WriteExcel.
7549           set_zoom()                  Yes
7550           right_to_left()             Yes
7551           hide_zero()                 Yes
7552           set_tab_color()             Yes
7553           autofilter()                Yes
7554           filter_column()             Yes
7555           filter_column_list()        Yes. Not in Spreadsheet::WriteExcel.
7556           write_utf16be_string()      Deprecated. Use Perl utf8 strings instead.
7557           write_utf16le_string()      Deprecated. Use Perl utf8 strings instead.
7558           store_formula()             Deprecated. See docs.
7559           repeat_formula()            Deprecated. See docs.
7560           write_url_range()           Not supported. Not required in Excel::Writer::XLSX.
7561
7562           Page Set-up Methods         Support
7563           ===================         =======
7564           set_landscape()             Yes
7565           set_portrait()              Yes
7566           set_page_view()             Yes
7567           set_paper()                 Yes
7568           center_horizontally()       Yes
7569           center_vertically()         Yes
7570           set_margins()               Yes
7571           set_header()                Yes
7572           set_footer()                Yes
7573           repeat_rows()               Yes
7574           repeat_columns()            Yes
7575           hide_gridlines()            Yes
7576           print_row_col_headers()     Yes
7577           print_area()                Yes
7578           print_across()              Yes
7579           fit_to_pages()              Yes
7580           set_start_page()            Yes
7581           set_print_scale()           Yes
7582           set_h_pagebreaks()          Yes
7583           set_v_pagebreaks()          Yes
7584
7585           Format Methods              Support
7586           ==============              =======
7587           set_font()                  Yes
7588           set_size()                  Yes
7589           set_color()                 Yes
7590           set_bold()                  Yes
7591           set_italic()                Yes
7592           set_underline()             Yes
7593           set_font_strikeout()        Yes
7594           set_font_script()           Yes
7595           set_font_outline()          Yes
7596           set_font_shadow()           Yes
7597           set_num_format()            Yes
7598           set_locked()                Yes
7599           set_hidden()                Yes
7600           set_align()                 Yes
7601           set_rotation()              Yes
7602           set_text_wrap()             Yes
7603           set_text_justlast()         Yes
7604           set_center_across()         Yes
7605           set_indent()                Yes
7606           set_shrink()                Yes
7607           set_pattern()               Yes
7608           set_bg_color()              Yes
7609           set_fg_color()              Yes
7610           set_border()                Yes
7611           set_bottom()                Yes
7612           set_top()                   Yes
7613           set_left()                  Yes
7614           set_right()                 Yes
7615           set_border_color()          Yes
7616           set_bottom_color()          Yes
7617           set_top_color()             Yes
7618           set_left_color()            Yes
7619           set_right_color()           Yes
7620

REQUIREMENTS

7622       <http://search.cpan.org/search?dist=Archive-Zip/>.
7623
7624       Perl 5.8.2.
7625

SPEED AND MEMORY USAGE

7627       "Spreadsheet::WriteExcel" was written to optimise speed and reduce
7628       memory usage. However, these design goals meant that it wasn't easy to
7629       implement features that many users requested such as writing formatting
7630       and data separately.
7631
7632       As a result "Excel::Writer::XLSX" takes a different design approach and
7633       holds a lot more data in memory so that it is functionally more
7634       flexible.
7635
7636       The effect of this is that Excel::Writer::XLSX is about 30% slower than
7637       Spreadsheet::WriteExcel and uses 5 times more memory.
7638
7639       In addition the extended row and column ranges in Excel 2007+ mean that
7640       it is possible to run out of memory creating large files. This was
7641       almost never an issue with Spreadsheet::WriteExcel.
7642
7643       This memory usage can be reduced almost completely by using the
7644       Workbook "set_optimization()" method:
7645
7646           $workbook->set_optimization();
7647
7648       This also gives an increase in performance to within 1-10% of
7649       Spreadsheet::WriteExcel, see below.
7650
7651       The trade-off is that you won't be able to take advantage of any new
7652       features that manipulate cell data after it is written. One such
7653       feature is Tables.
7654
7655   Performance figures
7656       The performance figures below show execution speed and memory usage for
7657       60 columns x N rows for a 50/50 mixture of strings and numbers.
7658       Percentage speeds are relative to Spreadsheet::WriteExcel.
7659
7660           Excel::Writer::XLSX
7661                Rows  Time (s)    Memory (bytes)  Rel. Time
7662                 400      0.66         6,586,254       129%
7663                 800      1.26        13,099,422       125%
7664                1600      2.55        26,126,361       123%
7665                3200      5.16        52,211,284       125%
7666                6400     10.47       104,401,428       128%
7667               12800     21.48       208,784,519       131%
7668               25600     43.90       417,700,746       126%
7669               51200     88.52       835,900,298       126%
7670
7671           Excel::Writer::XLSX + set_optimisation()
7672                Rows  Time (s)    Memory (bytes)  Rel. Time
7673                 400      0.70            63,059       135%
7674                 800      1.10            63,059       110%
7675                1600      2.30            63,062       111%
7676                3200      4.44            63,062       107%
7677                6400      8.91            63,062       109%
7678               12800     17.69            63,065       108%
7679               25600     35.15            63,065       101%
7680               51200     70.67            63,065       101%
7681
7682           Spreadsheet::WriteExcel
7683                Rows  Time (s)    Memory (bytes)
7684                 400      0.51         1,265,583
7685                 800      1.01         2,424,855
7686                1600      2.07         4,743,400
7687                3200      4.14         9,411,139
7688                6400      8.20        18,766,915
7689               12800     16.39        37,478,468
7690               25600     34.72        75,044,423
7691               51200     70.21       150,543,431
7692

DOWNLOADING

7694       The latest version of this module is always available at:
7695       <http://search.cpan.org/search?dist=Excel-Writer-XLSX/>.
7696

INSTALLATION

7698       The module can be installed using the standard Perl procedure:
7699
7700                   perl Makefile.PL
7701                   make
7702                   make test
7703                   make install    # You may need to be sudo/root
7704

DIAGNOSTICS

7706       Filename required by Excel::Writer::XLSX->new()
7707           A filename must be given in the constructor.
7708
7709       Can't open filename. It may be in use or protected.
7710           The file cannot be opened for writing. The directory that you are
7711           writing to may be protected or the file may be in use by another
7712           program.
7713
7714       Can't call method "XXX" on an undefined value at someprogram.pl.
7715           On Windows this is usually caused by the file that you are trying
7716           to create clashing with a version that is already open and locked
7717           by Excel.
7718
7719       The file you are trying to open 'file.xls' is in a different format
7720       than specified by the file extension.
7721           This warning occurs when you create an XLSX file but give it an xls
7722           extension.
7723

WRITING EXCEL FILES

7725       Depending on your requirements, background and general sensibilities
7726       you may prefer one of the following methods of getting data into Excel:
7727
7728       ·   Spreadsheet::WriteExcel
7729
7730           This module is the precursor to Excel::Writer::XLSX and uses the
7731           same interface. It produces files in the Excel Biff xls format that
7732           was used in Excel versions 97-2003. These files can still be read
7733           by Excel 2007 but have some limitations in relation to the number
7734           of rows and columns that the format supports.
7735
7736           Spreadsheet::WriteExcel.
7737
7738       ·   Win32::OLE module and office automation
7739
7740           This requires a Windows platform and an installed copy of Excel.
7741           This is the most powerful and complete method for interfacing with
7742           Excel.
7743
7744           Win32::OLE
7745
7746       ·   CSV, comma separated variables or text
7747
7748           Excel will open and automatically convert files with a "csv"
7749           extension.
7750
7751           To create CSV files refer to the Text::CSV_XS module.
7752
7753       ·   DBI with DBD::ADO or DBD::ODBC
7754
7755           Excel files contain an internal index table that allows them to act
7756           like a database file. Using one of the standard Perl database
7757           modules you can connect to an Excel file as a database.
7758
7759       For other Perl-Excel modules try the following search:
7760       <http://search.cpan.org/search?mode=module&query=excel>.
7761

READING EXCEL FILES

7763       To read data from Excel files try:
7764
7765       ·   Spreadsheet::XLSX
7766
7767           A module for reading formatted or unformatted data form XLSX files.
7768
7769           Spreadsheet::XLSX
7770
7771       ·   SimpleXlsx
7772
7773           A lightweight module for reading data from XLSX files.
7774
7775           SimpleXlsx
7776
7777       ·   Spreadsheet::ParseExcel
7778
7779           This module can read  data from an Excel XLS file but it doesn't
7780           support the XLSX format.
7781
7782           Spreadsheet::ParseExcel
7783
7784       ·   Win32::OLE module and office automation (reading)
7785
7786           See above.
7787
7788       ·   DBI with DBD::ADO or DBD::ODBC.
7789
7790           See above.
7791
7792       For other Perl-Excel modules try the following search:
7793       <http://search.cpan.org/search?mode=module&query=excel>.
7794

BUGS

7796       ·   Memory usage is very high for large worksheets.
7797
7798           If you run out of memory creating large worksheets use the
7799           "set_optimization()" method. See "SPEED AND MEMORY USAGE" for more
7800           information.
7801
7802       ·   Perl packaging programs can't find chart modules.
7803
7804           When using Excel::Writer::XLSX charts with Perl packagers such as
7805           PAR or Cava you should explicitly include the chart that you are
7806           trying to create in your "use" statements. This isn't a bug as such
7807           but it might help someone from banging their head off a wall:
7808
7809               ...
7810               use Excel::Writer::XLSX;
7811               use Excel::Writer::XLSX::Chart::Column;
7812               ...
7813
7814       If you wish to submit a bug report run the "bug_report.pl" program in
7815       the "examples" directory of the distro.
7816
7817       The bug tracker is on Github:
7818       <https://github.com/jmcnamara/excel-writer-xlsx/issues>.
7819

TO DO

7821       The roadmap is as follows:
7822
7823       ·   New separated data/formatting API to allow cells to be formatted
7824           after data is added.
7825
7826       ·   More charting features.
7827

REPOSITORY

7829       The Excel::Writer::XLSX source code in host on github:
7830       <http://github.com/jmcnamara/excel-writer-xlsx>.
7831

MAILING LIST

7833       There is a Google group for discussing and asking questions about
7834       Excel::Writer::XLSX. This is a good place to search to see if your
7835       question has been asked before:
7836       <http://groups.google.com/group/spreadsheet-writeexcel>.
7837

DONATIONS and SPONSORSHIP

7839       If you'd care to donate to the Excel::Writer::XLSX project or sponsor a
7840       new feature, you can do so via PayPal: <http://tinyurl.com/7ayes>.
7841

SEE ALSO

7843       Spreadsheet::WriteExcel:
7844       <http://search.cpan.org/dist/Spreadsheet-WriteExcel>.
7845
7846       Spreadsheet::ParseExcel:
7847       <http://search.cpan.org/dist/Spreadsheet-ParseExcel>.
7848
7849       Spreadsheet::XLSX: <http://search.cpan.org/dist/Spreadsheet-XLSX>.
7850

ACKNOWLEDGEMENTS

7852       The following people contributed to the debugging, testing or
7853       enhancement of Excel::Writer::XLSX:
7854
7855       Rob Messer of IntelliSurvey gave me the initial prompt to port
7856       Spreadsheet::WriteExcel to the XLSX format. IntelliSurvey
7857       (<http://www.intellisurvey.com>) also sponsored large files
7858       optimisations and the charting feature.
7859
7860       Bariatric Advantage (<http://www.bariatricadvantage.com>) sponsored
7861       work on chart formatting.
7862
7863       Eric Johnson provided the ability to use secondary axes with charts.
7864       Thanks to Foxtons (<http://foxtons.co.uk>) for sponsoring this work.
7865
7866       BuildFax (<http://www.buildfax.com>) sponsored the Tables feature and
7867       the Chart point formatting feature.
7868

DISCLAIMER OF WARRANTY

7870       Because this software is licensed free of charge, there is no warranty
7871       for the software, to the extent permitted by applicable law. Except
7872       when otherwise stated in writing the copyright holders and/or other
7873       parties provide the software "as is" without warranty of any kind,
7874       either expressed or implied, including, but not limited to, the implied
7875       warranties of merchantability and fitness for a particular purpose. The
7876       entire risk as to the quality and performance of the software is with
7877       you. Should the software prove defective, you assume the cost of all
7878       necessary servicing, repair, or correction.
7879
7880       In no event unless required by applicable law or agreed to in writing
7881       will any copyright holder, or any other party who may modify and/or
7882       redistribute the software as permitted by the above licence, be liable
7883       to you for damages, including any general, special, incidental, or
7884       consequential damages arising out of the use or inability to use the
7885       software (including but not limited to loss of data or data being
7886       rendered inaccurate or losses sustained by you or third parties or a
7887       failure of the software to operate with any other software), even if
7888       such holder or other party has been advised of the possibility of such
7889       damages.
7890

LICENSE

7892       The Perl Artistic Licence <http://dev.perl.org/licenses/artistic.html>.
7893

AUTHOR

7895       John McNamara jmcnamara@cpan.org
7896
7897           Wilderness for miles, eyes so mild and wise
7898           Oasis child, born and so wild
7899           Don't I know you better than the rest
7900           All deception, all deception from you
7901
7902           Any way you run, you run before us
7903           Black and white horse arching among us
7904           Any way you run, you run before us
7905           Black and white horse arching among us
7906
7907             -- Beach House
7908
7910       Copyright MM-MMXIX, John McNamara.
7911
7912       All Rights Reserved. This module is free software. It may be used,
7913       redistributed and/or modified under the same terms as Perl itself.
7914
7915
7916
7917perl v5.30.1                      2020-01-30            Excel::Writer::XLSX(3)
Impressum