Excel2txt. pl
#! /Usr/bin/perl
Use strict;
Use Spreadsheet: parseexcel;
My $ oexcel = new spreadsheet: parseexcel;
Die "Usage: \ n \ tperl $0 <XLS> xls.txt \ n" Unless @ argv;
My $ obook = $ oexcel-> parse ($ argv [0]);
My ($ IR, $ IC, $ owks, $ owkc );
For (my $ isheet = 0; $ isheet <$ obook-> {sheetcount}; $ isheet ++ ){
$ Owks = $ obook-> {worksheet} [$ isheet];
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 $ owkc-> value, "\ t" if ($ owkc );
}
Print "\ n ";
}
}
The input is in XLS format and is available under the cluster.
Txt2excel. pl
#! /Usr/bin/perl
Use strict;
Use encode QW (decode );
Use Spreadsheet: writeexcel;
My $ workbook = Spreadsheet: writeexcel-> New ("Maid 02.16.xls ");
My $ worksheet = $ workbook-> add_worksheet ();
# Row and column are zero indexed
My $ ROW = 0;
Open in, $ argv [0] Or die $ !;
While (<in> ){
Chomp; my @ s = split;
My $ Col = 0;
Foreach my $ token (@ s ){
$ Worksheet-> write_string ($ row, $ Col, decode ('gb2312', $ token ));
$ Col ++;
}
$ Row ++;
}
Close in;