Read Excel cell and write to text with unicode ?

Questions and answers on how to use XLSReadWriteII 3/4/5.
Post Reply
Guest
Posts: 83
Joined: Tue Aug 16, 2005 6:08 pm

Read Excel cell and write to text with unicode ?

Post by Guest »

hi

i need read excel cell then write to a text file with unicode.
my procedure here :

Code: Select all

procedure ConvertToXML(sheetindex:Integer;xlsfile:String;outfile:String);
var
XLS:TXLSReadWriteII2;
col,row:integer;
ws:TStringList;
begin
    XLS:=TXLSReadWriteII2.Create(nil);
    XLS.Filename:=xlsfile;
    XLS.Read;
    ws:=TStringList.Create;
    for row:=0 to XLS.Sheets[sheetindex].LastRow do
    begin
        for col:=0 to XLS.Sheets[sheetindex].LastCol do
        begin
            ws.Add(XLS.Sheets[sheetindex].AsWideString[col,row]);
        end;
    end;
    ws.SaveToFile(outfile);
    ws.Free();
end;
But output file not correct, can you help me !!
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Post by larsa »

Hello

TStringList can't handle unicode. When you add a unicode string to a TStringList, it will be converted to a normal string.


Lars Arvidsson
Guest
Posts: 83
Joined: Tue Aug 16, 2005 6:08 pm

Post by Guest »

Thank for reply

But can you help me a example how to done that problem.
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Post by larsa »

Hello

You need a string list component that can handle unicode. I beleive that the TNT components have one.


Lars Arvidsson
Post Reply