Combined export of multiple grids to csv, html, pdf and xlsx


Csv

For csv, we concatenate the csv strings returned by exportData() method

var csv1 = grid1.exportData({ format: 'csv' });//export 1st grid
var csv2 = grid2.exportData({ format: 'csv', skipBOM: true });//export 2nd grid

var data = csv1 + "\n\n" + csv2;
pq.saveAs(data, "pqGrid.csv");

Xlsx

For xlsx, we extract sheet from the other workbooks and add it to the sheets collection of the first workbook

    var w1 = grid1.exportExcel({workbook: true});//export 1st grid into js workbook.
    var w2 = grid2.exportExcel({workbook: true});//export 2nd grid into js workbook.

    w1.sheets.push( w2.sheets[0] );//copy worksheet of 2nd workbook to sheets collection of 1st workbook.

    var blob = pq.excel.exportWb({workbook: w1, type: 'blob'});//export 1st workbook into Excel file.
    pq.saveAs(blob, "pqGrid.xlsx" );

Html export

For html export, we simply concatenate the html strings returned by exportData method.

var html1 = grid1.exportData({ format: 'htm' });//export 1st grid
var html2 = grid2.exportData({ format: 'htm' });//export 2nd grid

pq.saveAs( "First table" + html1 + "Second table" + html2, "pqGrid.html");

Pdf export

For Pdf export, we add document definiition objects returned by exportData method to the content array of document definition object of whole Pdf document.

content: [
    {
        text: "First table:", margin: [0, 10, 0, 5]
    },
    {
        //include document definition of grid.
        table: dd1
    },
    {
        text: "Second table:", margin: [0, 10, 0, 5], pageBreak: 'before'
    },
    {
        table: dd2
    }
],