CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Win32 Programming Help:
About Excel problem


kevin meng
New User

Jan 7, 2008, 7:35 PM

Post #1 of 1 (8031 views)
About Excel problem Can't Post

Hi everyone:

I write a program read the data from excel,everything is ok,but when i read the chinese,there a problem,it show the garble.Can everyone help me! Thank you!

This is my code:

# !usr/bin/perl -w
use strict;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
use Log;
use Data::Dumper;
use Cwd;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
use Spreadsheet::ParseExcel::FmtUnicode;
use Unicode::Map();
use Encode;

$Win32::OLE::Warn = 3;

my $cat={};
my $path=getcwd."/test.xls";

my $oCode = 'CP936';
my $oFmtJ = Spreadsheet::ParseExcel::FmtUnicode->new(Unicode_Map => $oCode);
my $excel = Spreadsheet::ParseExcel::Workbook->Parse($path,$oFmtJ);

foreach my $sheet (@{$excel->{Worksheet}}) {
my @subcat=();
printf("Sheet: %s\n", $sheet->{Name});
$sheet->{MaxRow} ||= $sheet->{MinRow};
foreach my $row ($sheet->{MinRow}+1 .. $sheet->{MaxRow}) {
my %kv;
$sheet->{MaxCol} ||= $sheet->{MinCol};
foreach my $col1 ($sheet->{MinCol} .. $sheet->{MaxCol}) {
my $fld1=($sheet->{Cells}[0][$col1]);
my $cell = $sheet->{Cells}[$row][$col1];
my $str=$cell->{Val};
push @subcat,\%kv;
Attachments: test.xls (51.0 KB)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives