Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
190
Customizing Summary Row in ExcelExporter
posted

Hi There,

I'm trying to get access to the worksheet or xlRow object in the summaryExporting event. 

What i'm trying to do is to simply bold the text on the summary line of the exported excel row

I'm doing something similar in the CellExported event without issue.

Here's the code snippet for that

cellExported: function (e, args) {
if (args.xlRow.index() == 0) {
return;
}
if (args.columnKey == "DailyTotal" || args.columnKey == "DailyCheckTotal" || args.columnKey == "DailyCardTotal") {
args.xlRow.getCellFormat(args.columnIndex).font().bold(1);
}
}

How do i simply bold all cells in the summary row of the exported worksheet?

Parents
No Data
Reply
  • 240
    Offline posted

    Hello Andrew,

    To apply bold formatting to summary cells when exporting a grid to Excel, you can utilize the summaryExporting event. This event provides access to each summary cell, allowing you to format it individually during the export process.

    The key to achieving this is correctly identifying the summary row’s position in the exported worksheet. This is done by calculating the actual row index using summaryRowIndex + xlRowIndex. The summaryRowIndex represents the summary iterative position within the column, while xlRowIndex accounts for its placement in the Excel worksheet.

    Once the correct row is determined, the specific column index (columnIndex) is used to locate the exact summary cell within that row. The formatting is then applied by retrieving the cell and setting its font to bold using row.getCellFormat(columnIndex).font().bold(1). This ensures that only the relevant summary cells are affected, rather than formatting the entire row.

    Here is the code implementation:

    {
                            summaryExporting: function (sender, args) {
                                var worksheet = sender._worksheet; // Get the worksheet object
                                var targetRowIndex = args.summaryRowIndex + args.xlRowIndex; // Calculate the correct summary row index
                                var columnIndex = args.columnIndex; // Get the column index
    
                                if (worksheet && targetRowIndex >= 0) {
                                    var row = worksheet.rows(targetRowIndex); // Access the correct row in the worksheet
    
                                    if (row) {
                                        row.getCellFormat(columnIndex).font().bold(1); // Bold the specific cell in the summary row
                                    }
                                }
                            }
     }

    Best Regards,
    Arkan Ahmedov,
    Infragistics

Children
No Data