View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default 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