may be small mistakes? in XLS RW 3 (My fixes below)
Posted: Tue May 29, 2007 2:02 pm
1) Creating XLS with current regional settings, but not 1200 codepage
procedure TRecordStorageGlobals.SetDefaultData;
begin
.....
{$IFDEF VVC}
PCODEPAGE := AddDefRecWord(BIFFRECID_CODEPAGE, GetACP());
{$ELSE}
PCODEPAGE := AddDefRecWord(BIFFRECID_CODEPAGE,$04B0);
{$ENDIF}
......
2) Bad data when writing unicode non english strings.
procedure TXLSReadII.RREC_LABEL;
var
i: integer;
P: PWordArray;
WS: WideString;
begin
InsertRecord := False;
with PRecLABEL(PBuf)^ do begin
if FXLS.Version > xvExcel97 then
FXLS.Sheets[FCurrSheet].IntWriteSSTString(Col,Row,FormatIndex,ByteStrToWideString(@Data[0],Len))
else begin
SetLength(WS,Len);
if Data[0] = 0 then begin
{$IFDEF VVC}
MultiByteToWideChar(FXLS.CodePage,MB_PRECOMPOSED,Pointer(Integer(@Data)+1),Len-1,PWideChar(WS),Len*2);
{$ELSE}
for i := 1 to Len do
WS := WideChar(Data);
{$ENDIF}
end
else if Data[0] = 1 then begin
P := @Data[1];
for i := 0 to Len - 1 do
WS[i + 1] := WideChar(P);
end
else begin
{$IFDEF VVC}
MultiByteToWideChar(FXLS.CodePage,MB_PRECOMPOSED,@Data,Len,PWideChar(WS),Len*2);
{$ELSE}
for i := 0 to Len - 1 do
WS[i + 1] := WideChar(Data);
{$ENDIF}
end;
FXLS.Sheets[FCurrSheet].IntWriteSSTString(Col,Row,FormatIndex,WS);
end;
end;
end;
procedure TRecordStorageGlobals.SetDefaultData;
begin
.....
{$IFDEF VVC}
PCODEPAGE := AddDefRecWord(BIFFRECID_CODEPAGE, GetACP());
{$ELSE}
PCODEPAGE := AddDefRecWord(BIFFRECID_CODEPAGE,$04B0);
{$ENDIF}
......
2) Bad data when writing unicode non english strings.
procedure TXLSReadII.RREC_LABEL;
var
i: integer;
P: PWordArray;
WS: WideString;
begin
InsertRecord := False;
with PRecLABEL(PBuf)^ do begin
if FXLS.Version > xvExcel97 then
FXLS.Sheets[FCurrSheet].IntWriteSSTString(Col,Row,FormatIndex,ByteStrToWideString(@Data[0],Len))
else begin
SetLength(WS,Len);
if Data[0] = 0 then begin
{$IFDEF VVC}
MultiByteToWideChar(FXLS.CodePage,MB_PRECOMPOSED,Pointer(Integer(@Data)+1),Len-1,PWideChar(WS),Len*2);
{$ELSE}
for i := 1 to Len do
WS := WideChar(Data);
{$ENDIF}
end
else if Data[0] = 1 then begin
P := @Data[1];
for i := 0 to Len - 1 do
WS[i + 1] := WideChar(P);
end
else begin
{$IFDEF VVC}
MultiByteToWideChar(FXLS.CodePage,MB_PRECOMPOSED,@Data,Len,PWideChar(WS),Len*2);
{$ELSE}
for i := 0 to Len - 1 do
WS[i + 1] := WideChar(Data);
{$ENDIF}
end;
FXLS.Sheets[FCurrSheet].IntWriteSSTString(Col,Row,FormatIndex,WS);
end;
end;
end;