# perldoc > Spreadsheet::WriteExcel::Examples

---
type: CommandReference
command: Spreadsheet::WriteExcel::Examples
mode: perldoc
section: 
source: perldoc
---

## Quick Reference

- `a_simple.pl` — Basic text and numbers to Excel
- `demo.pl` — Overview of features (text, numbers, formulas, hyperlinks, images)
- `regions.pl` — Multiple worksheets
- `stats.pl` — Statistical functions
- `formats.pl` — All formatting options (fonts, colors, borders, patterns, alignment)
- `autofilter.pl` — Autofilter creation with conditions
- `chart_column.pl` — Column chart example
- `unicode_cyrillic.pl` — Unicode (UTF-8) with Cyrillic text

## Name

Examples - [Spreadsheet::WriteExcel](https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AWriteExcel/markdown) example programs.

## Description

This is a documentation only module showing the examples included in the [Spreadsheet::WriteExcel](https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AWriteExcel/markdown) distribution. 85 example programs are provided, covering most features.

## Examples

### Example: a_simple.pl

A simple example of writing text and numbers to an Excel binary file.

perl
#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;

my $workbook  = Spreadsheet::WriteExcel->new('a_simple.xls');
my $worksheet = $workbook->add_worksheet();

$worksheet->write(0, 0,  "Hi Excel!");
$worksheet->write(2, 0,  3);
$worksheet->write(3, 0,  3.00000);
$worksheet->write(4, 0,  3.00001);
$worksheet->write(5, 0,  3.14159);
$worksheet->write(7, 0,  '=A3 + A6');
$worksheet->write(8, 0,  '=IF(A5>3,"Yes", "No")');
$worksheet->write(10, 0, 'http://www.perl.com/');
### Example: demo.pl

Demonstrates many features: text, numbers, formulas, hyperlinks, images, Unicode, and formatting.

perl
#!/usr/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;

my $workbook   = Spreadsheet::WriteExcel->new("demo.xls");
my $worksheet  = $workbook->add_worksheet('Demo');
my $worksheet2 = $workbook->add_worksheet('Another sheet');
my $worksheet3 = $workbook->add_worksheet('And another');
my $bold       = $workbook->add_format(bold => 1);

$worksheet->set_column('A:A', 36, $bold);
$worksheet->set_column('B:B', 20);
$worksheet->set_row(0, 40);

my $heading = $workbook->add_format(bold=>1, color=>'blue', size=>16, merge=>1, align=>'vcenter');
$worksheet->write_row('A1', ['Features of Spreadsheet::WriteExcel', ''], $heading);

my $text_format = $workbook->add_format(bold=>1, italic=>1, color=>'red', size=>18, font=>'Lucida Calligraphy');
$worksheet->write('A2', "Text");
$worksheet->write('B2', "Hello Excel");
$worksheet->write('A3', "Formatted text");
$worksheet->write('B3', "Hello Excel", $text_format);

my $num1_format = $workbook->add_format(num_format => '$#,##0.00');
my $num2_format = $workbook->add_format(num_format => ' d mmmm yyy');
$worksheet->write('A5', "Numbers");
$worksheet->write('B5', 1234.56);
$worksheet->write('A6', "Formatted numbers");
$worksheet->write('B6', 1234.56, $num1_format);
$worksheet->write('A7', "Formatted numbers");
$worksheet->write('B7', 37257, $num2_format);

$worksheet->write('A8', 'Formulas and functions, "=SIN(PI()/4)"');
$worksheet->write('B8', '=SIN(PI()/4)');
$worksheet->write('A9', "Hyperlinks");
$worksheet->write('B9', 'http://www.perl.com/');
$worksheet->write('A10', "Images");
$worksheet->insert_image('B10', 'republic.png', 16, 8);
$worksheet->write('A18', "Page/printer setup");
$worksheet->write('A19', "Multiple worksheets");
### Example: regions.pl

Multiple worksheets example.

### Example: stats.pl

Basic statistical functions (COUNT, SUM, AVERAGE, MIN, MAX, STDEV, KURT).

### Example: formats.pl

Demonstrates all formatting options: fonts, named colors, standard colors, numeric formats, borders, patterns, alignment, rotation, text wrap, indent, underline, strikeout, etc.

### Example: autofilter.pl

Autofilter with conditions (e.g., `Region eq East`, `x > 3000 and x < 8000`, blanks, non-blanks).

### Example: chart_area.pl

Area chart; similar templates for `chart_bar.pl`, `chart_column.pl`, `chart_line.pl`, `chart_pie.pl`, `chart_scatter.pl`, `chart_stock.pl`.

### Example: unicode_utf16.pl

Writing Unicode using UTF-16 encoding.

### Full list of example programs (85 total)

- `a_simple.pl` — Basic get started example
- `demo.pl` — Features demo
- `regions.pl` — Multiple worksheets
- `stats.pl` — Basic formulas and functions
- `formats.pl` — All formatting
- `bug_report.pl` — Bug report template
- `autofilter.pl` — Autofilters
- `autofit.pl` — Simulate Excel's autofit
- `bigfile.pl` — Write past 7MB limit (requires OLE::Storage_Lite)
- `cgi.pl` — Simple CGI program
- `chart_area.pl` — Area chart
- `chart_bar.pl` — Bar chart
- `chart_column.pl` — Column chart
- `chart_line.pl` — Line chart
- `chart_pie.pl` — Pie chart
- `chart_scatter.pl` — Scatter chart
- `chart_stock.pl` — Stock chart
- `chess.pl` — Reusing formatting via property hashes
- `colors.pl` — Colour palette and named colours
- `comments1.pl` — Add comments to cells
- `comments2.pl` — Comments with advanced options
- `copyformat.pl` — Copying a cell format
- `data_validate.pl` — Data validation and dropdown lists
- `date_time.pl` — Writing dates and times with `write_date_time()`
- `defined_name.pl` — Defined names
- `diag_border.pl` — Diagonal cell borders
- `easter_egg.pl` — Excel97 flight simulator (Win32::OLE)
- `filehandle.pl` — Working with filehandles
- `formula_result.pl` — Formulas with user specified results
- `headers.pl` — Headers and footers
- `hide_sheet.pl` — Hiding a worksheet
- `hyperlink1.pl` — Web hyperlinks
- `hyperlink2.pl` — Internal and external hyperlinks
- `images.pl` — Adding images
- `indent.pl` — Cell indentation
- `merge1.pl` — Cell merging (center across selection)
- `merge2.pl` — Merging with formatting
- `merge3.pl` — Hyperlinks in merged cells
- `merge4.pl` — Advanced merging with formatting
- `merge5.pl` — Merging with rotation
- `merge6.pl` — Merging with Unicode strings
- `mod_perl1.pl` — mod_perl 1 program
- `mod_perl2.pl` — mod_perl 2 program
- `outline.pl` — Outlines and grouping
- `outline_collapsed.pl` — Collapsed outlines
- `panes.pl` — Worksheet panes (freeze/split)
- `properties.pl` — Document properties
- `protection.pl` — Cell locking and formula hiding
- `repeat.pl` — Repeated formulas
- `right_to_left.pl` — Right-to-left sheet direction
- `row_wrap.pl` — Wrap data to multiple worksheets
- `sales.pl` — Sales spreadsheet with formulas and dates
- `sendmail.pl` — Send Excel attachment via Mail::Sender
- `stats_ext.pl` — Statistics with external references
- `stocks.pl` — Conditional formatting for stock prices
- `tab_colors.pl` — Worksheet tab colours
- `textwrap.pl` — Text wrapping options
- `win32ole.pl` — Win32::OLE comparison example
- `write_arrays.pl` — Writing 1D/2D arrays
- `write_handler1.pl` — Extending `write()` method (7-digit IDs)
- `write_handler2.pl` — Extending `write()` with column constraint
- `write_handler3.pl` — Extending `write()` for dates
- `write_handler4.pl` — Extending `write()` for dates with error handling
- `write_to_scalar.pl` — Writing Excel to a Perl scalar
- `unicode_utf16.pl` — Unicode UTF-16 strings
- `unicode_utf16_japan.pl` — Japanese Unicode UTF-16
- `unicode_cyrillic.pl` — Russian Cyrillic UTF-8
- `unicode_list.pl` — List Unicode characters in a font
- `unicode_2022_jp.pl` — Japanese ISO-2022-JP to UTF-8
- `unicode_8859_11.pl` — Thai ISO-8859-11 to UTF-8
- `unicode_8859_7.pl` — Greek ISO-8859-7 to UTF-8
- `unicode_big5.pl` — Chinese BIG5 to UTF-8
- `unicode_cp1251.pl` — Russian CP1251 to UTF-8
- `unicode_cp1256.pl` — Arabic CP1256 to UTF-8
- `unicode_koi8r.pl` — Russian KOI8-R to UTF-8
- `unicode_polish_utf8.pl` — Polish UTF-8
- `unicode_shift_jis.pl` — Japanese Shift JIS to UTF-8
- `csv2xls.pl` — CSV to Excel converter
- `tab2xls.pl` — Tab separated file to Excel
- `datecalc1.pl` — Unix/Perl time to Excel time
- `datecalc2.pl` — Excel date using Date::Calc
- `lecxe.pl` — Convert Excel file to WriteExcel program (Win32::OLE)
- `convertA1.pl` — Helper functions for A1 notation
- `function_locale.pl` — Add non-English function names
- `writeA1.pl` — Extending module with A1 style references

## See Also

- [Spreadsheet::WriteExcel](https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AWriteExcel/markdown) — Main module documentation
- [Spreadsheet::WriteExcel::Utility](https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AWriteExcel%3A%3AUtility/markdown) — Utility functions
- [Spreadsheet::ParseExcel](https://www.chedong.com/phpMan.php/perldoc/Spreadsheet%3A%3AParseExcel/markdown) — Read Excel files
- [OLE::Storage_Lite](https://www.chedong.com/phpMan.php/perldoc/OLE%3A%3AStorageLite/markdown) — Required for large files