Using perl Syntax Highlighting
- #!c:/perl/bin/perl.exe
- use Win32::OLE;
- if ($ENV{'REQUEST_METHOD'} eq 'POST') {
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
- @pairs = split(/&/, $buffer);
- foreach $pair (@pairs) {
- ($name, $value) = split(/=/, $pair);
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
- $FORM{$name} = $value;
- }
- eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
- die "Excel not installed" if $@;
- unless (defined $ex) {
- $ex = Win32::OLE->new('Excel.Application', sub {$_[0]->Quit;})
- or die "Oops, cannot start Excel";
- }
- $writeBook = $ex->Workbooks->Open("C:\\Program Files\\Apache Group\\Apache2\\htdocs\\Excel\\credencialMacro.xls");
- $readBook = $ex->Workbooks->Open("C:\\Program Files\\Apache Group\\Apache2\\htdocs\\Excel\\Book2.xls");
- $writeSheet = $writeBook->Worksheets("BD");
- $writeSheet->Activate();
- $readSheet = $readBook->Worksheets("Sheet2");
- $readSheet->Activate();
- my $Tot_Rows = $readSheet->UsedRange->Rows->{'Count'};
- my $rows = 1;
- while($rows <= $Tot_Rows){
- $writeSheet->Cells($rows,2)->{Value} = $readSheet -> Cells($rows,1) -> {Value};
- $rows++;
- }
- $ex->{DisplayAlerts} = 0; # alerts Off
- $writeBook->{CheckCompatibility} = "False";
- $ex->Run('credencialMacro.xls!creaCredencial');
- undef $readBook;
- $writeBook->SaveAs( 'C:\\Program Files\\Apache Group\\Apache2\\htdocs\\Excel\\Descargas\\credencialMacro.xls' );
- undef $writeBook;
- undef $ex;
- }
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4
Este código lee dos excel y copia el contenido de uno a otro. Pero me manda el error: Premature end of script headers.
¡¡¡ Auxilio !!!