473,473 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do i transfer data to an excel sheet?

170 New Member
hi to all,

i'm having problems with a perl programe, i'm very new to it.
currently my script output data to a excel file, however i need to group the datas into boxes, pls help
Jan 23 '08 #1
8 2103
nithinpes
410 Recognized Expert Contributor
hi to all,

i'm having problems with a perl programe, i'm very new to it.
currently my script output data to a excel file, however i need to group the datas into boxes, pls help

Go through DBD::Excel and Spreadsheet::WriteExcel modules in CPAN. They may be of help.
Jan 23 '08 #2
poolboi
170 New Member
hm...so i have to install the spreadsheet::excel module right? if not it won't work

here's my program not sure if it will help u to see the problem


Expand|Select|Wrap|Line Numbers
  1. #####    START OF MAIN PROGRAM    #####
  2. #####    LIST OF PARAMETERS    #####
  3.  
  4.  
  5.     @parameters = qw/MO /;
  6.  
  7.             # Please add in the neccessary fields here!!!
  8.                                         # Field name is case-sensitive!!!
  9.  
  10.  
  11.  
  12.  
  13. #####    WELCOME MESSAGE    ####
  14.  
  15.     print "\nWelcome to SMSC STATISTICS!\n";                    
  16.  
  17. #####    REQUEST NAME OF SMSC USED    #####
  18.  
  19.     print "\nPlease enter the name of the SMSC used (1, 2 , 3, 4 or 5):\n";
  20.     $smsc_name = <STDIN>;
  21.     $smsc_name = $smsc_name * 1;
  22.  
  23.     if ($smsc_name == "1")
  24.     { $max_pk_msg = 140;}
  25.  
  26.     if ($smsc_name == "2")
  27.     {$max_pk_msg = 40;}
  28.  
  29.     if ($smsc_name == "3")
  30.     {$max_pk_msg = 100;}
  31.  
  32.     if ($smsc_name == "4")
  33.     {$max_pk_msg = 80;}
  34.  
  35.     if ($smsc_name == "5")
  36.     {$max_pk_msg = 100;}
  37.  
  38. #####    REQUEST NAME OF FILE USED        #####
  39.  
  40.     print "\nPlease enter the date used to compute the statistics <yymmdd : e.g. 020222>:\n";
  41.     $file_name = <STDIN>;
  42.     $rev_file_name = scalar reverse $file_name;
  43.     $file_name = scalar reverse substr($rev_file_name,1);
  44.     $file_name1 = "DR"."$file_name".".PRT";
  45.     open (FILE1,"$file_name1") || die "Couldn't OPEN $file_name!!!\n\n";  
  46.  
  47. #####    REQUEST NAME OF ADDITIONAL FIELDS    #####
  48.  
  49.     $a = 0;
  50.  
  51.     do
  52.     {
  53.     print "\nPlease enter the name of the additional field to be computed (Case-Sensitive!)\n";
  54.     print "(Press 1 to exit!):\n";
  55.     $add_field = <STDIN>;
  56.     $rev_add_field = scalar reverse $add_field;
  57.     $add_field = scalar reverse substr($rev_add_field,1);
  58.  
  59.         if ($add_field == "1")
  60.         {
  61.         $a = 1;
  62.         }
  63.  
  64.         if ($add_field != "1")
  65.         {
  66.         push @parameters, "$add_field";
  67.         }
  68.  
  69.     }while ($a < 1);
  70.  
  71.  
  72. #####    OPENING OF FILE    #####
  73.  
  74.     undef $/;
  75.     open (FILE1,"$file_name1") || die "Couldn't OPEN $file_name!!!\n";      
  76.     $_ = <FILE1>;
  77.     $original = $_;                                              
  78.     close(FILE1) || die "Couldn't CLOSE $file_name properly!!!\n";                    
  79.  
  80.     push @output, "Date,Total (IN),Succ (IN),Pk (IN)/Hrs,Pk (OUT)/Hrs,Peak Hour,Total (OUT),Succ (OUT),";
  81.  
  82.     foreach(@parameters)
  83.     {
  84.     push @output, "$_ (In),$_ (Out),";
  85.     }
  86.  
  87.     push @output, "Pk Msg/sec,Max Pk Msg/sec\n";
  88.  
  89. #####    OBTAINING DATE    #####
  90.  
  91.     $length_date = index($original,"From (local)");                
  92.     $date_line = substr($original,($length_date + 14));
  93.     $rev_date = scalar reverse $date_line;                
  94.     $date = scalar reverse substr($rev_date,-8);
  95.  
  96.     $day = scalar reverse substr($rev_date,-2);
  97.  
  98.     $date1 = scalar reverse $rev_date;
  99.     $date2 = substr($date1,3);
  100.     $rev_month = scalar reverse $date2;    
  101.     $month = scalar reverse substr($rev_month,-2);
  102.  
  103.     $save_file_name= "smsc"."$smsc_name"."_"."$month"."$day".".xls";
  104.  
  105. #####    OBTAINING SUCC IN    #####
  106.  
  107.     $length_succ_in = index($original,"SUBMIT successful");    
  108.     $succ_in_line = substr($original,($length_succ_in + 19));
  109.  
  110.     $length_succ_in1 = index($succ_in_line,"\n");    
  111.     print "SUCC LENGTH=$length_succ_in1\n";
  112.     $rev_succ_in = scalar reverse $succ_in_line;                
  113.     $succ_in = scalar reverse substr($rev_succ_in,-$length_succ_in1);
  114.  
  115.  
  116. #####    OBTAINING TOTAL IN    #####
  117.  
  118.     $length_total_in = index($succ_in_line,"Total");
  119.     $total_in_line = substr($succ_in_line,($length_total_in + 7));
  120.  
  121.     $length_total_in1 = index($total_in_line,"\n");    
  122.     $rev_total_in = scalar reverse $total_in_line;                
  123.     $total_in = scalar reverse substr($rev_total_in,-$length_total_in1);
  124.  
  125.  
  126.  
  127. #####    OBTAINING SUCC OUT (Part 1)    #####
  128.  
  129.     $length_succ_out_p1 = index($succ_in_line,"DELIVER successful");    
  130.     $succ_out_line_p1 = substr($succ_in_line,($length_succ_out_p1 + 20));
  131.  
  132.     $length_succ_out_p11 = index($succ_out_line_p1,"\n");    
  133.     $rev_succ_out_p1 = scalar reverse $succ_out_line_p1;                
  134.     $succ_out_p1 = scalar reverse substr($rev_succ_out_p1,-$length_succ_out_p11);
  135.  
  136. #####    OBTAINING TOTAL OUT (Part 1)    #####
  137.  
  138.     $length_total_out_p1 = index($succ_out_line_p1,"Total");    
  139.     $total_out_line_p1 = substr($succ_out_line_p1,($length_total_out_p1 + 7));
  140.  
  141.     $length_total_out_p11 = index($total_out_line,"\n");    
  142.     $rev_total_out_p1 = scalar reverse $total_out_line_p1;                
  143.     $total_out_p1 = scalar reverse substr($rev_total_out_p1,-$length_total_out_p11);
  144.  
  145. #####    OBTAINING SUCC OUT (Part 2)    #####
  146.  
  147.     $length_succ_out_p2 = index($total_out_line_p1,"Status rep. deliv. successful");    
  148.     $succ_out_line_p2 = substr($total_out_line_p1,($length_succ_out_p2 + 31));
  149.  
  150.     $length_succ_out_p21 = index($succ_out_line_p2,"\n");    
  151.     $rev_succ_out_p2 = scalar reverse $succ_out_line_p2;                
  152.     $succ_out_p2 = scalar reverse substr($rev_succ_out_p2,-$length_succ_out_p21);
  153.  
  154. #####    OBTAINING TOTAL OUT (Part 2)    #####
  155.  
  156.     $length_total_out_p2 = index($succ_out_line_p2,"Total");    
  157.     $total_out_line_p2 = substr($succ_out_line_p2,($length_total_out_p2 + 7));
  158.  
  159.     $length_total_out_p21 = index($total_out_line,"\n");    
  160.     $rev_total_out_p2 = scalar reverse $total_out_line_p2;                
  161.     $total_out_p2 = scalar reverse substr($rev_total_out_p2,-$length_total_out_p21);
  162.  
  163. #####    OBTAINING SUCC OUT (Part 3)    #####
  164.  
  165.     $length_succ_out_p3 = index($total_out_line_p2,"Status rep. deliv. successful");    
  166.     $succ_out_line_p3 = substr($total_out_line_p2,($length_succ_out_p3 + 31));
  167.  
  168.     $length_succ_out_p31 = index($succ_out_line_p3,"\n");    
  169.     $rev_succ_out_p3 = scalar reverse $succ_out_line_p3;                
  170.     $succ_out_p3 = scalar reverse substr($rev_succ_out_p3,-$length_succ_out_p31);
  171.  
  172. #####    OBTAINING TOTAL OUT (Part 3)    #####
  173.  
  174.     $length_total_out_p3 = index($succ_out_line_p3,"Total");    
  175.     $total_out_line_p3 = substr($succ_out_line_p3,($length_total_out_p3 + 7));
  176.  
  177.     $length_total_out_p31 = index($total_out_line,"\n");    
  178.     $rev_total_out_p3 = scalar reverse $total_out_line_p3;                
  179.     $total_out_p3 = scalar reverse substr($rev_total_out_p3,-$length_total_out_p31);
  180.  
  181. #####    OBTAINING SUCC OUT     #####    
  182.  
  183.     $succ_out = $succ_out_p1 + $succ_out_p2 + $succ_out_p3;        
  184.  
  185. #####    OBTAINING TOTAL OUT     #####
  186.  
  187.     $total_out = $total_out_p1 + $total_out_p2 + $total_out_p3;
  188.  
  189.  
  190.  
  191. #####    OBTAINING SUBMIT PARAGRAPH    #####
  192.  
  193.     $length_submit = index($original,"Submissions by hour of day");    
  194.     $submit = substr($original,$length_submit);
  195.  
  196.     $length_submit1 = index($submit,"Successful deliveries by application and hour of day");
  197.     $rev_submit = scalar reverse $submit;                
  198.     $submit_para = scalar reverse substr($rev_submit,-$length_submit1);
  199.  
  200. #####    OBTAINING DELIVERY PARAGRAPH        #####
  201.  
  202.     $length_delivery = index($original,"Successful deliveries by application and hour of day");    
  203.     $delivery = substr($original,$length_delivery);
  204.  
  205.     $length_delivery1 = index($delivery,"Failed delivery attempts by application and hour of day");
  206.     $rev_delivery = scalar reverse $delivery;                
  207.     $delivery_para = scalar reverse substr($rev_delivery,-$length_delivery1);
  208.  
  209.  
  210. #####    OBTAINING VARIOUS IN PARAMETERS        #####
  211.  
  212.     $l = 0;
  213.  
  214.     foreach(@parameters)
  215.     {
  216.     $length = length($_);
  217.     $length_parameters = index($submit_para,$_);
  218.     $parameters_req_para = substr($submit_para,$length_parameters);
  219.     $rev_parameters = scalar reverse $submit_para;
  220.     $parameters_line = substr($rev_parameters,-($length_parameters + $length));
  221.  
  222.     $length_parameters1 = index($parameters_line,"\n");
  223.     $rev_parameters1 = scalar reverse $parameters_line;
  224.     $parameters_line1 = substr($rev_parameters1,-$length_parameters1);
  225.  
  226.     $length_parameters2 = index($parameters_line1,$_) + $length;
  227.  
  228.     $length_total = index($parameters_req_para,"          Total ");
  229.     $total_line = substr($parameters_req_para,$length_total);
  230.  
  231.     $rev_total = scalar reverse $total_line; 
  232.     $total_line1 = scalar reverse substr($rev_total,-$length_parameters2);
  233.  
  234.     $parameter_in_value[$l] = substr($total_line1,-10);
  235.  
  236.     $parameter_in_array{$_} = $parameter_in_value[$l];
  237.  
  238.     $l++;
  239.     }
  240.  
  241. #####    OBTAINING VARIOUS OUT PARAMETERS    #####
  242.  
  243.     $l = 0;
  244.  
  245.     foreach(@parameters)
  246.     {
  247.     $length = length($_);
  248.     $length_parameters = index($delivery_para,$_);
  249.     $parameters_req_para = substr($delivery_para,$length_parameters);
  250.     $rev_parameters = scalar reverse $delivery_para;
  251.     $parameters_line = substr($rev_parameters,-($length_parameters + $length));
  252.  
  253.     $length_parameters1 = index($parameters_line,"\n");
  254.     $rev_parameters1 = scalar reverse $parameters_line;
  255.     $parameters_line1 = substr($rev_parameters1,-$length_parameters1);
  256.  
  257.     $length_parameters2 = index($parameters_line1,$_) + $length;
  258.  
  259.     $length_total = index($parameters_req_para,"          Total ");
  260.     $total_line = substr($parameters_req_para,$length_total);
  261.  
  262.     $rev_total = scalar reverse $total_line; 
  263.     $total_line1 = scalar reverse substr($rev_total,-$length_parameters2);
  264.  
  265.     $parameter_out_value[$l] = substr($total_line1,-10);
  266.  
  267.     $parameter_out_array{$_} = $parameter_out_value[$l];
  268.  
  269.     $l++;
  270.     }
  271.  
  272. #####     TESTING
  273.  
  274. #####    OBTAINING PEAK IN Traffics            #####
  275.  
  276.     print "Obtaining Peak AO\n";
  277.     $length_pk_in = index($submit_para,"MO        AO   MO Flex   AO Flex     Total");    
  278. #    $length_pk_in = index($submit_para,"Submissions by hour of day");    
  279.     $pk_in_line = substr($submit_para,$length_pk_in);
  280.  
  281.     @hours = qw/00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23/;
  282.  
  283.     $l = 0;
  284.  
  285.         foreach (@hours)
  286.         {
  287.         $length_pk_in = index($pk_in_line,"$_ ");
  288.  
  289.         $pk_in_line = substr($pk_in_line,($length_pk_in + 2));
  290.  
  291.         $length_pk_in1 = index($pk_in_line,"\n");
  292.         $rev_pk_in = scalar reverse $pk_in_line;                
  293.         $apps_hours_in[$l] = scalar reverse substr($rev_pk_in,-$length_pk_in1);
  294.         $apps_hours_in[$l] = substr($apps_hours_in[$l],44);
  295.         $in_apps_hours{$apps_hours_in[$l]} = $_;
  296.  
  297.         print "apps_hours_in[$l] as $apps_hours_in[$l]\n";
  298.         $l++;
  299.         }
  300.  
  301.     sub numerically { $b <=> $a; }
  302.  
  303.     @pk_in_apps = sort numerically @apps_hours_in;
  304.  
  305.     $pk_in = $pk_in_apps[0];
  306.     $pk_hour = $in_apps_hours{$pk_in_apps[0]} * 100;
  307.     $pk_hour_dur = $pk_hour + 100;
  308.  
  309.         if ($pk_hour_dur == "2400") 
  310.         { 
  311.         $pk_hour_dur = "0000";
  312.         }
  313.     print "Peak IN (MO+AO) in as $pk_in at $pk_hour.\n";
  314. ########################
  315.  
  316.  
  317.  
  318. #####    OBTAINING PEAK OUT            #####
  319.  
  320.     $length_pk_out = index($delivery_para,"All applications");    
  321.     $pk_out_line = substr($delivery_para,$length_pk_out);
  322.  
  323.     @hours = qw/00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23/;
  324.  
  325.     $l = 0;
  326.  
  327.         foreach (@hours)
  328.         {
  329.         $length_pk_out = index($pk_out_line,"$_ ");
  330.         $pk_out_line = substr($pk_out_line,($length_pk_out + 2));
  331.  
  332.         $length_pk_out1 = index($pk_out_line,"\n");
  333.         $rev_pk_out = scalar reverse $pk_out_line;                
  334.         $apps_hours_out[$l] = scalar reverse substr($rev_pk_out,-$length_pk_out1);
  335.         $l++;
  336.         }
  337.  
  338.     sub numerically { $b <=> $a; }
  339.  
  340.     @pk_out_apps = sort numerically @apps_hours_out;
  341.     $pk_out = $pk_out_apps[0];
  342.  
  343.  
  344.  
  345. #####    OBTAINING PEAK MESSAGE/SEC        #####
  346.  
  347.     $pk_msg = $pk_in_apps[0] / 3600;
  348.  
  349. #####    PRINTING RESULT TO FILE            #####
  350.  
  351.     open (OUTPUT,">$save_file_name") || die "Couldn't OPEN $save_file_name!!!\n"; 
  352.  
  353.     push @output, "$date,$total_in,$succ_in,$pk_in,$pk_out,$pk_hour - $pk_hour_dur hr,$total_out,$succ_out,";
  354.  
  355.     foreach(@parameters)
  356.     {
  357.     push @output, "$parameter_in_array{$_},$parameter_out_array{$_},";
  358.     }
  359.  
  360.  
  361.     print OUTPUT @output;
  362.     printf (OUTPUT "%.2f,$max_pk_msg\n",$pk_msg);
  363.  
  364.     close(OUTPUT) || die "Couldn't CLOSE $save_file_name properly!!!\n";                
  365.  
  366.     print "\nPlease remember to collect your file at $save_file_name!\n";
  367.     print "\nThank you for using STARHUB SMSC STATISTICS!\n\n";         
  368.  
  369. #####    END OF PROGRAM                #####
  370.  
Basically, the output is to an excel file....think i just need to modify the last part, yeah
thanks



;
Jan 24 '08 #3
poolboi
170 New Member
sorrie for the long post
but i pretty much figured out how to export to excel using win32::OLE
cos using Spreadsheet:Excel i have to install extra modules in

but now if i need to append data into my program using win32::OLE, is it possible?
pls advise guys, thanks
Jan 24 '08 #4
nithinpes
410 Recognized Expert Contributor
If your objective is to type the data into separate cells and format the output into columns and rows, keep in mind the action of following escape sequences in Excel sheet:

\t - will move to next adjacent cell(in the same row)
\n - will move to next line ( to next row)

In the this line of your code,
Expand|Select|Wrap|Line Numbers
  1. push @output, "$date,$total_in,$succ_in,$pk_in,$pk_out,$pk_hour -$pk_hour_dur hr,$total_out,$succ_out,";
  2.  
you are pushing the variables as a single comma separated string. If you want them to be separate elements inorder to print them in separate columns, modify it as below:

Expand|Select|Wrap|Line Numbers
  1. push @output, ($date,$total_in,$succ_in,$pk_in,$pk_out,$pk_hour -$pk_hour_dur hr,$total_out,$succ_out);
  2.  
To print the contents use:
Expand|Select|Wrap|Line Numbers
  1. print "$_\t" foreach(@output);   
  2. ### instead of: print OUTPUT @output;
  3.  print "\n" ; ## will move to next row
  4.  
Apart from this, if you want to do advanced level of formatting like printing particular data into a specific cell, you have to use Spreadsheet::WriteExcel.

Note: If you want to pass all records in an array, you have to create a two-dimensional array. Each element in the array being a list of data to be printed in each row.
Jan 24 '08 #5
poolboi
170 New Member
ok i've actually done it in another way where particular values are assigned to specified cells using win32::OLE
here's what i've done:

Expand|Select|Wrap|Line Numbers
  1. use Win32::OLE;
  2.  
  3.         # use existing instance if Excel is already running
  4.         eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
  5.         die "Excel not installed" if $@;
  6.         unless (defined $ex) {
  7.             $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
  8.                     or die "Oops, cannot start Excel";
  9.         }
  10.  
  11.  
  12.         # get a new workbook
  13.         $book = $ex->Workbooks->Add;
  14.     $sheet = $book->Worksheets(1);
  15.  
  16.         # write a 2 rows by 3 columns range
  17.         $sheet->Range("A1:J2")->{Value} = [['Date','Total (IN)','Succ (IN)','Pk (IN)/Hrs','Pk (OUT)/Hrs','Peak Hour','Total (OUT)','Succ (OUT)','MO(IN)','MO(OUT)'],
  18.                                            [$date, $total_in, $succ_in,$pk_in,$pk_out,"$pk_hour - $pk_hour_dur hr",$total_out,$succ_out ]];
  19.  
  20.     $sheet->Range("K1:L2")->{Value} = [['Pk Msg/sec','Max Pk Msg/sec'],
  21.                       [$max_pk_msg,$pk_msg]];
  22.  
  23.     $sheet->Cells(3,10)->{Value} = [$save_file_name];
  24.     foreach(@parameters)
  25.     {
  26.     $sheet->Cells(2,9)->{Value} = [$parameter_in_array{$_}];
  27.     $sheet->Cells(2,10)->{Value} = [$parameter_out_array{$_}];
  28.     }
  29.  
  30.         # print "XyzzyPerl"
  31.         $array = $sheet->Range("A2:I1")->{Value};
  32.         for (@$array) {
  33.             for (@$_) {
  34.                 print defined($_) ? "$_|" : "<undef>|";
  35.             }
  36.             print "\n";
  37.         }
  38.  
  39.         # save and exit
  40.  
  41.          $book->SaveAs ('C:\Documents and Settings\clong\Desktop\perl\$save_file_name.xls') ;
  42.         undef $book;
  43.         undef $ex;
  44.  
now any idea if say i wanna save $save_file_name as i've declared earlier?
cos they just save it as $save_file_name
however i declared $save_file_name as smsc_0101 in my earlier program
advise pls?

thanks
Jan 25 '08 #6
nithinpes
410 Recognized Expert Contributor
ok i've actually done it in another way where particular values are assigned to specified cells using win32::OLE
here's what i've done:

Expand|Select|Wrap|Line Numbers
  1. use Win32::OLE;
  2.  
  3.         # use existing instance if Excel is already running
  4.         eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
  5.         die "Excel not installed" if $@;
  6.         unless (defined $ex) {
  7.             $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
  8.                     or die "Oops, cannot start Excel";
  9.         }
  10.  
  11.  
  12.         # get a new workbook
  13.         $book = $ex->Workbooks->Add;
  14.     $sheet = $book->Worksheets(1);
  15.  
  16.         # write a 2 rows by 3 columns range
  17.         $sheet->Range("A1:J2")->{Value} = [['Date','Total (IN)','Succ (IN)','Pk (IN)/Hrs','Pk (OUT)/Hrs','Peak Hour','Total (OUT)','Succ (OUT)','MO(IN)','MO(OUT)'],
  18.                                            [$date, $total_in, $succ_in,$pk_in,$pk_out,"$pk_hour - $pk_hour_dur hr",$total_out,$succ_out ]];
  19.  
  20.     $sheet->Range("K1:L2")->{Value} = [['Pk Msg/sec','Max Pk Msg/sec'],
  21.                       [$max_pk_msg,$pk_msg]];
  22.  
  23.     $sheet->Cells(3,10)->{Value} = [$save_file_name];
  24.     foreach(@parameters)
  25.     {
  26.     $sheet->Cells(2,9)->{Value} = [$parameter_in_array{$_}];
  27.     $sheet->Cells(2,10)->{Value} = [$parameter_out_array{$_}];
  28.     }
  29.  
  30.         # print "XyzzyPerl"
  31.         $array = $sheet->Range("A2:I1")->{Value};
  32.         for (@$array) {
  33.             for (@$_) {
  34.                 print defined($_) ? "$_|" : "<undef>|";
  35.             }
  36.             print "\n";
  37.         }
  38.  
  39.         # save and exit
  40.  
  41.          $book->SaveAs ('C:\Documents and Settings\clong\Desktop\perl\$save_file_name.xls') ;
  42.         undef $book;
  43.         undef $ex;
  44.  
now any idea if say i wanna save $save_file_name as i've declared earlier?
cos they just save it as $save_file_name
however i declared $save_file_name as smsc_0101 in my earlier program
advise pls?

thanks
Assign the value of $save_file_name as in your previous script.
Change this line in your code:
Expand|Select|Wrap|Line Numbers
  1.    $book->SaveAs ('C:\Documents and Settings\clong\Desktop\perl\$save_file_name.xls') ;
  2.  
to :
Expand|Select|Wrap|Line Numbers
  1.    $book->SaveAs ("C:\\Documents and Settings\\clong\\Desktop\\perl\\$save_file_name.xls") ;
  2.  
If you use single quotes, the string inside it will be taken as literal string. There won't be any substitutions.
Use double quotes for substiotution and escape the backslashes so that they are taken as actual backslash (to avoid misinterpretation with escape sequences).
Jan 25 '08 #7
nithinpes
410 Recognized Expert Contributor
Assign the value of $save_file_name as in your previous script.
Change this line in your code:
Expand|Select|Wrap|Line Numbers
  1.    $book->SaveAs ('C:\Documents and Settings\clong\Desktop\perl\$save_file_name.xls') ;
  2.  
to :
Expand|Select|Wrap|Line Numbers
  1.    $book->SaveAs ("C:\\Documents and Settings\\clong\\Desktop\\perl\\$save_file_name.xls") ;
  2.  
If you use single quotes, the string inside it will be taken as literal string. There won't be any substitutions.
Use double quotes for substiotution and escape the backslashes so that they are taken as actual backslash (to avoid misinterpretation with escape sequences).
Jan 25 '08 #8
poolboi
170 New Member
thank you very much!

it work! right i need to know how to append my info now...any problems i will get back again..thanks once again
Jan 25 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ilan | last post by:
Hi all I need to add data from two Excel sheets (both on the same workbook) to an existing table in my SQL DB. The problem is that each sheet holds different fields for the same record, though...
2
by: Niyazi | last post by:
Hi, I have to retrieve a data from AS400 DB2 and after working with data I have to export into one of existing Excel file. I can connect into specific library in AS400 DB2 using AS400...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
11
by: Hi5 | last post by:
Hi, I am new to access I usedto work in Oracle and Mysql. I am after a way that enables me to populate a database I designed in access with lots of data which can be sorted in excel sheets, ...
5
by: hmiller | last post by:
Hey there folks: I have been trying to get this work for about a week now. I'm new to VBA... I am trying to transfer a populated table in Access to an existing, but blank, Excel worksheet. I...
1
by: tamatem | last post by:
I have an excel sheet that contain colummns as in a table in a sql data base i want to transfer this data from the sheet to the table from business logic code layer not from the enterprise manager...
2
by: cyberdwarf | last post by:
Hi I need to pull data from an Excel worksheet to a data table, using Access & VBA. I am trying to use the "DoCmd.TransferSpreadsheet acImport" method, but... My problem is that the sheet...
1
by: is49460 | last post by:
Good afternoon! I use transfer spreadsheet function the export data from one of the table into the excel spreat sheet. I use the following code: DoCmd.TransferSpreadsheet acExport, 8, "qry...
5
by: billa856 | last post by:
Hi I am totaly new to MS Access. I have one worksheet in excel in which I have data of company's inventory. I want to know can I transfer data from a form made in MS Access to the Excel worksheet?...
2
by: shalskedar | last post by:
In the excel sheet attached below can the particular data b transfered to Access. The data is more of the dimensions data i.e the tabular data in the sheet has to go to Access...Based on the data...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.