Thanks for your hint, unfortunatelly my interpretation of it wasn't succesful.
I apologize, I'm new to this editor so the code was "lost".
#!/usr/bin/perl
use strict;
use Pod::Usage;
use Getopt::Std;
use Win32::OLE;
use Spreadsheet::WriteExcel;
use encoding "cp1250";
use Encode;
my $Excel;
my $Book;
my $Sheet;
my @Test;
my $Test;
@Test=encode("cp1250",@Test);
#Excel file FileToRead.xls contains the following Slovenian characters:
# Line 1 Column 1: Čč (capital and small letter C with caron)
# Line 1 Column 2: Šš (capital and small letter S with caron)
# Line 1 Column 3: Žž (capital and small letter Z with caron)
$Excel=Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit');
$Book=$Excel->Workbooks->Open('c:\batch\Pisarna\Clouseau\FileToRead.xls');
$Sheet=$Book->Worksheets(1);
# characters read into @Test are correct
push(@Test,{
Col1=>$Sheet->Cells(1,1)->{'Value'},
Col2=>$Sheet->Cells(1,2)->{'Value'},
Col3=>$Sheet->Cells(1,3)->{'Value'},
});
$Book->Close;
$Excel->Close;
my $BookOut=Spreadsheet::WriteExcel->new('c:\batch\Pisarna\Clouseau\FileWritten.xls');
my $SheetOut=$BookOut->add_worksheet('test');
# writing Slovenian characters directly
$SheetOut->write(0,0,"Čč");
$SheetOut->write(0,1,"Šš");
$SheetOut->write(0,2,"Žž");
# read from xls file through @Test
$SheetOut->write(1,0,"$Test
1->{Col1}");
$SheetOut->write(1,1,$Test
1->{Col2});
$SheetOut->write(1,2,$Test
1->{Col3});
# strings defined in above lines 41, 42 and 43 are written into FileWritten.xls correct:
# Line 1 Column 1: Čč (capital and small letter C with caron)
# Line 1 Column 2: Šš (capital and small letter S with caron)
# Line 1 Column 3: Žž (capital and small letter Z with caron)
# strings read into @Test are written into FileWritten.xls incorrect
# Line 2 Column 1: capital and small letter C with grave (can't be written)
# Line 2 Column 2: small outlined square (can't be written)
# Line 2 Column 3: small outlined square (can't be written)
_END_
In short, Slovenian characters written directly are correct but those read from xls file and written through @Test aren't correct. Something weird happens to them on their way from array through Spreadsheet::WriteExcel.
(I work in Windows XP Professional version 2002, I use Perl 5.8).
Thanks for your hint.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.