Search Results for

    Show / Hide Table of Contents

    Finding out how many pages will be exported

    If you need to calculate the number of pages a report will take without actually exporting it or printing it, you can use the code below.

    function NumberOfPagesToExport(const xls: TExcelFile): Int32;
    var
      img: TFlexCelImgExport;
      ExportInfo: IImgExportInfo;
    begin
      img := TFlexCelImgExport.Create(xls);
      try
        ExportInfo := img.GetFirstPageExportInfo;
        exit(ExportInfo.TotalPages);
      finally
        img.Free;
      end;
    end;
    

    You can use the TFlexCelImgExport.GetFirstPageExportInfo method to find out a lot of information about how the pages will be exported. For example, you might have set a "Print to fit" in one page wide, and wonder which zoom FlexCel will use to fit the page. If the zoom is too small, you might want to change it to fit in two pages wide. To get the zoom used in the page, you can use:

    function FinalZoom(const xls: TExcelFile; const sheet: Int32): RealNumber;
    var
      img: TFlexCelImgExport;
      ExportInfo: IImgExportInfo;
    begin
      img := TFlexCelImgExport.Create(xls);
      try
        ExportInfo := img.GetFirstPageExportInfo;
        exit(ExportInfo.Sheet(sheet).ZoomUsed);
      finally
        img.Free;
      end;
    end;
    
    In This Article
    Back to top FlexCel Studio for VCL and FireMonkey v7.24
    © 2002 - 2025 tmssoftware.com