First of all you should convert your code using a loop, like below. Then it gets tidy enough to make changes fast and avoid a lot of minor errors which are likely in repetitive code.
Should your output be XML ("output.xml")? Because it isn't yet. Have a look on XML::Simple's function xmlout() for that.
my @CELLS = ( 'pisbn', 'isbn', 'rendition', ...); my %bookdata; # [...] for my $n (0..13) { if($cell = $sheet->{Cells}[$i][$n]) { my $val = $cell->{Val}; #If you would need the data for later: $bookdata{@CELLS[$n]} = $val; #print"\n--", $val; $getfile = $val; } }
PS: Could you use <readmore> tags for code of this length in the future, please.
Update: Are you aware that your code overwrites the output file for every row ($i iteration) and sheet? This could be one of you main problems.
In reply to Re: read excel data and write into *.txt file
by mscharrer
in thread Read Excel cell
by senthil_v
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |