Delphi CxGrid increase in total control transfer Excel

The first step, first set the footer to true cxgridview

 

 

The second step, set the required aggregate columns and property settings

 

 

The third method step, wherein the cell references used cxGridExportLink

procedure TFrmYpcgJh.BtnExcelClick(Sender: TObject);
var
pathName: string;
begin
// ExportExcelcxGrid(cxgYpcg, '药品采购计划单' + FormatDateTime('YYYYMMDD', DtpCgrq.Date));
SaveDialog1.Title := '选择路径'; //设置浏览对话框标题名
SaveDialog1.Filter := '文本文件(*.xls)|*.xlsx'; //设置保存文件的扩展名
SaveDialog1.DefaultExt := '.xlsx'; //为保存文件名自动添加扩展名
SaveDialog1.FileName := '药品采购计划单' + FormatDateTime('YYYYMMDD', DtpCgrq.Date);
if SaveDialog1.Execute then
begin
pathName := Trim(SaveDialog1.FileName); //获取保存路径
ExportGridToExcel(pathName, cxgYpcg, True, True);
end;
end;

Guess you like

Origin www.cnblogs.com/wooroc/p/12098782.html