use Unicode::Map();
use Spreadsheet::WriteExcel;
use Win32::OLE::Const 'Microsoft Word'
my $workbook = Spreadsheet::WriteExcel->new("word.xls");
my $worksheet = $workbook->addworksheet();
my $word = Win32::OLE->new('Word.Application', 'Quit');
my $map = Unicode::Map->new("ISO-8859-6");
my $utf16 = $map->to_unicode($doc->Words->Item(1)->Text);
$worksheet->write(0, 0, $utf16, $format2);
You indicate that the data you are reading from Word is ISO-8859-6 but it may be UTF-16LE, which most Windows applications use internally.
Either way you should try to convert it to UTF-8 instead of UTF-16 if you are using write().
You can also write UTF-16BE and UTF-16LE data using the (poorly named) write_unicode() and write_unicode_le() methods.
--
John.
This is G o o g l e's cache of http://apache.hoxt.com/perl/win32-bin/ppmpackages/ as retrieved on Feb 26, 2006 09:28:24 GMT.
If you are using Perl 5.8 you can use the core Encode module to convert between encodings.
See also the perluniintro and perlunicode manpages for more information.
--
John.
use Win32::OLE qw(CP_UTF8); Win32::OLE->Option(CP=>CP_UTF8);Secondly, it is not good to use obsoleted Unicode::Map module, it was used when Unicode in Perl was weak, now you should go other, the robust way, of perl5.8.x
thirdly, boxes are probably missing characters in a given font.
BR,
Vadim.
use Win32::OLE qw(CP_UTF8);
Win32::OLE->Option(CP=>CP_UTF8);
use Win32::OLE::Const 'Microsoft Word';
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new("word.xls");
my $worksheet = $workbook->addworksheet();
my $word = Win32::OLE->new('Word.Application', 'Quit');
my $doc = $word->Documents->Open("C:\\file.doc");
my $string = $doc->Words->Item(1)->Text;
$worksheet->write(0, 0, $string);
use Win32::OLE qw(CP_UTF8);
Win32::OLE->Option(CP=>CP_UTF8);
use Win32::OLE::Const 'Microsoft Word';
use Spreadsheet::WriteExcel;
my $word = Win32::OLE->new('Word.Application', 'Quit');
my $doc = $word->Documents->Open($file);
my $workbook = Spreadsheet::WriteExcel->new($out_file);
my $worksheet = $workbook->addworksheet();
my $row = 0;
my $col = 0;
for(my $i = 1; $i <= $doc->Words->Count; $i++)
{
if($doc->Words->Item($i)->HighlightColorIndex > 0)
{
$worksheet->write($row++, $col,
$doc->Words->Item($i)->Text);
}
}
Thank you for any help in advance!
I don't know if it'd be significantly quicker, but you could try using Word's 'find object' to search for the highlighted text, then loop through whatever it returns you.
perlmonks.org content © perlmonks.org and ff, jmcnamara, john_oshea, pg09, vkon
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03