貌似还是得更新一个,2010下的问题.这种文件格式貌似不支持Unicode的双字节字符串.
更新一个函数声明:
procedure XlsWriteCellLabel(XlsStream: TStream; const ACol: Byte; const ARow: Word;
const AValue: AnsiString);
再继续更新那个函数:
procedure TCnXlsWriter.SetCells(const ACol: Byte; const ARow: Word; const Value: Variant);
var
aStr: AnsiString;
aUStr: WideString;
aInt: Integer;
aFloat: Double;
aCode: Integer;
begin
case VarType(Value) of
varSmallint, varInteger, varByte:
XlsWriteCellRk(FStream, ACol, ARow, Value);
varSingle, varDouble, varCurrency:
XlsWriteCellNumber(FStream, ACol, ARow, Value);
varString, varOleStr:
begin
aStr := VarToStr(Value);
Val(aStr, aInt, aCode);
if aCode = 0 then
begin
XlsWriteCellLabel(FStream, ACol, ARow, '''' + aStr);
Exit;
end;
Val(aStr, aFloat, aCode);
if aCode = 0 then
begin
XlsWriteCellLabel(FStream, ACol, ARow, '''' + aStr);
Exit;
end;
XlsWriteCellLabel(FStream, ACol, ARow, Value);
end;
{$IFDEF DELPHI2009_UP}
varUString:
begin
aUStr := VarToWideStr(Value);
aStr := WideCharToString(PWideChar(aUStr));
XlsWriteCellLabel(FStream, ACol, ARow, aStr);
end;
{$ENDIF}
varDate:
XlsWriteCellLabel(FStream, ACol, ARow, DateTimeToStr(Value));
else
XlsWriteCellBlank(FStream, ACol, ARow);
end;
end;
另外,这样写的话,d2010会报Warning,因为我手头没这个高科技的2010...谁来试下?
目前的代码双字节的问题是解决了..就是会报Warning,不爽啊.