Skip to main content.
home | support | download

Back to List Archive

Re: Good Excel parser

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Wed May 28 2003 - 18:19:12 GMT
On Wed, May 28, 2003 at 09:00:19AM -0700, Roubart Capcap wrote:
> Hello,
> 
> Does anybody know of a good Excel parser?  I tried the Swish Filters
> with the following code in my spider.pl:
> 
> use lib '/swish-e-2.2.3/filters/SWISH/Filters';
> use XLtoHTML;
> sub xl {
>    my ( $uri, $server, $response, $content_ref ) = @_;
>    return 1 unless $response->content_type eq 'application/vnd.ms-excel';
>    # for logging counts
>    $server->{counts}{'XLS transformed'}++;
>    $$content_ref = ${XLtoHTML( $content_ref )};
>    $$content_ref =~ tr/ / /s;
>    return 1;
> }

I assume you have Spreadsheet::ParseExcel installed?  I also don't know 
if you can call XLtoHTML() directly.  You should call it from 
SWISH::Filter.  See

   http://swish-e.org/dev/docs/Filter.html

There's also a "TESTING" section that shows how to test the filter 
outside of swish-e or spider.pl.

It says:

[This module can be run as a program directly. Change directory 
to the location of the Filter.pm module and run:

  perl -I.. Filter.pm test  foo.pdf  bar.doc

replace foo.pdf and bar.doc with real paths on your system. The -I.. is 
needed for loading the filter modules.]


You don't really have to change directory to the location of Filter.pm.  
You can run from any directory.  For example

   perl -I/home/moseley/swish-e/filters \
        /home/moseley/swish-e/filters/Filter.pm \
        test.xls

That should show you if the filtering is working.

BTW -- The new version of Swish-e has a filter (a SWISH::Filter) that
uses the Perl module Spreadsheet::ParseExcel (available from CPAN).  The
new spider.pl will automatically use it if you have
Spreadsheet::ParseExcel installed.


-- 
Bill Moseley
moseley@hank.org
Received on Wed May 28 18:19:20 2003