#! /usr/bin/perl -w
# vim:syntax=perl
use strict;

use lib '/usr/share/perl5';

use Getopt::Long;
use Lire::Config;
use Lire::Program qw( :msg tempfile $PROG $LR_SUPERSERVICE $LR_ID );
use Lire::ReportParser::ExcelWriter;

my %opts = ( userlevel => Lire::Config->get( 'lr_user_level' ) );
GetOptions( \%opts, "userlevel=s" ) && @ARGV == 0
  or lr_err( "Usage $PROG [--userlevel normal|advanced] < report.xml" );


lr_err( "wrong value for userlevel: $opts{userlevel} (must be either 'normal' or 'advanced' )" )
  unless $opts{userlevel} =~ /^(normal|advanced)$/;

my $parser = new Lire::ReportParser::ExcelWriter( %opts );
eval {
    $parser->parse(\*STDIN);
};
lr_err( $@ ) if $@;
lr_info( "parsing xml finished" );

exit 0;

__END__

=pod

=head1 NAME

lr_xml2xls - generate a Excel 95 spreadsheet from a raw xml report

=head1 SYNOPSIS

B<lr_xml2xls> [--userlevel normal|advanced] < report.xml

=head1 DESCRIPTION

This script uses the Spreadsheet::WriteExcel CPAN module to convert a
Lire XML report into a Excel95 spreadsheet. This spreadsheet file
format should work in all version of Excel(tm). It is also supported
by Gnumeric and OpenOffice.

It reads a XML report on STDIN and outputs a Excel95 spreadsheet on
STDOUT. Since this is a binary format, we suggests you use file
redirection!

=head1 SEE ALSO

lr_log2report(1), lr_xml2report(1), lr_xml2mail(1)

=head1 VERSION

$Id: lr_xml2xls.in,v 1.7 2004/01/21 07:23:00 wsourdeau Exp $

=head1 COPYRIGHT

Copyright (C) 2000, 2001, 2002 Stichting LogReport Foundation LogReport@LogReport.org

This file is part of Lire.

Lire is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html or write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.

=head1 AUTHOR

Francis J. Lacoste

=cut

# Local Variables:
# mode: cperl
# End:
