Skip Menu | You are currently an anonymous guest. | Login | Return to Main | About rt.cpan.org
 

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.

X Report information
Id: 30368
Status: resolved
Worked: 30 min
Left: 0 min
Priority: 0/0
Queue: Spreadsheet-WriteExcel

Owner: Nobody
Requestors: zhur [...] yandex-team.ru
Cc:
AdminCc:

Severity: (no value)
Broken in: (no value)
Fixed in: 2.21



X History Display mode: Brief headersFull headers
#   Tue Oct 30 14:25:08 2007 zhur[...]yandex-team.ru - Ticket created  
Subject: Bug with utf-8 strings in Formula.pm
Date: Tue, 30 Oct 2007 21:24:14 +0300
To: bug-Spreadsheet-WriteExcel[...]rt.cpan.org
From: Sergey Zhuravlev <zhur[...]yandex-team.ru>
[text/plain 1.2k]
Hi,

WriteExcel make broken xls file if utf8 string used in formulas.

How to repeat:
Spreadsheet::WriteExcel->new(\*STDOUT)
->addworksheet()
->write_formula("A1", qq!="\x{43c}\x{430}\x{43c}\x{430}"!);

Suggested fix:
diff -U 7 -F '^sub ' -r
Spreadsheet-WriteExcel-2.20.orig/lib/Spreadsheet/WriteExcel/Formula.pm
Spreadsheet-WriteExcel-2.20/lib/Spreadsheet/WriteExcel/Formula.pm
---
Spreadsheet-WriteExcel-2.20.orig/lib/Spreadsheet/WriteExcel/Formula.pm
2007-10-30 20:52:45.584613634 +0300
+++ Spreadsheet-WriteExcel-2.20/lib/Spreadsheet/WriteExcel/Formula.pm
2007-10-30 20:55:05.152679214 +0300
@@ -515,14 +515,23 @@ sub _convert_string {
$str =~ s/""/"/g; # Substitute Excel's escaped double quote "" for "

my $length = length($str);

# TODO string length
die "String in formula has more than 255 chars\n" if $length > 255;

+ # encode utf strings
+ if ($] >= 5.008) {
+ require Encode;
+ if (Encode::is_utf8($str)) {
+ $encoding = 1;
+ $str = Encode::encode("UTF-16LE", $str);
+ }
+ }
+
return pack("CCC", $ptg{ptgStr}, $length, $encoding) . $str;
}


###############################################################################
#
# _convert_ref2d()



#   Mon Mar 10 05:46:46 2008 JMCNAMARA - Fixed in 2.21 added  
#   Mon Mar 10 05:46:51 2008 JMCNAMARA - Correspondence added  
[text/plain 69b]


Fixed in Spreadsheet::WriteExcel version 2.21.

Thanks,

John.
--

#   Mon Mar 10 05:46:55 2008 RT_System - Status changed from 'new' to 'open'  
#   Mon Mar 10 05:46:57 2008 JMCNAMARA - TimeWorked changed from (no value) to '30'  
#   Mon Mar 10 05:46:59 2008 JMCNAMARA - Status changed from 'open' to 'resolved'