~ubuntu-branches/ubuntu/trusty/horae/trusty

« back to all changes in this revision

Viewing changes to 0CPAN/Spreadsheet-WriteExcel-2.15/examples/write_to_scalar.pl

  • Committer: Bazaar Package Importer
  • Author(s): Carlo Segre
  • Date: 2008-02-23 23:13:02 UTC
  • mfrom: (2.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080223231302-mnyyxs3icvrus4ke
Tags: 066-3
Apply patch to athena_parts/misc.pl for compatibility with 
perl-tk 804.28.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
##############################################################################
4
 
#
5
 
# An example of writing an Excel file to a Perl scalar using Spreadsheet::
6
 
# WriteExcel and the new features of perl 5.8.
7
 
#
8
 
# For an examples of how to write to a scalar in versions prior to perl 5.8
9
 
# see the filehandle.pl program and IO:Scalar.
10
 
#
11
 
# reverse('�'), September 2004, John McNamara, jmcnamara@cpan.org
12
 
#
13
 
 
14
 
use strict;
15
 
use Spreadsheet::WriteExcel;
16
 
 
17
 
require 5.008;
18
 
 
19
 
 
20
 
# Use perl 5.8's feature of using a scalar as a filehandle.
21
 
my   $fh;
22
 
my   $str = '';
23
 
open $fh, '>', \$str or die "Failed to open filehandle: $!";;
24
 
 
25
 
 
26
 
# Or replace the previous three lines with this:
27
 
# open my $fh, '>', \my $str or die "Failed to open filehandle: $!";
28
 
 
29
 
 
30
 
# Spreadsheet::WriteExce accepts filehandle as well as file names.
31
 
my $workbook  = Spreadsheet::WriteExcel->new($fh);
32
 
my $worksheet = $workbook->add_worksheet();
33
 
 
34
 
$worksheet->write(0, 0,  "Hi Excel!");
35
 
 
36
 
$workbook->close();
37
 
 
38
 
 
39
 
# The Excel file in now in $str. Remember to binmode() the output
40
 
# filehandle before printing it.
41
 
binmode STDOUT;
42
 
print $str;
43
 
 
44
 
 
45
 
__END__
46