By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,187 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,187 IT Pros & Developers. It's quick & easy.

Read Chinese character from excel using asp

P: n/a
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...
Jul 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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" <se*********@dell.com> wrote in message
news:Or****************@TK2MSFTNGP12.phx.gbl...
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=Micro soft 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...


Jul 19 '05 #2

P: n/a
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>"
%>

Jul 19 '05 #3

P: n/a
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...
Jul 19 '05 #4

P: n/a
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/r...DisplayLang=en

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

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

"Lee See Mun" <se*********@dell.com> wrote in message
news:uJ**************@TK2MSFTNGP09.phx.gbl...
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...


Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.