首页 > 其他分享 >delphi TMS FlexCel 导出PDF2

delphi TMS FlexCel 导出PDF2

时间:2022-09-02 16:35:28浏览次数:54  
标签:TFlexCelPdfExport FlexCel Excel delphi 导出 书签 PDF2 Pdf property

TMS FlexCel 导出PDF2

属性和方法

TFlexCelPdfExport.Workbook

property Workbook: TExcelFile

要打印的 Excel 文件。

TFlexCelPdfExport.CurrentPage

property CurrentPage: Integer

返回要打印的下一页。

TFlexCelPdfExport.CurrentPageInSheet

property CurrentPageInSheet: Integer

返回当前工作表上要打印的下一页。当不打印多页时,相当于CurrentPage

TFlexCelPdfExport.GetBookmarkInformation

property GetBookmarkInformation: TGetBookmarkInformationEventHandler

使用此事件可在导出Excel 文件的多个工作表时自定义书签中的内容。

导出多个工作表时触发事件,调用 TFlexCelPdfExport.Export 时不触发。

导出Excel 文件或导出每个工作表时触发一次。

TGetBookmarkInformationArgs

TFlexCelPdfExport.GetBookmarkInformation 上传递的参数

unit

FlexCel.Render

TGetBookmarkInformationArgs.DataFile

property DataFile: TPdfWriter

包含PDF数据的文件。

TGetBookmarkInformationArgs.CurrentPage

property CurrentPage: Integer

当前正在打印的页面。 0 表示所有工作表的全局书签父级。相当于TFlexCelPdfExport.CurrentPage

TGetBookmarkInformationArgs.CurrentPageInSheet

property CurrentPageInSheet: Integer

当前工作表正在打印的页面。相当于TFlexCelPdfExport.CurrentPageInSheet

TGetBookmarkInformationArgs.Bookmark

property Bookmark: TBookmark

要加入的书签。

TBookmark

PDF 文件的书签列表中的条目。

unit

FlexCel.Pdf

TBookmark.Title

property Title: string

书签项的标题。

TBookmark.ChildrenCollapsed

property ChildrenCollapsed: Boolean

如果为 true,则此书签的所有子书签将被折叠。

TBookmark.TextColor

书签项的文本颜色。

property TextColor: TUIColor

TBookmark.TextStyle

property TextStyle: Set of TBookmarkStyle

书签项的文本样式。

例子

合并导出PDF

TForm1private中增加方法PdfGetBookmarkInformation

uses VCL.FlexCel.Core, FlexCel.XlsAdapter, FlexCel.Render, FlexCel.Pdf;

private
  procedure PdfGetBookmarkInformation(const sender: TObject; const e: TGetBookmarkInformationArgs);

procedure TForm1.PdfGetBookmarkInformation(const sender: TObject;
  const e: TGetBookmarkInformationArgs);
begin
  //通过CurrentPage是否为0判断正在导出Excel还是Sheet
  if e.CurrentPage = 0 then
  begin
    Memo1.Lines.Add('--------------------');
    //调用ExportAllVisibleSheets导出全部工作表时,Excel书签名称为参数bookmarkName的名称
    Memo1.Lines.Add('bookmarkName名称 ' + e.Bookmark.Title);
    //设置标签字体颜色为红色
    e.Bookmark.TextColor := TUIColor(TColor(clRed));
  end
  else
  begin
    //导出Sheet时,标签名称默认为Sheet名称
    Memo1.Lines.Add('Sheet名称 ' + e.Bookmark.Title);
    Memo1.Lines.Add('书签指向的页码 ' + e.CurrentPage.ToString);
    Memo1.Lines.Add('当前Sheet中的页码 ' + e.CurrentPageInSheet.ToString);
  end;
end;

procedure TForm1.Button19Click(Sender: TObject);
var
  Xls1, Xls2: TXlsFile;
  Pdf: TFlexCelPdfExport;
  Stream: TMemoryStream;
begin
  //读取Excel文件
  Xls1 := TXlsFile.Create('C:\Users\Administrator\Desktop\ceshi2.xlsx');
  Xls2 := TXlsFile.Create('C:\Users\Administrator\Desktop\ceshi3.xlsx');
  //关联导出的文档
  Pdf := TFlexCelPdfExport.Create(Xls1, True);
  Stream := TMemoryStream.Create;
  try
    //设置导出PDF自定义书签事件
    Pdf.GetBookmarkInformation := PdfGetBookmarkInformation;
    //设置页面布局
    Pdf.PageLayout := TPageLayout.Outlines;
    //准备导出
    Pdf.BeginExport(Stream);
    //导出第1个Excel文件
    Pdf.ExportAllVisibleSheets(False, '第1个Excel文件');
    //导出第2个Excel文件
    Pdf.Workbook := Xls2;
    Pdf.ExportAllVisibleSheets(False, '第2个Excel文件');
    //结束导出
    Pdf.EndExport;
    //将流数据保存到文件
    Stream.SaveToFile('C:\Users\Administrator\Desktop\ceshi.pdf');
  finally
    Pdf.Free;
    Xls1.Free;
    Xls2.Free;
    Stream.Free;
  end;
end;

标签:TFlexCelPdfExport,FlexCel,Excel,delphi,导出,书签,PDF2,Pdf,property
From: https://www.cnblogs.com/txgh/p/16650410.html

相关文章

  • Delphi 经典游戏程序设计40例 的学习 例26 Image List 的实力与用法
     unitR26;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,ExtCtrls,ImgList;typeTPatDt=rec......
  • Delphi 搜索特征码
    老外开源的代码,使用了各种新语法,测试了能用,支持05??EB这种,不支持老版本DelphiunituPatternFinder;interfaceusesSysUtils,Generics.Collections,Threading;......
  • delphi 【组件TcxPropertiesStore】 窗体界面记忆与恢复
    TcxPropertiesStore组件能记住用户对窗体,网格(列宽/行高,显示/隐藏列),按钮,工具栏等多种形态与位置的记忆.其原理其实就是开发时,在TcxPropertiesStore里设置好要记忆的......
  • Delphi 通用 Hook 库
    Super的开源作品,这里直接拿来用,感谢作者。学习研究内嵌反汇编引擎,可以智能识别抹掉几句汇编代码处理做hook跳转,自动保存被抹掉的汇编代码方便恢复原调用。支持对API的h......
  • Delphi:StringList Delimiter默认受空格字符影响,如何解决
    stringlist通过Delimiter方法获取切割字符,默认受空格字符影响。 var  sl:TStringList;  str:string;  i:Integer;begin  str:='aa,bb,cc,dd';  sl......
  • Delphi 中constructor、destructor、property(构造函数,析构函数、属性)关键字的用法
    首先搜索现成的文章学习原文:https://www.cnblogs.com/guorongtao/p/15132445.html其次自己理解并总结最常见的用法constructor用来定义构造函数,destructor用来定义析构......
  • delphi TdxBarManager学习笔记
    一.WholeRow工具显示模式WholeRow:true工具栏单独在一行显示,不管你有几个内含元素默认为WholeRow:false,即同一行内可以排列多个工具栏,像下图就同时排列了三个工具栏......
  • delphi TMS FlexCel 导出PDF
    TMSFlexCel导出PDF属性和方法TFlexCelPdfExport用于将Excel文件导出为PDF的组件。unitFlexCel.RenderTFlexCelPdfExport.CreateconstructorCreate(constaWorkbo......
  • Delphi 高低字节交换
    内存中的字节顺序与网络传输的字节顺序是不一样的,用名词说就是大端存储和小端存储的区别,有时候就需要转换。Delphi7不支持inline内联函数,可以把inline去掉。functionSwa......
  • Delphi 中的换行符sLineBreak
    其实就是#13#10//Delphi7中:constsLineBreak={$IFDEFLINUX}#10{$ENDIF}{$IFDEFMSWINDOWS}#13#10{$ENDIF};//Delphi11中:constsLineBreak={$IFDEFPOS......