Search Results for

    Show / Hide Table of Contents

    TFlexCelPrintDocument Class

    Use this class to print an Excel file natively.

    Remarks

    This class uses the settings from the standard "Printer" object in Delphi, so to change most settings, you should change the settings for Printer. You can also use a standard Delphi PrintDialog to allow the user to choose printer and parameters.

    Syntax

    Unit: FlexCel.Render

    TFlexCelPrintDocument = class(TFlexCelObject);

    Constructors

    Name Description
    Create Overloaded
    Create
    Create(TExcelFile)

    Methods

    Name Description
    OnBeforeNewPage Replace this event when creating a custom descendant of FlexCelPrint​Document. See also BeforeNewPage
    OnBeforeGeneratePage Replace this event when creating a custom descendant of FlexCelPrint​Document. See also BeforeGeneratePage
    OnAfterGeneratePage Replace this event when creating a custom descendant of FlexCelPrint​Document. See also AfterGeneratePage
    Cancel Cancels a printing process. This method is equivalent to setting Canceled = true.
    Note: Please note that when you set a thread to Terminated, the printing will be canceled too. So normally you don't need this method, just Terminate the thread.
    Print Prints the active sheet of the associated xls workbook.
    BeginPrint Initializes the printing engine. After calling this method you can call PrintSheet to print different xls files, or PrintAllVisible​Sheets. You should always end printing with a call to EndPrint
    EndPrint Finishes the printing process. You should always call this method.
    CalcPrintArea Calculates the actual spreadsheet range that will be printed. This is given by: 1)If you specified non zero values on PrintRange, this will be used.
    2)If any value in PrintRange is zero and there is a Print Area defined on the spreadsheet, the Print Area will be used.
    3)If there is no PrintRange and no Print Area defined, the visible cells on the sheet will be printed.
    TotalPagesInSheet Returns the number of pages that the active sheet will use when printed.
    PrintSheet Overloaded
    PrintSheet
    PrintSheet(Integer, Integer, Integer, Integer)
    PrintAllVisible​Sheets This method will print all the visible sheets on an xls file.
    Different than calling PrintSheet for each sheet, this method can keep the page number growing on each sheet, without resetting it.

    Properties

    Name Description
    Canceled If true the printing has been canceled with Cancel method.
    You can't set this variable to false, and setting it true is the same as calling Cancel.
    Note: Please note that when you set a thread to Terminated, the printing will be canceled too. So normally you don't need this property, just Terminate the thread.
    Progress Progress of the printing. This variable can be accessed from other thread, or from the AfterGeneratePage event.
    Workbook The ExcelFile to print.
    HidePrintObjects Select which kind of objects should not be printed.
    ExportSheetBackground​Images If false (the default) then the background images in the sheet won't be exported. Note that Excel doesn't print or export background images, and when it shows them on the screen they look the same no matter the sheet zoom.
    When you set this to true we will try to export the image, but it will grow and shrink when you zoom, making it look different from what Excel shows.
    PrintRangeLeft First column to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated.
    PrintRangeTop First row to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated.
    PrintRangeRight Last column to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated.
    PrintRangeBottom Last row to print (1 based). if this or any other PrintRange property is 0, the range will be automatically calculated.
    PageSize Page size. Set it to null to use the paper size on the xls file.
    CurrentPage Returns the next page that we are going to print.
    CurrentPageInSheet Returns the next page we are going to print, on the current sheet.
    When not printing more than one sheet, it is equivalent to CurrentPage
    PrintAsBitmap If true, the file will be rendered to a bitmap and then we will print the bitmap, instead of directly printing the file.
    Use with caution. See remarks
    BitmapDPI When using a bitmap to print (PrintAsBitmap is true), this property specifies the resolution for the temporary bitmap that will be sent to the printer. The higher the resolution the better quality of the print, but also the more memory, network time and processing time it will take.
    Important: A value of 0 means creating bitmaps with the native printer resolution. This will give the best quality, but the bitmap can be big. A negative value means no bitmap used, and it is the same as setting...[more]

    Events

    Name Description
    BeforeNewPage Fires before each new page is printed.
    You can use this event to change the pagesize for the new sheet.
    BeforeGeneratePage Fires after each new page is printed, but before any content is written to the page. (The page is blank) You can use this event to add a watermark or a background image.
    AfterGeneratePage Fires after each new page is printed, and after all content is written to the page. (The page is written) You can use this event to add some text or images on top of the page contents.
    In This Article
    Back to top FlexCel Studio for VCL and FireMonkey v7.24
    © 2002 - 2025 tmssoftware.com