Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

printing Chinese, Japanese, french Text in excel using perl

by perl-nun (Initiate)
on Jul 29, 2013 at 09:16 UTC ( #1046802=perlquestion: print w/replies, xml ) Need Help??
perl-nun has asked for the wisdom of the Perl Monks concerning the following question:

I have a string($str) that has some chinese, french and japanese text(in the same string) that are read from the Database. It is read correctly which I am able to verify by printing in the web page directly. But I am not able to write it in a excel file. Tried this:
@arr = split(',',$str); $arrayref = \@arr;

Now, when I try to print it, using :
 $worksheet->write_row($count,0,$arrayref); I get question marks in the place of special characters. So I tried : $str = encode("utf8",$str); . Still the same problem persists. Someone kindly guide me as how to do it.

Replies are listed 'Best First'.
Re: printing Chinese, Japanese, french Text in excel using perl
by davies (Parson) on Jul 29, 2013 at 11:52 UTC

    Your symptoms seem the same as the ones I experienced when writing Re: Extracting Chinese characters from Excel. I shouldn't be surprised if you needed some VBA to solve your problem. It was the only way I could make it work. You won't be able to do this with things like Spreadsheet::WriteExcel; you will need Win32::OLE.


    John Davies

      @All : Thank you! I just did it by using the decode function in Encode module.
      use Encode qw(decode encode); $str = decode("utf8",$str);
      This did it all! Thanks again!
Re: printing Chinese, Japanese, french Text in excel using perl (modulename)
by Anonymous Monk on Jul 29, 2013 at 09:22 UTC
    What is $worksheet? This is critical information
      Its a page in excel workbook.
      my $workbook = Spreadsheet::WriteExcel->new('perl.xls'); $worksheet = $workbook->add_worksheet();

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1046802]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (9)
As of 2016-10-21 17:03 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (289 votes). Check out past polls.