----- Original Message -----
From: "William Martell" <[EMAIL PROTECTED]>
To: "perl-win32-users" <[EMAIL PROTECTED]>
Sent: Thursday, December 18, 2003 11:24 AM
Subject: Win32::OLE, Simple Question


> Hello All,
>
> Could anyone help me with this script.  I am trying to write an excel file
> with these column headers:
>
> 'cus_id', 'customer_name', 'current', 'days1thru30', 'days31thru60',
> 'days61thru90', 'over_90', 'on_hold', 'unap_cash', 'total_a_r'
>
> and under these headers I want to write rows of data.
> The data is held line by line in @columns array.
>
> This code does not work b/c it writes all the data on
> row 2 column A.  Which is exactly what I am telling it
> to do, I know.  But, I am trying to tell it to write
> one row of data and go to the next line or row and
> write the next row of data, over and over again
> until all the contents information is written.
>
> FYI.  artb46.da7 is a printed text report.
>
> Thank you all very much for your assistance.
> Will
> Dallas
>
>
>
>
> #!/perl
> # Perl script to read artb46.da7 printed report
> # takes all values and places them in excel
> # spreadsheet under date and report name
> # multiple sheets are added, one per day
>
> # NOTE: you should make a copy, don't work on the original
> use Win32::OLE;
>
>
>
> Win32::OLE::CreateObject("Excel.Application", $xl) ||
>     die "CreateObject: $!";
> # show it and add a new workbook
> $xl->{Visible} = 1;
> $xl->Workbooks->Add();
> #$x1->Cells.Select;
> #    Selection.NumberFormat = "@";
>
> open (INFILE, "artb46_short.da7") || die "Can't open artb46.da7 file.";
>
>
>
> @header = ('cus_id', 'customer_name', 'current', 'days1thru30',
> 'days31thru60', 'days61thru90', 'over_90', 'on_hold', 'unap_cash',
> 'total_a_r');
>
> # start at the top left
> $col = "A"; $row = 1;
> foreach $header (@header) {
>     $cell = sprintf("%s%d", $col++, $row);
>     # add it to Excel
>     $xl->Range($cell)->{Value}  = $header;
>
> }
>
>
> while($line = <INFILE>){
>
>
> $cus_id = substr($line, 0, 6);
> $customer_name = substr($line, 7, 17);
> $current = substr($line, 26, 12);
> $days1thru30 = substr($line, 40, 12); #plus 11 (size column) plus 3 size
> space
> $days31thru60 = substr($line, 54, 12);
> $days61thru90 = substr($line, 68, 12);
> $over_90 = substr($line, 82, 12);
> $on_hold = substr($line, 96, 12);
> $unap_cash = substr($line, 108, 12);
> $total_a_r = substr($line, 120, 12);
>
> @column = ($cus_id, $customer_name, $current, $days1thru30, $days31thru60,
> $days61thru90,
> $over_90, $on_hold, $unap_cash, $total_a_r);
>
> $col = "A";
> $row = 2;
> foreach $column (@column) {
>     $cell = sprintf("%s%d", $col++, $row);
>     # add it to Excel
>     $xl->Range($cell)->{Value}  = $column;
>     }
>
>
> }
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to