# For WIN32OLE: The returning of Reading the Asian Langugae Text in Excel is always '? '

**URL:** <https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678>\
**Category:** Ruby\
**Created:** [September 16, 2008, 5:56am UTC](https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678 "2008-09-16T05:56:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wu\_Nan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/898d66/32.png) [@Wu\_Nan](https://www.ruby-forum.com/u/Wu_Nan)\
**Post date:** [September 16, 2008, 5:56am UTC](https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678/1 "2008-09-16T05:56:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Wu\_Nan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/898d66/32.png) [@Wu\_Nan](https://www.ruby-forum.com/u/Wu_Nan)\
**Post date:** [September 16, 2008, 9:42am UTC](https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678/2 "2008-09-16T09:42:22Z")

</div>

Hi,

2008/9/16 Wu Nan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I use the parseexcel, and it can read the cell content correctly.  
> 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 H.

---

<div class="post-metadata">

**Author:** ![Wu\_Nan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/898d66/32.png) [@Wu\_Nan](https://www.ruby-forum.com/u/Wu_Nan)\
**Post date:** [September 16, 2008, 11:40am UTC](https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678/3 "2008-09-16T11:40:27Z")

</div>

Hello Heesob,

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

Sorry for my mistake.

BR  
Nan

2008/9/16 Heesob P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Wu\_Nan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/898d66/32.png) [@Wu\_Nan](https://www.ruby-forum.com/u/Wu_Nan)\
**Post date:** [September 16, 2008, 12:06pm UTC](https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678/4 "2008-09-16T12:06:56Z")

</div>

i want to know how to exit this maillist\> Date: Tue, 16 Sep 2008  
18:30:56 +0900\> From: removed\_email\_address@domain.invalid\> Subject: Re: [BUG  
REPORT] for WIN32OLE: The returning of Reading the Asian Langugae Text  
in Excel is always '??? '\> To: removed\_email\_address@domain.invalid\> \> Hello  
Heesob,\> \> Thank you very much! You are right, I have just test it.\> \>  
Sorry for my mistake.\> \> BR\> Nan\> \> 2008/9/16 Heesob P.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> \> \> Hi,\> \>\> \> 2008/9/16 Wu Nan  
\<removed\_email\_address@domain.invalid[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)\> \> \>:\> \> \> 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 H.\> \>\> \>

---

<div class="post-metadata">

**Author:** ![Wu\_Nan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/898d66/32.png) [@Wu\_Nan](https://www.ruby-forum.com/u/Wu_Nan)\
**Post date:** [September 16, 2008, 12:20pm UTC](https://www.ruby-forum.com/t/for-win32ole-the-returning-of-reading-the-asian-langugae-text-in-excel-is-always/148678/5 "2008-09-16T12:20:27Z")

</div>

Hi,

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

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

2008/9/16 xuhaimin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
