1

How do you use Data::Table::Excel for converting .csv to .xls file format.

I want to do the conversion with the tables2xls subroutine:

my $t = Data::Table::fromFile("testresults-2013-07-01.csv");  
my @arr = $t->csv;  
Data::Table::Excel::tables2xls("results.xls", $t ,\@arr);

I tried the code above but I was not able get what I expected.

1 Answer 1

2

Last line must be:

Data::Table::Excel::tables2xls("results.xls", [$t] ,["Sheet name for your Table"]);

And here is colors example like you want:

Data::Table::Excel::tables2xls("results.xls", [$t] ,["Sheet name for your Table"], [["white","silver","gray"]]);
Sign up to request clarification or add additional context in comments.

3 Comments

wonderful, but need data encoded in windows cp1252 , with utf8 data I got encoding problems , any solution to work with utf8 data ?
@Sérgio give me more details please. What is your source CSV encoding and what XLS encoding you expect?
@gangabass I have to do , something like : open(FCSV, ">:encoding(cp1252)", "$file.csv"); print FCSV $csv->string(); my $table = Data::Table::fromFile("$file.csv"); Data::Table::Excel::tables2xlsx("$BASExlsx", [$table], ["something"], [["white","silver","gray"]]); or utf-8 characters appears double encoding

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.