var
  L: integer;
begin  L := Length(AValue);
  CXlsLabel[1] := 8 + L;
  CXlsLabel[2] := FRow;
  CXlsLabel[3] := FCol;
  CXlsLabel[5] := L;
  Stream.WriteBuffer(CXlsLabel, SizeOf(CXlsLabel));  Stream.WriteBuffer( Pointer(AValue)^ , L );  if IncStatus then
    IncColRow;
end;上面这段代码,在delphi7中运行都好好的,但是到delhpi2010中输出全是乱码,谁知道怎么处理。

解决方案 »

  1.   

    delphi7是ansi字符集字符占1字节,2010是unicode字符集,一个字符占2个字节
    还有你的AValue是字符串么?Length在delphi7表字节,2010表字符
      

  2.   

    定义字符串 CXlsLabel为 ansistring 
    Stream.WriteBuffer(CXlsLabel[1], length(CXlsLabel)); 
      

  3.   

    procedure TDBGridEhToExcel.WriteStringCell(const AValue: string; const IncStatus: Boolean=True);AValue是字符串,我这个地方L*2 也不好用啊
      

  4.   

    这问题不是简单乘2解决的吧
    2010里用ansistring