Author Topic: pqGrid Excel Export – How to Set Cell Borders and Row Height (Headers & Data)  (Read 604 times)

luckduck

  • Pro OEM
  • Jr. Member
  • *
  • Posts: 60
    • View Profile
Hello,

I have a question regarding exporting pqGrid data to an Excel file.

When exporting, I would like to customize:

   - Borders for both header cells and data cells
   - Row height for headers and data

However, I’m finding it difficult to implement this using only the API documentation. It would be very helpful if you could provide a sample example demonstrating how to apply these styles during export.

Additionally, in my current implementation, I’ve noticed that when a grid cell value is null, the border is not applied in the exported Excel file. I would appreciate it if you could confirm whether this is expected behavior or if there is a way to handle it properly.

Thank you in advance for your help.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6552
    • View Profile
Customizing pqGrid Excel Export via Callbacks

Borders and row heights can be efficiently managed using the each* callbacks within the exportData method. This approach allows you to inject htFix for dimensions and border objects for styling directly into the export engine.

    htFix: Applied to the row object to set a fixed height in pixels.
    border: Applied to the cell object using a CSS-like string syntax (e.g., "1px solid #000000").
    • Coordinate Mapping: Use ri (row index) and ci (column index) to target specific cells or headers.
    Code: [Select]
    eachCell(cell, ci, ri){
    if(ri==2 && ci == 2){
    //debugger
    cell.border = {
    top: "1px dotted #ff0000",
    bottom: "1px solid #ff0000",
    }
    }
    },
    eachRowHead(row, ri){
    row.htFix = 100
    },
    eachRow(row, ri){
    row.htFix = 50
    }

    I was able to apply borders to empty cells and it was exported correctly.
    « Last Edit: April 20, 2026, 10:08:32 pm by paramvir »