用粘贴板将记录集中数据导Excel的问题(100分)

  • 主题发起人 主题发起人 Andyli
  • 开始时间 开始时间
A

Andyli

Unregistered / Unconfirmed
GUEST, unregistred user!
用粘贴板的方式将记录集中数据导Excel时,碰到如下问题:<br><br>&nbsp; 如果记录集中某条数据内容以 " (双引号)开头,则导出到excel时,在excel的这个单元格后面的单元格及以下的若干条记录都会窝在这一个格中显示。<br>&nbsp; <br>以下为程序片断,在实际过程中,因为物料描述trim(DataCds.fieldbyname('TPDT_SHT_NAM').AsString)中内容有可能以"开头,<br>则在导出到excel后,在Excel中,物料描述、采购数量、单位、货币、采购单价、金额、合同号都在物料描述这一个单元格中显示,且后面的若干条记录也会合并在一起在物料描述这个格中显示,不知大家有没有碰到过这种问题。<br><br>S := S +'采购单号'+#9+'采购日期'+#9+'供应商编号'+#9+'供应商名称'+#9+'物料代码'+#9+'物料描述'<br>&nbsp; &nbsp; &nbsp; &nbsp; +#9+'采购数量'+#9+'单位'+#9+'货币'+#9+'采购单价'+#9+'金额'+#9+'合同号'+#13#10;<br><br>&nbsp;DataCds.First;<br>&nbsp;for R := 0 to DataCds.RecordCount-1 do<br>&nbsp;begin<br>&nbsp; &nbsp; &nbsp;S := S+ trim(DataCds.fieldbyname('POHF_NUM').asstring)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('POHF_DTE').asstring)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('POHF_SUP_CDE').asstring)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('TVND_CNAM').asstring)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('POBF_ITM_CDE').asstring)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('TPDT_SHT_NAM').AsString)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ FloatToStr(DataCds.fieldbyname('POBF_QTY_BAS').ASFloat)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('POBF_STK_UNI').asstring)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('POBF_CCY_CDE').asstring)+ #9;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ FloatToStr(DataCds.fieldbyname('POBF_PRC').ASFloat)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ FloatToStr(DataCds.fieldbyname('POBF_AMT').ASFloat)+ #9<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+ trim(DataCds.fieldbyname('POBF_SO_NUM').asstring)+ #13#10;<br>&nbsp; &nbsp; &nbsp;DataCds.Next;<br>&nbsp;end;<br><br>&nbsp;ClipBoard.Clear;<br>&nbsp;ClipBoard.SetTextBuf(PChar(s)); <br>&nbsp;ExcelApp.ActiveSheet.Paste;<br>&nbsp;ExcelApp.ActiveSheet.columns['A:Z'].autofit;<br>&nbsp;Excelapp.ActiveWorkbook.SaveAs(sTempFileName);<br>&nbsp;ExcelApp.WorkBooks.Close;<br>&nbsp;ExcelApp.Quit;
 
自己顶一下,呵呵
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
696
import
I
I
回复
0
查看
676
import
I
后退
顶部