Hi i have one script(Scriptone) where i am generating xml file.Here i am putting values direclty in the script. for ex "ReqID" => "18AEXR" Now what i need to do is i need to pick value from excel and put it into respective field. i have written one code which will read data from excel. Now my problem is how to merge these two scripts script one:
#!/usr/bin/perl use XML::Writer; use IO::File; my $output = new IO::File('>C:\Documents and Settings\ashalatha\Desk +top\PEG\Perl scripting\xml\Files\output1.xml'); my $writer = new XML::Writer(OUTPUT => $output); $writer->startTag("FIXML"); $writer->startTag("PosMntReq", "ReqID" => "18AEXR" ,"TxnTyp" => "1", +"BizDt"=>"2003-12-04", "SetSesID" => "EOD", "TxnTm" => "2003-09-10T00:00:00"); $writer->endTag("PosMntReq"); $writer->endTag("FIXML"); $writer->end(); $output->close();
script two:
#!/usr/bin/perl -w use strict; use Spreadsheet::ParseExcel; use Data::Dumper; # cobbled together from examples for the Spreadsheet::ParseExcel and # Spreadsheet::WriteExcel modules my $sourcename = 'C:\Documents and Settings\la\Desktop\EuronextTestDat +a.xls'; #shift @ARGV or die "invocation: $0 <source file>"; my $source_excel = new Spreadsheet::ParseExcel; my $source_book = $source_excel->Parse($sourcename) or die "Could not open source Excel file $sourcename: $!"; my $storage_book; foreach my $source_sheet_number (0 .. $source_book->{SheetCount}-1) { my $source_sheet = $source_book->{Worksheet}[$source_sheet_number]; print "-----SHEET:", $source_sheet->{Name}, "\n"; # sanity checking on the source file: rows and columns should be sens +ible next unless defined $source_sheet->{MaxRow}; next unless $source_sheet->{MinRow} <= $source_sheet->{MaxRow}; next unless defined $source_sheet->{MaxCol}; next unless $source_sheet->{MinCol} <= $source_sheet->{MaxCol}; foreach my $row_index (0 .. $source_sheet->{MaxRow}) { foreach my $col_index (0 .. $source_sheet->{MaxCol}) { my $source_cell = $source_sheet->{Cells}[$row_index][$col_index]; if ($source_cell) { #print "( $row_index , $col_index ) =>", $source_cell->Value, "\n" +; $storage_book->{$source_sheet->{Name}}->{$row_index}->{$col_index} = + $source_cell->Value; } # end of source_cell check } # foreach col_index } # foreach row_index } # foreach source_sheet_number print "Perl recognized the following data (sheet/row/column order):\n" +; print Dumper( $storage_book ); print "Excel Content read successfully!\n";

In reply to Reading data from excel and create xml file using data by asha80

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.