Hi (hopefully John M)
I am playing around with this perl script
http://www.perlmonks.org/bare/?node_id=635437 which is great and uses some of your code to do the autofit part, but, changes I have made have stopped the autofit part working :( .. it was working with write(), and now doesnt work with write_text() .. its probably got something to do with the $token, but for the life of me I am not seeing why ..
The problem I had was that it was converting some of the colums that had an "E" in the CSV and truncating them, for example 44E0 became just 44 .. so to work around this I changed the write() to write_text() dumping the elements of the $row and looping through those to write each col of each row .. I also set some format globally
##-- global
my $format = $workbook->add_format(
bold => 0,
color => 'black',
size => 8,
valign => 'vcentre',
align => 'left',
num_format => 0x31,
);
$worksheet->keep_leading_zeros();
##--end global
The into the data loop ... this line ...
##--data loop
$worksheet->write($i++, 0,$row,$format);
now becomes ....
my @columns2 = @{ $row }; # Dereferencing my array reference
my $k=0;
for my $column2 ( @columns2 ) {
print "DEBUG: row $i col $k $column2 \n" if $debug;
$worksheet->write_string($i, $k, "$column2" ,$format);
$k++;
}
$i++;
#auto fit colums
autofit_columns($worksheet);
#autofilter
$worksheet->autofilter('A1:M19999');
##--end of data loop
So, the question is, any idea why the new method may have stopped the auto fit cols working ?
Any help greatly appreciated .. many thanks in advance
Mark