SpreadJS 13
SpreadJS Documentation / Developer's Guide / Features / Manage Data / Understand Printing / Get Page Information
In This Topic
    Get Page Information
    In This Topic

    SpreadJS allows users to get essential page information including the total number of pages, row count, column count, row index and column index of each page while working with spreadsheets. This feature is useful especially when users want to know important information about the page before printing the worksheet data.

    For instance, let's assume that you're working with a Financial application using Excel as a reporting tool. Now, you want to get the page information before the sheet executes the printing job and you want to create an "index page" as well. Using this feature, users can determine 1) the accurate page count (how many pages will be printed in the sheet) and 2) the print range in each printing page [i.e. the page row and column information]. This will help users to print the desired data in an efficient manner.

    Using Code

    Refer to the following example code in order to get page information while working with spreadsheets.

    JavaScript
    Copy Code
    // Initializing Spread
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'),
    { sheetCount: 1 });
    spread.suspendPaint();
    
    // Fetch the ActiveSheet
    var sheet = spread.getActiveSheet();
    for (var i = 0; i < 20; i++)
    {
    for (var j = 0; j < 18; j++)
    {
    sheet.setValue(i, j, "Row" + i + " Col" + j);
    }
    }
    spread.resumePaint();
    var pageInfos = spread.pageInfo(0);
    console.log("Total no. of pages: " + pageInfos.pageCount);
    for (var p = 0; p < pageInfos.pageCount; p++) {
    console.log("ColCount of Page[" + p + "] is: " + pageInfos.pages[p].columnCount);
    console.log("RowCount of Page[" + p + "] is: " + pageInfos.pages[p].rowCount);
    }