線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1837
推到 Plurk!
推到 Facebook!

如何讀取excel cells中的unicode字符?

尚未結案
kanelou
一般會員


發表:1
回覆:14
積分:3
註冊:2003-05-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-07 17:05:36 IP:202.175.xxx.xxx 未訂閱
請問怎樣才可以讀取cells中的unicode字符 例如á é ã ç .....(ASCII 128~256) 我試過讀這些字符時 得到變成 a e a c ....
kanelou
一般會員


發表:1
回覆:14
積分:3
註冊:2003-05-07

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-21 12:01:44 IP:202.175.xxx.xxx 未訂閱
終於用了個好笨的方法搞定了!
carter6
初階會員


發表:53
回覆:108
積分:42
註冊:2002-12-16

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-06-14 23:25:37 IP:139.175.xxx.xxx 未訂閱
請問什麼方式??
kanelou
一般會員


發表:1
回覆:14
積分:3
註冊:2003-05-07

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-06-16 17:31:25 IP:202.175.xxx.xxx 未訂閱
在EXCEL FILE 裝一個木馬程式將相關之unicode  encode 成 ASC 128~255之類, 讀入後再descode. 雖然好笨但可以讀中文同特殊碼。 >='Text ='9'Text='~'>'' then if ((StrToInt(S_Char) > 255) or (i=1)) then begin Convert_Text:=S_Char Convert_Text; S_state:=0; end; end; end; end; Result:=Convert_Text; end; function VBOpenExcelObj(xl_FileName:string;show:Boolean): Boolean; var Unknown: IUnknown; Res: HResult; begin try VBAppWasRunning := False; VBOpen:=False; Res := GetActiveObject(CLASS_ExcelApplication, nil, Unknown); if (Res = MK_E_UNAVAILABLE) then Excel := CoExcelApplication.Create else begin { make sure no other error occurred during GetActiveObject } OleCheck(Res); OleCheck(Unknown.QueryInterface(_Application, Excel)); VBAppWasRunning := True; end; Excel.Visible[lcid] := show; WBk := Excel.Workbooks.Open(xl_FileName, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, LCID); First_ws:=WBk.ActiveSheet as _Worksheet; VBOpen:=True; Result:=True; Super_Text_Import:=False; Excel_FileName:=xl_FileName; Except showmessage(xl_FileName #13 #10 'Unable to open MS Excel OLE object' #13 #10 '不能成功乎開啟MS Excel OLE object。'); Result:=False; end; end; FUNCTION VBReleaseExcelObj(Save:Boolean): Boolean; BEGIN Result:=True; IF VBOpen THEN TRY if Save and Super_Text_Import then begin WBk.VBProject.VBComponents.Remove(Super_Text_Import_C); Prg_ws.Cells.Item[1,1]:=''; Prg_Ws.Delete(LCID); end; Excel.ActiveWindow.Close(Save,Excel_FileName,True); {Close without save} Excel.Quit; VBOpen:=False; Super_Text_Import:=False; EXCEPT showmessage('Unable to release MS Excel OLE object' '不能成功乎釋放MS Excel OLE object,須等列印完成後方可關閉.'); Result:=False; END; END; procedure VBAddCodemodule; var LineNo: integer; CM: CodeModule; begin CM := WBk.VBProject.VBComponents.Item('ThisWorkbook').Codemodule; LineNo := CM.CreateEventProc('Open', 'Workbook'); CM.InsertLines(LineNo 1, ' Range("A1").Value = "Workbook activated!"'); //......... end; procedure VBImport_SUPER_TEXT_String; begin Super_Text_Import_C:=WBk.VBProject.VBComponents.Add(vbext_ct_StdModule); Super_Text_Import_C.CodeModule.InsertLines( 1,'Function Super_Text(The_String As String) as string'); Super_Text_Import_C.CodeModule.InsertLines( 2,'Dim i, j, k As Integer'); Super_Text_Import_C.CodeModule.InsertLines( 3,'Dim C As String'); Super_Text_Import_C.CodeModule.InsertLines( 4,'j = Len(The_String)'); Super_Text_Import_C.CodeModule.InsertLines( 5,'Super_Text = ""'); Super_Text_Import_C.CodeModule.InsertLines( 6,'For i = 1 To j'); Super_Text_Import_C.CodeModule.InsertLines( 7,' C = Mid(The_String, i, 1)'); Super_Text_Import_C.CodeModule.InsertLines( 8,' k = AscW(C)'); Super_Text_Import_C.CodeModule.InsertLines( 9,' If k < 0 or (k > 57 and k < 126 ) Or k > 255 Then'); Super_Text_Import_C.CodeModule.InsertLines(10,' Super_Text=Super_Text C'); Super_Text_Import_C.CodeModule.InsertLines(11,' Else'); Super_Text_Import_C.CodeModule.InsertLines(12,' Super_Text = Super_Text "~" Trim(Str(k))'); Super_Text_Import_C.CodeModule.InsertLines(13,' End If'); Super_Text_Import_C.CodeModule.InsertLines(14,'Next'); Super_Text_Import_C.CodeModule.InsertLines(15,'End Function'); Super_Text_Import:=True; Prg_ws:=WBk.Worksheets.Add(EmptyParam,First_ws,1,xlWorksheet,LCID) as _worksheet; Prg_ws.Name:='Prg_ws'; First_ws.Activate(LCID); end; function Cell_str_por(r,c:integer):string; var Active_Name,Cell,super_Text:string; begin Result:=''; if not Super_Text_Import then VBImport_SUPER_TEXT_String; //VBImport_SUPER_TEXT_File; Active_Name:=First_ws.Name '!'; Cell:=Active_Name Chr(64 c) inttostr(r); Prg_ws.Cells.Item[1,1]:='=Super_Text(' Cell ')'; super_Text:=Prg_ws.Cells.Item[1,1].Value; Result:=Convert_super_Text(super_Text); end; function Cell_str(r,c:integer):string; begin Result:=First_ws.Cells.item[r,c]; end; initialization {ReadAppIni;} VBAppWasRunning :=False; VBOpen :=False; Super_Text_Import :=False;
系統時間:2024-05-20 7:41:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!