Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 02:21 PM
see_mun_lee@dell.com
Guest
 
Posts: n/a
Default Read Chinese character from excel using asp

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...
  #2  
Old July 19th, 2005, 02:21 PM
Egbert Nierop \(MVP for IIS\)
Guest
 
Posts: n/a
Default Re: Read Chinese character from excel using asp

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" <see_mun_lee@dell.com> wrote in message
news:Or03%23VGcEHA.2520@TK2MSFTNGP12.phx.gbl...[color=blue]
>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">[/color]

Hi,

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

Response.CharSet = "utf-8"
[color=blue]
>
> ' 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...[/color]

  #3  
Old July 19th, 2005, 02:21 PM
Egbert Nierop \(MVP for IIS\)
Guest
 
Posts: n/a
Default Re: Read Chinese character from excel using asp

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>"
%>

  #4  
Old July 19th, 2005, 02:22 PM
see_mun_lee@dell.com
Guest
 
Posts: n/a
Default Re: Read Chinese character from excel using asp

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...
  #5  
Old July 19th, 2005, 02:23 PM
Egbert Nierop \(MVP for IIS\)
Guest
 
Posts: n/a
Default Re: Read Chinese character from excel using asp

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" <see_mun_lee@dell.com> wrote in message
news:uJ$4d4rcEHA.2468@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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...[/color]

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles