+ Reply to Thread
Results 1 to 2 of 2

Read unicode (Asian Languages) from Excel spreadsheet

  1. #1
    Frank
    Guest

    Read unicode (Asian Languages) from Excel spreadsheet

    Hi,

    I guess it is a common problem when read some DBCS value from Excel
    spreadsheet but got question marks.
    Following are my code:
    -----------------------------------------------------------------------------------
    <%
    Session.CodePage=65001
    response.charset="UTF-8"
    %>
    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    </HEAD>
    <BODY>
    <%
    'Create a connection
    Set oConn = Server.CreateObject("ADODB.Connection")
    strConn = "Driver={Microsoft Excel Driver (*.xls)}; " &_
    "DBQ=<someXLS file>;" 'How to can set codepage or characterset here?
    oConn.Open strConn

    strCmd = "SELECT * from `<some Name defined in Excel>'"

    'Create a recordset
    Set oRS = Server.CreateObject("ADODB.Recordset")

    oRS.Open strCmd, oConn

    'Output conects of Excel
    while not oRS.EOF
    for each item in oRs.Fields
    response.write item.Name & "==>" & item.value & "<br>"
    Next
    ORs.moveNext
    Wend
    set ORs= nothing
    set oConn = nothing
    %>
    </BODY>
    </HTML>
    -------------------------------------------------------------------------------------

    For the cloumn that include some Asian languages like Chinese, Japanese and
    Korean, will display question marks ??? at this page.

    Is it any way we can set codepage or characterset in the connectionstring?

    Regadrs,

    Frank







  2. #2
    keepITcool
    Guest

    Re: Read unicode (Asian Languages) from Excel spreadsheet

    Frank,

    have you tried with Jet provider iso ODBC?..
    the Jet Driver has unicode support.

    Your DSN/ODBC approach is not the best way to use Ado.
    you should use ADO with Jet's OLEDB provider.

    hmm.. even Jet is listed as deprecated these days

    Data Access Technologies Roadmap
    (http://msdn.microsoft.com/library/de...y/en-us/dnmdac
    /html/data_mdacroadmap.asp) #see Obsolete


    Note the font you're using should support the dbms characters..
    Have you checked that you can write a hardcoded asian string?


    Sub ReadXL()
    Const cConXL = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Extended Properties='Excel 8.0';Data Source=%File%;"

    Dim oCon As ADODB.Connection
    Dim oRst As ADODB.Recordset

    Dim sFile$
    Dim sSQL$

    sFile = "c:\test.xls"
    sSQL = "Select * from [Sheet1$]"

    'Connect to the workbook
    Set oCon = New ADODB.Connection
    oCon.CursorLocation = adUseClient
    oCon.Open Replace(cConXL, "%File%", sFile)

    Set oRst = New ADODB.Recordset
    oRst.Open sSQL, oCon, adOpenForwardOnly, adLockReadOnly, adCmdText
    Stop ' or do your stuff

    If oRst.State > 0 Then oRst.Close
    If oCon.State > 0 Then oCon.Close
    Set oRst = Nothing
    Set oCon = Nothing

    End Sub




    --
    keepITcool
    | www.XLsupport.com | keepITcool chello nl | amsterdam


    Frank wrote :

    > Hi,
    >
    > I guess it is a common problem when read some DBCS value from Excel
    > spreadsheet but got question marks.
    > Following are my code:
    > ----------------------------------------------------------------------
    > ------------- <%
    > Session.CodePage=65001
    > response.charset="UTF-8"
    > %>
    > <HTML>
    > <HEAD>
    > <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    > </HEAD>
    > <BODY>
    > <%
    > 'Create a connection
    > Set oConn = Server.CreateObject("ADODB.Connection")
    > strConn = "Driver={Microsoft Excel Driver (*.xls)}; " &_
    > "DBQ=<someXLS file>;" 'How to can set codepage or characterset here?
    > oConn.Open strConn
    >
    > strCmd = "SELECT * from `<some Name defined in Excel>'"
    >
    > 'Create a recordset
    > Set oRS = Server.CreateObject("ADODB.Recordset")
    >
    > oRS.Open strCmd, oConn
    >
    > 'Output conects of Excel
    > while not oRS.EOF
    > for each item in oRs.Fields
    > response.write item.Name & "==>" & item.value & "<br>"
    > Next
    > ORs.moveNext
    > Wend
    > set ORs= nothing
    > set oConn = nothing
    > %>
    > </BODY>
    > </HTML>
    > ----------------------------------------------------------------------
    > ---------------
    >
    > For the cloumn that include some Asian languages like Chinese,
    > Japanese and Korean, will display question marks ??? at this page.
    >
    > Is it any way we can set codepage or characterset in the
    > connectionstring?
    >
    > Regadrs,
    >
    > Frank


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1