【问题标题】:Perl Compilation error writing to .xlsx filePerl 编译错误写入 .xlsx 文件
【发布时间】:2015-03-25 20:15:26
【问题描述】:
 #!C:\Perl\bin
 #excel::writer attempt
 #allows IR-Serial-Parts tracking

 use strict;
 use warnings;
 use POSIX qw(strftime);
 use Excel::Writer::XLSX;
 use Spreadsheet::WriteExcel;


my $ref = strftime '%Y-%m-%d', localtime();     #create the datestamp
my $workbook;
my $worksheet;
my $i = 1;
my $ir = "IR Number: ";
my $sr = "UUT Serial: ";
my $pur = "How many parts used: ";
my $part = "Scan Part: ";
my @parts = "";


    if(-e 'tracking.xlsx'){
        my $workbook = Spreadsheet::WriteExcel->open('tracking.xlsx');  #open existing excel file

    }
    else{
        my $workbook = Excel::Writer::XLSX->new('tracking.xlsx');   #open new Excel if the date on comp has changed

    }
        $worksheet = $workbook->add_worksheet($ref);
        print $ir;  #ask user for IR #
        my $irs = <>;   #get user IR 
        print $sr;  #ask user for serial
        my $isr = <>;   #get serial from user
        print $pur; #get the number of parts used that way we can run the while loop below
        my $count = <>;

    While ($i < $count){

        print $part;
        my $scan = <>;
            push @parts, $scan;
            $i++;
        }




            $worksheet->write( 'A1', '$irs');
            $worksheet->write( 'A2', '$isr');
            $worksheet->write( 'A3', '@parts');

此脚本处于开发的第一阶段。而且我不是 perl 之神,事实上我是全新的,但它太棒了!!! 当我第一次运行时,我遇到了一些足够简单的错误,可以从错误消息中解决,但我似乎无法理解这一点,我觉得它应该比我以前的错误更容易修复,任何帮助解释为什么会这样正在发生会很棒!

 syntax error at writexcel.pl line 39, near "){"
 syntax error at writexcel.pl line 45, near "}"
 Execution of writexcel.pl aborted due to compilation errors.
 Press any key to continue . . .

【问题讨论】:

  • While -> while(全部小写;Perl 区分大小写)
  • 我不得不使用记事本,我什至无法说出谢谢你的帮助!

标签: perl excel-2007


【解决方案1】:

正如@ThisSuitIsBlackNot 指出我的while 循环中的while 被大写并且需要小写。感谢您的快速回复!

【讨论】:

    猜你喜欢
    • 2015-06-24
    • 2013-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    相关资源
    最近更新 更多