This queue is for tickets about the Spreadsheet-WriteExcel CPAN distribution.
Maintainer(s)' notes
If you are reporting a bug in Spreadsheet::WriteExcel here are some pointers
1) State the issues as clearly and as concisely as possible. A simple program or Excel test file (see below) will often explain the issue better than a lot of text.
2) Provide information on your system, version of perl and module versions. The following program will generate everything that is required. Put this information in your bug report.
#!/usr/bin/perl -w
print "\n Perl version : $]";
print "\n OS name : $^O";
print "\n Module versions: (not all are required)\n";
my @modules = qw(
Spreadsheet::WriteExcel
Parse::RecDescent
File::Temp
OLE::Storage_Lite
IO::Stringy
Spreadsheet::ParseExcel
Scalar::Util
Unicode::Map
);
for my $module (@modules) {
my $version;
eval "require $module";
if (not $@) {
$version = $module->VERSION;
$version = '(unknown)' if not defined $version;
}
else {
$version = '(not installed)';
}
printf "%21s%-24s\t%s\n", "", $module, $version;
}
__END__
3) Upgrade to the latest version of Spreadsheet::WriteExcel (or at least test on a system with an upgraded version). The issue you are reporting may already have been fixed.
4) Create a small but complete example program that demonstrates your problem. The program should be as small as possible. At the same time it should be a complete program that generates an Excel file. If the Spreadsheet::WriteExcel section is part of a much larger program then simplify it down to the essentials. Simulate any DB reads with an array.
5) Say if you tested with Excel, OpenOffice, Gnumeric or something else. Say which version of that application you used.
6) If you are submitting a patch you should check with the author whether the issue has already been patched or if a fix is in the works. Patches should be accompanied by test cases.
Asking a question
If you would like to ask a more general question there is the Spreadsheet::WriteExcel Google Group.
Owner: |
Nobody in particular
|
Requestors: |
rbo [...] cpan.org
|
Cc: |
|
AdminCc: |
|
|
Severity: |
Important |
Broken in: |
2.37 |
Fixed in: |
(no value)
|
|
Wed Dec 15 04:48:15 2010
rbo [...] cpan.org - Ticket created
Hi,
if i write an utf8 string into a cell then after each character is a \0.
Please look the example script "utf8_cell_values.pl"
Thanks
Robert
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
no utf8;
use Spreadsheet::WriteExcel;
print "\nSpreadsheet::WriteExcel::VERSION: " . $Spreadsheet::WriteExcel::VERSION . "\n\n";
my $normal_str = "abcde";
my $utf8_str = $normal_str;
utf8::upgrade($utf8_str);
printf("utf8 flag on utf8_str is %s\n",utf8::is_utf8($utf8_str) ? 'on': 'off');
printf("utf8 flag on normal_str is %s\n",utf8::is_utf8($normal_str) ? 'on': 'off');
printf("normal_str and utf8_str are equal %s\n\n",($normal_str eq $utf8_str) ? 'yes': 'no');
my $workbook = Spreadsheet::WriteExcel->new("test.xls");
my $sheet = $workbook->add_worksheet("Data");
$sheet->write(0,0,'normal_str:');
$sheet->write(0,1,$normal_str);
$sheet->write(1,0,'utf8_str:');
$sheet->write(1,1,$utf8_str);
__END__
Script Output:
Spreadsheet::WriteExcel::VERSION: 2.37
utf8 flag on utf8_str is on
utf8 flag on normal_str is off
normal_str and utf8_str are equal yes
hexdump -C test.xls
[...snipped...]
00000660 00 c2 04 00 00 00 00 04 00 44 61 74 61 8c 00 04 |.........Data...|
00000670 00 01 00 01 00 fc 00 37 00 04 00 00 00 04 00 00 |.......7........|
00000680 00 0b 00 00 6e 6f 72 6d 61 6c 5f 73 74 72 3a 05 |....normal_str:.|
00000690 00 00 61 62 63 64 65 09 00 00 75 74 66 38 5f 73 |..abcde...utf8_s|
000006a0 74 72 3a 05 00 01 61 00 62 00 63 00 64 00 65 00 |tr:...a.b.c.d.e.|
000006b0 ff 00 0a 00 08 00 81 04 00 00 0c 00 00 00 0a 00 |................|
000006c0 00 00 09 08 10 00 00 06 10 00 bb 0d cc 07 41 00 |..............A.|
000006d0 00 00 06 00 00 00 2a 00 02 00 00 00 2b 00 02 00 |......*.....+...|
000006e0 01 00 82 00 02 00 00 00 80 00 08 00 00 00 00 00 |................|
[...snipped...]
Wed Dec 15 05:29:36 2010
jmcnamara [...] cpan.org - Correspondence added
On Wed Dec 15 04:48:15 2010, rbo wrote:
Show quoted text> if i write an utf8 string into a cell then after each character is a \0.
Excel uses UTF-16 to store Unicode strings, hence the additional \0 bytes in your example.
Spreadsheet::WriteExcel assumes that if a string has the uft8 flag set by perl then the string
is a Unicode string and converts it to UTF-16 when writing it to an Excel file.
The module doesn't try to distinguish between strings that have the utf8 flag set but could be
represented by ASCII and strings that can't.
Either way Excel will display the string as you would expect it to be displayed so I don't see
this as being a real issue.
The S::WE docs hace some additional information about Unicode handling in Excel:
http://search.cpan.org/~jmcnamara/Spreadsheet-
WriteExcel/lib/Spreadsheet/WriteExcel.pm#UNICODE_IN_EXCEL
There are also a lot of Unicode examples that might be of useful to you:
http://search.cpan.org/~jmcnamara/Spreadsheet-
WriteExcel/lib/Spreadsheet/WriteExcel/Examples.pm
So, if you don't have any major objection I will close this issue. Let me know if you do.
John.
--
Wed Dec 15 05:29:37 2010
The RT System itself - Status changed from 'new' to 'open'
Wed Dec 15 09:04:47 2010
rbo [...] cpan.org - Correspondence added
Hi John,
thank you for your fast response.
OK then WriteExcel works fine but ParserExcel has an error.
An example is better than thousands of words on my bad English. Please look
"utf8_cell_values_parse.pl"
Robert
#!/usr/bin/env perl
use strict;
use warnings;
use Spreadsheet::ParseExcel;
use Devel::Peek;
use utf8;
no utf8;
print "\nSpreadsheet::ParseExcel::VERSION: " . $Spreadsheet::ParseExcel::VERSION . "\n\n";
my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->Parse('test.xls');
my $worksheet = $workbook->worksheet(0);
for my $row ( 0 .. 1 ) {
my $name = $worksheet->get_cell( $row, 0 )->unformatted() ;
my $value = $worksheet->get_cell( $row, 1 )->unformatted() ;
printf("utf8 flag on %-15s is %s\n",$name,utf8::is_utf8($value) ? 'yes' : 'no');
print Devel::Peek::Dump($value)
}
print "\n";
__END__
Script output
Spreadsheet::ParseExcel::VERSION: 0.58
utf8 flag on normal_str: is no
SV = PV(0x100812a18) at 0x10082af18
REFCNT = 1
FLAGS = (PADMY,POK,pPOK)
PV = 0x10047d110 "abcde"\0
CUR = 5
LEN = 16
utf8 flag on utf8_str: is no
SV = PV(0x100812a18) at 0x10082af18
REFCNT = 1
FLAGS = (PADMY,POK,pPOK)
PV = 0x10047d7a0 "\0a\0b\0c\0d\0e"\0
CUR = 10
LEN = 16
Wed Dec 15 12:06:13 2010
jmcnamara [...] cpan.org - Correspondence added
On Wed Dec 15 09:04:47 2010, rbo wrote:
Show quoted text>
> OK then WriteExcel works fine but ParserExcel has an error.
>
> An example is better than thousands of words on my bad English. Please look
> "utf8_cell_values_parse.pl"
HiRobert,
Again, that seems to be the correct behaviour. The unformatted() method returns the raw
unformatted data that is in a cell. If you require the UTF-8 value or a formatted number value
you need to use the value() method.
Change unformatted() to value() in your example and see if that gives you what you expected.
John.
--
Wed Dec 15 12:32:14 2010
rbo [...] cpan.org - Correspondence added
Hi John,
thank you for your time!
I should read the documentation better :-(
Robert
Wed Dec 15 12:32:15 2010
rbo [...] cpan.org - Status changed from 'open' to 'rejected'
Wed Dec 15 15:33:28 2010
jmcnamara [...] cpan.org - Correspondence added
Show quoted text> I should read the documentation better :-(
In that case I'll close the tracker.
Feel free to email me if you have any other issues.
John.
--
Wed Dec 15 15:33:31 2010
The RT System itself - Status changed from 'rejected' to 'open'
Wed Dec 15 15:33:32 2010
jmcnamara [...] cpan.org - Status changed from 'open' to 'resolved'