Thanks diotalevi!

I've problems binding the values from the parsed Excel file to the DBI execute command. How exactly do I bind those values?

use strict; use Spreadsheet::ParseExcel; use Data::Dumper; my $source_file = 'C:/mydocu~1/db/jokes.xls'; my $source_excel = new Spreadsheet::ParseExcel; my $source_book = $source_excel->Parse($source_file); my $dbh = do_connect(); my $sql = "INSERT INTO mytest VALUES(?,?,?,?); my $sth = $dbh->prepare($sql); # code lifted from a site... my($iR, $iC, $oWkS, $oWkC); foreach my $oWkS (@{$source_book->{Worksheet}}) { for(my $iR = $oWkS->{MinRow} ; defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; $iR++) { for(my $iC = $oWkS->{MinCol} ; defined $oWkS->{MaxCol} && $iC <= $oWkS->{MaxCol} ; $iC++) { $oWkC = $oWkS->{Cells}[$iR][$iC]; print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC); + } } } # $sth->execute(var1, var2, var3, var4); # I know the above line has to be somewhere in the foreach loop but I +just can't figure how :(
cheers,

In reply to Re: Re: From excel to mysql... by kiat
in thread From excel to mysql... by kiat

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.