Print Area Problem

Posted by: bastian.wagner on 24 February 2023, 5:19 am EST

  • Posted 24 February 2023, 5:19 am EST

    Hi,

    I’m experiencing some troubles with the printarea in SpreadJs.

    In the default setting,

    sheet.printInfo().columnStart()
    sheet.printInfo().columnEnd()
    sheet.printInfo().rowStart()
    sheet.printInfo().rowEnd()

    all returns -1 and only the filled Area is printed. But when i set the area manually

    sheet.printInfo().columnStart(-1)
    sheet.printInfo().columnEnd(-1)
    sheet.printInfo().rowStart(-1)
    sheet.printInfo().rowEnd(-1)

    the whole sheet with all the empty rows and cols are printed. I would expect only the filled rows and cols are printed. How can I tell Spreadjs to use the “initial” setting? Is this a bug or am i doing something wrong?

    Thanks for any help!

  • Posted 27 February 2023, 8:30 am EST

    Hello,

    You can get the range of only filled rows and columns using sheet.getUsedRange() method and with the help of the used range, you can set print area accordingly using methods printInfo.rowStart(), printInfo.rowEnd(), printInfo.columnStart() and printInfo.columnEnd() method.

    Please refer to the code snippet and attached sample for further understanding.

        let range = sheet.getUsedRange(GC.Spread.Sheets.UsedRangeType.all);
        printInfo.rowEnd(range.row + range.rowCount - 1);
        printInfo.columnEnd(range.col + range.colCount - 1);
        sheet.printInfo(printInfo);


    Sample: https://jscodemine.grapecity.com/share/ExWQC_Rd0EWp10viEBdrZQ/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Findex.html"}

    Please let us know if the issue still persists

    Doc reference

    PrintInfo class: https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Print.PrintInfo#class-printinfo

    sheet.getUsedRange(): https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Worksheet#getusedrange

    Regards,

    Avinash

  • Posted 28 February 2023, 6:09 am EST

    Thanks for the reply!

    your solution is working, the only problem is, that floating objects are not included and get cut off (when in range they get printed). Is there a solution to include floating objects in this calculation, i did not see a value in the enum that says floating object?

    Thanks in advance,

    Bastian

  • Posted 1 March 2023, 3:39 am EST

    Hi,

    We are sorry but the floating object is not supported in print. YOu may refer to the following page which has a list of features that are not supported with printing.

    Demo and list of features: https://www.grapecity.com/spreadjs/demos/features/print/custom-print#demo_source_name

    Regards,

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels