Page 1 of 1

Read Excel cell and write to text with unicode ?

Posted: Fri Mar 30, 2007 1:49 pm
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 !!

Posted: Tue Apr 03, 2007 12:16 pm
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

Posted: Tue Apr 03, 2007 2:34 pm
by Guest
Thank for reply

But can you help me a example how to done that problem.

Posted: Thu Apr 05, 2007 7:29 am
by larsa
Hello

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


Lars Arvidsson