ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: TraTech on December 01, 2021, 10:14:00 pm
-
Hello Support-Team,
The "Export" Option works only if the colour of the column or row is mentioned in Hex-Code.
If the colour is mentioned as 'red' or 'green', it's correctly displayed in the grid, but when the "Export" option is clicked, nothing happens.
In the web console an error message "Uncaught invalid colour: red" is present.
Please advise if there is a workaround for this.
Thanking you in advance.
Best regards,
-
Hi TraTech
Yes there is a workaround.
Step1: First export to js workbook.
Step 2: replace string color values with hex values in the workbook.
Step 3: export to xlsx.
listener: function() {
var colors = {
red: '#FF0000',
yellow: '#FFFF00',
green: '#00FF00',
blue: '#0000FF'
}
var wb = this.exportExcel({workbook: true});
pq.excel.eachCell(wb.sheets, function( cell, ci, ri, si ){
//do something with each cell.
cell.color = colors[cell.color] || cell.color;
});
var blob = pq.excel.exportExcel({workbook: wb, type: 'blob'});
saveAs(blob, "pqGrid.xlsx" );
}
Hope it helps.
-
Hello Paramvir,
Thankyou for the quick reply.
Is there a new library required to use the workbook-js?
We are using the "FileSaver.js" to perform the export option.
Is there any example that I could refer to view how this works.
Thanking you in advance!
Best regards,
-
Hi TraTech
js workbook is part of paramQuery and doesn't require any other library.
Structure of js workbook: https://paramquery.com/pro/api/excel-workbook
These 2 examples show usage of js workbook.
https://paramquery.com/pro/demos/export_detail
https://paramquery.com/pro/demos/export_sheets
Please also refer to this API
https://paramquery.com/pro/api#method-eachCell
https://paramquery.com/pro/api#method-exportExcel
https://paramquery.com/pro/api#method-exportWb