I have this perl script:
use Spreadsheet::WriteExcel::Big; use XML::SAX::ExpatXS; #use lib qw(/vweb/cl2000/docs/); use lib qw(/opt/perl/scripts); use ExcelSAX; $excel_file_path = "/proddata/coll/targift/ftp/"; $book_cnt = 1; $sheet_cnt = 1; # The location of the XML file to be parsed. $file = "/proddata/coll/targift/ftp/TARGIFT_CARDSALES_RPT_031711_0933. +xls"; #$file = "OPERATOR_LEAD_RPT062405_51457.xml"; $day = (localtime(time))[3]; $month = ((localtime(time))[4]) + 1; $year = ((localtime(time))[5]) + 1900; $basename = "MONTHLY_INVENTORY_$year"."_$month"."_$day"; $callback = sub { my $worksheet = shift; my $workbook = shift; my $format1 = $workbook->add_format(); $format1->set_num_format('$#,##0.00'); $worksheet->set_landscape(); # Landscape mode $worksheet->set_column(0, 0, 10); $worksheet->set_column(1, 1, 35); $worksheet->set_column(2, 2, 15);; $worksheet->fit_to_pages(1,0); # set to 1 page wide and as long as nee +ded $worksheet->set_footer('&CPage &P of &N'); }; $handler = ExcelSAX->new("$excel_file_path", 0, $callback); $parser = XML::SAX::ExpatXS->new( Handler => $handler ); $parser->parse_uri($file);
This is the error that I am receiving.
perl /vweb/cl2000/docs/targift/xml/targift_card_sales_rpt_MARKL.pl Created workbook /proddata/coll/targift/ftp/TARGIFT_CARDSALES_RPT_0317 +11_1235.xls unclosed token at line 2191, column 3, byte 32765 at /vweb/cl2000/docs +/targift/xml/targift_card_sales_rpt_MARKL.pl line 55
The data is as follows. There are three columns trying to be created.
<ROW> <COL1 >T1500</COL1> <COL2 >1</COL2> <COL3 >50</COL3> </ROW> <ROW> <COL1 >T1502</COL1> <COL2 >1</COL2> <COL3 >50</COL3> </ROW> <ROW> <COL1 >T1505</COL1> <--- Line in the error. <COL2 >1</COL2> <COL3 >50</COL3> </ROW> <ROW> <COL1 >T1506</COL1> <COL2 >1</COL2> <COL3 >50</COL3> </ROW> <ROW>
Not a perl programmer so I am lost at why this is not working. Thanks

In reply to Using Perl to go from XML to EXCEL by mlaursen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.