To use this module
use Spreadsheet::WriteExcel;
As stated above this module allows you to write excel files without that annoying popup asking you how your file is delimeted when you open the file. It works very well, the only problem i had was trying to convert one of our flat files that is over 70,000 records in length. But after i checked the problem is documented, it can only produce files <~ 7.0 MB. heres on little program I have created
with it
#!/usr/bin/perl
use Spreadsheet::WriteExcel;
print "Enter the path to the file(ie /home/): ";
$path = <>;
chomp($path);
print "Enter the filename(ie data): ";
$fname = <>;
chomp($fname);
$file = "$path$fname";
my $workbook = Spreadsheet::WriteExcel->new("/tmp/$fname.xls");
$worksheet1 = $workbook->addworksheet(sheet1);
$worksheet2 = $workbook->addworksheet(sheet2);
$worksheet3 = $workbook->addworksheet(sheet3);
$format = $workbook->addformat();
$format->set_bold();
$format->set_color('black');
$format->set_align('center');
$format->set_size('10');
open input, "$file" || die "Can't open that file";
$k=0;
for (<input>){
chomp($_);
@data = split(/\t/,$_);
for ($i=0; $i<=@data; $i++){
$worksheet1->write($k, $i, $data[$i], $format);
}
$k++;
}
Good Luck
Rob
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|