Re: PERL + Repeat header on every page while printing excel



On 2007-12-28 16:54, Ron Bergin <rkb@xxxxxxxxxx> wrote:
On Dec 28, 6:32 am, Ivan Novick <i...@xxxxxxxxxx> wrote:
On Dec 28, 4:13 am, venkatasatyasur...@xxxxxxxxx wrote:
I am working on an application using PERL 5.8.

<mantra>
The language is spelled "Perl", not "PERL".
</mantra>

I have a requirement where i am getting data from Oracle
database & exporting it to an excel. Users will print this excel file.

What is the purpose of the export?

* To get an Excel file, which people can use for further processing of
the data (compute statistics, make graphs, etc.) and incidentally also
print.

* To print the data.

If it is the latter, then creating a "print file" of some sort (e.g.,
Postscript or PDF, or maybe just plain text) may be a better way,
especially if precise control over the layout is necessary.


We are getting bulk data from database & its printing multiple pages.
On every page we want the header to be present.

I am hoping you are printing to excel in csv plain text format and not
using binary api specifically for excel.
Why?

I was going to ask the same thing. In this case CSV is completely
unsuitable as you have absolutely no control over the layout. A CSV file
contains only the data, nothing else.


If you are printing in csv format and want to repeat a header on every
page you can use "perl format" to do this:

http://perldoc.perl.org/functions/format.html

How much is "a page" in CSV? You don't know, or rather, you *do* know
that there is no such thing as a "page" in CSV. The first line may be
header line, but all other lines are supposed to contain only data. You
should not repeat header lines periodically in a CSV file.

Also, "format" is intended for fixed width layouts, which CSV isn't.
If you want to write CSV, DBD::CSV or Text::CSV is probably the way to
go (or just use simple print statements).


Using an api would give you far more control over the spread***
formatting than the "perl format"

Spread***::WriteExcel - Write to a cross-platform Excel binary file.

Right. Or - if the real objective is printing instead of creating an
Excel file - PDF::API2.

hp

.


Quantcast