[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

PagePrintEventArgs

Class PagePrintEventArgs

java.lang.Object
com.grapecity.documents.excel.EventArgs
com.grapecity.documents.excel.PagePrintEventArgs
Direct Known Subclasses:
PagePrintedEventArgs, PagePrintingEventArgs

public class PagePrintEventArgs extends EventArgs
为 PagePrinting 和 PagePrinted 事件提供数据。

此事件数据类提供打印处理所需的页面相关信息,包括当前页的从 1 开始的页码和总页数。


 worksheet.getRange("A1:A96").setValue(1);
 PdfSaveOptions options = new PdfSaveOptions();
 options.getPagePrintingEvent().addListener(new EventHandler<PagePrintingEventArgs>() {
     public void invoke(Object sender, PagePrintingEventArgs e) {
         int pageNumber = e.getPageNumber();
         int pageCount = e.getPageCount();
     }
 });
 workbook.save(new ByteArrayOutputStream(), options);
 
  • Constructor Details

    • PagePrintEventArgs

      public PagePrintEventArgs()
  • Method Details

    • getPageNumber

      public final int getPageNumber()
      获取与此事件关联的从 1 开始的页码。

      此值标识 PagePrinting 或 PagePrinted 事件序列中当前正在处理的页面。

      
       worksheet.getRange("A1:A96").setValue(1);
       PdfSaveOptions options = new PdfSaveOptions();
       options.getPagePrintingEvent().addListener(new EventHandler<PagePrintingEventArgs>() {
           public void invoke(Object sender, PagePrintingEventArgs e) {
               int pageNumber = e.getPageNumber();
           }
       });
       workbook.save(new ByteArrayOutputStream(), options);
       
      Returns:
      与当前事件关联的从 1 开始的页码。
    • getPageCount

      public final int getPageCount()
      获取与当前页面打印事件关联的总页数。

      此值表示引发当前 PagePrintingEventArgs 或 PagePrintedEventArgs 实例的打印操作的总页数。

      
       worksheet.getRange("A1:A96").setValue(1);
       PdfSaveOptions options = new PdfSaveOptions();
       options.getPagePrintingEvent().addListener(new EventHandler<PagePrintingEventArgs>() {
           public void invoke(Object sender, PagePrintingEventArgs e) {
               int pageCount = e.getPageCount();
           }
       });
       workbook.save(new ByteArrayOutputStream(), options);
       
      Returns:
      当前打印操作的总页数。