Data-Table-Excel
view release on metacpan or search on metacpan
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Data::Table::Excel - Convert between Data::Table objects and Excel files.</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@gold.nonet" />
</head>
<body style="background-color: white">
<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>
<ul>
<li><a href="#name">NAME</a></li>
<li><a href="#synopsis">SYNOPSIS</a></li>
<li><a href="#abstract">ABSTRACT</a></li>
<li><a href="#description">DESCRIPTION</a></li>
<li><a href="#author">AUTHOR</a></li>
<li><a href="#see_also">SEE ALSO</a></li>
</ul>
<hr name="index" />
</div>
<!-- INDEX END -->
<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>Data::Table::Excel - Convert between Data::Table objects and Excel (xls/xlsx) files.</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
News: The package now includes "Perl Data::Table Cookbook" (PDF), which may serve as a better learning material.
To download the free Cookbook, visit https://sites.google.com/site/easydatabase/</pre>
<pre>
use Data::Table::Excel qw (tables2xls xls2tables tables2xlsx xlsx2tables excelFileToTable is_xlsx xls2xlsx xlsx2xls);</pre>
<pre>
# read in two CSV tables and generate an Excel .xls binary file with two spreadsheets
my $t_category = Data::Table::fromFile("Category.csv");
my $t_product = Data::Table::fromFile("Product.csv");
# the workbook will contain two sheets, named Category and Product
# parameters: output file name, an array of tables to write, and their corresponding names
tables2xls("NorthWind.xls", [$t_category, $t_product], ["Category","Product"]);</pre>
<pre>
# read in NorthWind.xls file as two Data::Table objects
my ($tableObjects, $tableNames, $column_headers)=xls2tables("NorthWind.xls");
for (my $i=0; $i<@$tableNames; $i++) {
print "*** ". $tableNames->[$i], " ***\n";
print $tableObjects->[$i]->csv($column_headers[$i]);
}</pre>
<pre>
Outputs:
*** Category ***
CategoryID,CategoryName,Description
( run in 0.642 second using v1.01-cache-2.11-cpan-119454b85a5 )