Read Chinese character from excel using asp

S

see_mun_lee

I use asp to develop a web page to read an excel file containing Chinese Character then display it in the web page. Unfortunately, I cant display it!!! it will display (?????????).

<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">


' create and open the connection to the Excel file
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER=Microsoft Excel Driver (*.xls);" & "DBQ=" & Server.MapPath("uploadfolder/" & NewFileName)

Set RS = conn.Execute("Select * From [Customer_Group]")

'response.write connection
con.open connection
' Create recordset and retrieve values using the open connection
Set objRS = server.CreateObject("ADODB.Recordset")


<TABLE Border=1 CellPadding=3>
<TR class=TRAlternate1>
<% For f = 0 To RS.Fields.Count-1%>
<TH>
<%= RS.Fields(f).value%></TH>

when i tried to display it using "RS.Fields(f).value", i only can c ???? so, I think the problem is i cant even get/read the chinese character from the excel file. Pls help me.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
E

Egbert Nierop \(MVP for IIS\)

This _will_ work!

Success

<% @ codepage=65001 %>

<%
Dim a, r
Response.Write "<HTML><BODY>"
Response.CharSet = "utf-8"
Set a = CreateObject("ADODB.Connection")
a.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Temp\Book1.xls;Extended Properties=Excel 8.0;Persist Security
Info=False"
Set r = a.Execute("SELECT * FROM [Sheet1$]")
Do Until r.EOF
Response.Write r.Collect(0)
Response.Write "<BR>"
r.MoveNext
Loop
a.Close
Response.Write "</BODY></HTML>"
%>


--
compatible web farm Session replacement for Asp and Asp.Net
http://www.nieropwebconsult.nl/asp_session_manager.htm


Lee See Mun said:
I use asp to develop a web page to read an excel file containing Chinese
Character then display it in the web page. Unfortunately, I cant display
it!!! it will display (?????????).

<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">

Hi,

meta tags are for backward-compat and for non-dynamic pages.

Response.CharSet = "utf-8"
' create and open the connection to the Excel file
Set conn = CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.Oledb.4.0;extensions=Microsoft Excel
Driver (*.xls);" & "DBQ=" & Server.MapPath("uploadfolder/" & NewFileName)

Set RS = conn.Execute("Select * From [Customer_Group]")

'response.write connection
con.open connection
' Create recordset and retrieve values using the open connection
Set objRS = server.CreateObject("ADODB.Recordset")


<TABLE Border=1 CellPadding=3>
<TR class=TRAlternate1>
<% For f = 0 To RS.Fields.Count-1%>
<TH>
<%= RS.Fields(f).value%></TH>

when i tried to display it using "RS.Fields(f).value", i only can c ????
so, I think the problem is i cant even get/read the chinese character from
the excel file. Pls help me.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 
E

Egbert Nierop \(MVP for IIS\)

tiny improvement

<% @ codepage=65001 %>

<%
Dim a, r, f
Response.Write "<HTML><BODY>"
Response.CharSet = "utf-8"
Set a = CreateObject("ADODB.Connection")
a.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Temp\Book1.xls;Extended Properties=Excel 8.0"
Set r = a.Execute("SELECT * FROM [Sheet1$]")
Set f = r(0)
Do Until r.EOF
Response.Write f
Response.Write "<BR>"
r.MoveNext
Loop
r.Close
a.Close
Response.Write "</BODY></HTML>"
%>
 
S

see_mun_lee

Hi Egbert Nierop,

I still face some problem with the code. I copied all the code provided by u n i change the excel file path to point to my excel file. The rest of the codes r still the same. I got this error:

Error Type:
Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
/test2.asp, line 8, column 45
a.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data

It seems that i cant use this provider! i try to use another provider

a.Open "DRIVER=Microsoft Excel Driver (*.xls);DBQ=C:\EWS List CCC3.xls"

but i get this error:
Error Type:
(0x8007007F)
/test2.asp, line 15

Please help me. It has been days and i still could find the solution. Thank you.


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
E

Egbert Nierop \(MVP for IIS\)

Hi,

It means that your server does not have the necessary versions.
You -need- oledb 3.51 at least, to have unicode support. About UTF-8 which
is a modern unicode encoding, I really advice to you to use Oledb 4.0
The solution should be simple. Install the JET provider/drivers for your
Specific OS.
http://www.microsoft.com/downloads/results.aspx?productID=&freetext=JET&DisplayLang=en

And also, better use my code which utilizes oledb and not odbc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top