[BUG REPORT] for WIN32OLE: The returning of Reading the Asian Langugae Text in Excel is always '? '

Hi All,

I think I just found a bug in Win32OLE,

When I read a cell which has Korean or Chinese Character Text from Excel2003
with Win32Ole, whatever the text is, the value of the cell is always '???'

My environment is WinXP Sp3, Office2003, Ruby is 1.8.6 (I also test the
1.9.0, it still returns ???)

I use the parseexcel, and it can read the cell content correctly.

I attched the test codes and test file.
In the excel file, there are 2 cells, first cell is Koean Text, 2nd cell is
Chinese Text.

test.rb is used Win32Ole.
test2.rb is used parseexcel, if you want use this, please:Gem Install
parseexcel
test.xls is the excel file

Thanks for alex's help.

BR
Nan

test.rb (703 Bytes)

test2.rb (1.01 KB)

test.xls (13.5 KB)

Hi,

Hi All,

I think I just found a bug in Win32OLE,

When I read a cell which has Korean or Chinese Character Text from Excel2003
with Win32Ole, whatever the text is, the value of the cell is always '???'

My environment is WinXP Sp3, Office2003, Ruby is 1.8.6 (I also test the
1.9.0, it still returns ???)

I use the parseexcel, and it can read the cell content correctly.

I attched the test codes and test file.
In the excel file, there are 2 cells, first cell is Koean Text, 2nd cell is
Chinese Text.

test.rb is used Win32Ole.
test2.rb is used parseexcel, if you want use this, please:Gem Install
parseexcel
test.xls is the excel file

Thanks for alex's help.

BR
Nan

That is not a bug.

You must use WIN32OLE.codepage in case of the mixed character set handling:
Here is a working code for my Korean WinXP SP3 based on your test.rb:

require 'win32ole'
require 'iconv'

def read_excel(e_name, s_name)
    $excel.WorkBooks.Open("#{$MY_LOCATION}/" + e_name,TRUE)

    $excel.WorkSheets(s_name).Activate
    begin
    puts $excel.Cells(1,1).value
    puts $excel.Cells(1,2).value

    $excel.Cells(1,1).text.to_s.each_byte{|c| print c, ' '}
    puts Iconv.conv("EUC-KR//IGNORE","UTF-8//IGNORE",$excel.Cells(1,1).value)

    ensure
        $excel.WorkBooks.Close()
    end
end

$MY_LOCATION = Dir.getwd
WIN32OLE.codepage = WIN32OLE::CP_UTF8
$excel = WIN32OLE.new("excel.application")
$excel.Visible = false
begin
read_excel('test.xls',"Sheet1")
ensure
$excel.Quit()
end

Regards,

Park Heesob

···

2008/9/16 Wu Nan <i.wunan+rubymail@gmail.com>:

Hello Heesob,

Thank you very much! You are right, I have just test it.

Sorry for my mistake.

BR
Nan

···

2008/9/16 Heesob Park <phasis@gmail.com>

Hi,

2008/9/16 Wu Nan <i.wunan+rubymail@gmail.com<i.wunan%2Brubymail@gmail.com>
>:
> Hi All,
>
> I think I just found a bug in Win32OLE,
>
> When I read a cell which has Korean or Chinese Character Text from
Excel2003
> with Win32Ole, whatever the text is, the value of the cell is always
'???'
>
> My environment is WinXP Sp3, Office2003, Ruby is 1.8.6 (I also test the
> 1.9.0, it still returns ???)
>
> I use the parseexcel, and it can read the cell content correctly.
>
> I attched the test codes and test file.
> In the excel file, there are 2 cells, first cell is Koean Text, 2nd cell
is
> Chinese Text.
>
> test.rb is used Win32Ole.
> test2.rb is used parseexcel, if you want use this, please:Gem Install
> parseexcel
> test.xls is the excel file
>
> Thanks for alex's help.
>
> BR
> Nan
>
That is not a bug.

You must use WIN32OLE.codepage in case of the mixed character set handling:
Here is a working code for my Korean WinXP SP3 based on your test.rb:

require 'win32ole'
require 'iconv'

def read_excel(e_name, s_name)
   $excel.WorkBooks.Open("#{$MY_LOCATION}/" + e_name,TRUE)

   $excel.WorkSheets(s_name).Activate
   begin
   puts $excel.Cells(1,1).value
   puts $excel.Cells(1,2).value

   $excel.Cells(1,1).text.to_s.each_byte{|c| print c, ' '}
   puts
Iconv.conv("EUC-KR//IGNORE","UTF-8//IGNORE",$excel.Cells(1,1).value)

   ensure
       $excel.WorkBooks.Close()
   end
end

$MY_LOCATION = Dir.getwd
WIN32OLE.codepage = WIN32OLE::CP_UTF8
$excel = WIN32OLE.new("excel.application")
$excel.Visible = false
begin
read_excel('test.xls',"Sheet1")
ensure
$excel.Quit()
end

Regards,

Park Heesob

i want to know how to exit this maillist> Date: Tue, 16 Sep 2008 18:30:56 +0900> From: i.wunan+rubymail@gmail.com> Subject: Re: [BUG REPORT] for WIN32OLE: The returning of Reading the Asian Langugae Text in Excel is always '??? '> To: ruby-talk@ruby-lang.org> > Hello Heesob,> > Thank you very much! You are right, I have just test it.> > Sorry for my mistake.> > BR> Nan> > 2008/9/16 Heesob Park <phasis@gmail.com>> > > Hi,> >> > 2008/9/16 Wu Nan <i.wunan+rubymail@gmail.com<i.wunan%2Brubymail@gmail.com>> > >:> > > Hi All,> > >> > > I think I just found a bug in Win32OLE,> > >> > > When I read a cell which has Korean or Chinese Character Text from> > Excel2003> > > with Win32Ole, whatever the text is, the value of the cell is always> > '???'> > >> > > My environment is WinXP Sp3, Office2003, Ruby is 1.8.6 (I also test the> > > 1.9.0, it still returns ???)> > >> > > I use the parseexcel, and it can read the cell content correctly.> > >> > > I attched the test codes and test file.> > > In the excel file, there are 2 cells, first cell is Koean Text, 2nd cell> > is> > > Chinese Text.> > >> > > test.rb is used Win32Ole.> > > test2.rb is used parseexcel, if you want use this, please:Gem Install> > > parseexcel> > > test.xls is the excel file> > >> > > Thanks for alex's help.> > >> > > BR> > > Nan> > >> > That is not a bug.> >> > You must use WIN32OLE.codepage in case of the mixed character set handling:> > Here is a working code for my Korean WinXP SP3 based on your test.rb:> >> > require 'win32ole'> > require 'iconv'> >> > def read_excel(e_name, s_name)> > $excel.WorkBooks.Open("#{$MY_LOCATION}/" + e_name,TRUE)> >> > $excel.WorkSheets(s_name).Activate> > begin> > puts $excel.Cells(1,1).value> > puts $excel.Cells(1,2).value> >> > $excel.Cells(1,1).text.to_s.each_byte{|c| print c, ' '}> > puts> > Iconv.conv("EUC-KR//IGNORE","UTF-8//IGNORE",$excel.Cells(1,1).value)> >> > ensure> > $excel.WorkBooks.Close()> > end> > end> >> > $MY_LOCATION = Dir.getwd> > WIN32OLE.codepage = WIN32OLE::CP_UTF8> > $excel = WIN32OLE.new("excel.application")> > $excel.Visible = false> > begin> > read_excel('test.xls',"Sheet1")> > ensure> > $excel.Quit()> > end> >> >> > Regards,> >> > Park Heesob> >> >

···

_________________________________________________________________
谈话枯燥无味?让MSN魔法书来点缀您的MSN!
http://im.live.cn/emoticons/?ID=6

Hi,

You can unsubscirbe this maillist by visiting here:
http://www.ruby-lang.org/en/community/mailing-lists/

Change the Action into unsubscirbe.
Fill your email
Press[submit]

···

2008/9/16 xuhaimin <haimin@live.cn>

i want to know how to exit this maillist> Date: Tue, 16 Sep 2008 18:30:56
+0900> From: i.wunan+rubymail@gmail.com <i.wunan%2Brubymail@gmail.com>>
Subject: Re: [BUG REPORT] for WIN32OLE: The returning of Reading the Asian
Langugae Text in Excel is always '??? '> To: ruby-talk@ruby-lang.org> >
Hello Heesob,> > Thank you very much! You are right, I have just test it.> >
Sorry for my mistake.> > BR> Nan> > 2008/9/16 Heesob Park <
phasis@gmail.com>> > > Hi,> >> > 2008/9/16 Wu Nan <
i.wunan+rubymail@gmail.com <i.wunan%2Brubymail@gmail.com><
i.wunan%2Brubymail@gmail.com <i.wunan%252Brubymail@gmail.com>>> > >:> > >
Hi All,> > >> > > I think I just found a bug in Win32OLE,> > >> > > When I
read a cell which has Korean or Chinese Character Text from> > Excel2003> >
> with Win32Ole, whatever the text is, the value of the cell is always> >
'???'> > >> > > My environment is WinXP Sp3, Office2003, Ruby is 1.8.6 (I
also test the> > > 1.9.0, it still returns ???)> > >> > > I use the
parseexcel, and it can read the cell content correctly.> > >> > > I attched
the test codes and test file.> > > In the excel file, there are 2 cells,
first cell is Koean Text, 2nd cell> > is> > > Chinese Text.> > >> > >
test.rb is used Win32Ole.> > > test2.rb is used parseexcel, if you want use
this, please:Gem Install> > > parseexcel> > > test.xls is the excel file> >
>> > > Thanks for alex's help.> > >> > > BR> > > Nan> > >> > That is not a
bug.> >> > You must use WIN32OLE.codepage in case of the mixed character set
handling:> > Here is a working code for my Korean WinXP SP3 based on your
test.rb:> >> > require 'win32ole'> > require 'iconv'> >> > def
read_excel(e_name, s_name)> > $excel.WorkBooks.Open("#{$MY_LOCATION}/" +
e_name,TRUE)> >> > $excel.WorkSheets(s_name).Activate> > begin> > puts
$excel.Cells(1,1).value> > puts $excel.Cells(1,2).value> >> >
$excel.Cells(1,1).text.to_s.each_byte{|c| print c, ' '}> > puts> >
Iconv.conv("EUC-KR//IGNORE","UTF-8//IGNORE",$excel.Cells(1,1).value)> >> >
> > $excel.WorkBooks.Close()> > end> > end> >> > $MY_LOCATION =
Dir.getwd> > WIN32OLE.codepage = WIN32OLE::CP_UTF8> > $excel =
WIN32OLE.new("excel.application")> > $excel.Visible = false> > begin> >
read_excel('test.xls',"Sheet1")> > ensure> > $excel.Quit()> > end> >> >> >
Regards,> >> > Park Heesob> >> >
_________________________________________________________________
谈话枯燥无味?让MSN魔法书来点缀您的MSN!
http://im.live.cn/emoticons/?ID=6