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 (Monsignor) 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.

    Regards,

    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();