Author Topic: Exported Excel Issues with Merged Cells and SUM in WPS/MS Office  (Read 1316 times)

saritha_sdwot

  • Pro OEM
  • Newbie
  • *
  • Posts: 1
    • View Profile
Hi,

I'm facing a couple of issues with Excel files exported from ParamQuery Grid:

The exported Excel file is downloaded with a .xls extension, which doesn't open properly in Microsoft Office. To work around this, I renamed it to .xlsx, and it opens fine.

However, I'm encountering a problem with merged cells in the exported file. When using the SUM() function on merged cells:

In WPS Office and Microsoft Excel, the sum includes duplicate values from the merged regions (i.e., it adds hidden values under the merged cells).

In LibreOffice, it works correctly and only includes the value from the visible (top-left) cell in the merged range.

This issue appears only in Excel files exported from ParamQuery Grid. If I manually unmerge and remerge the cells in Excel, the problem is resolved — which suggests the initial export includes hidden values in all cells of the merged range.

Is there a way to modify the export logic in ParamQuery so that:

Only the top-left cell of a merged range contains a value,

The other cells in the merged range are left blank (like LibreOffice expects)?

Thanks!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6407
    • View Profile
Re: Exported Excel Issues with Merged Cells and SUM in WPS/MS Office
« Reply #1 on: June 19, 2025, 04:37:36 pm »
1st issue:

ParamQuery Pro supports xlsx format only, so please ensure to name the file with xlsx extension while downloading the file.


2nd issue:

Please add this refresh event in the grid initialization object. It would ensure to clear all the merged cells except the 1st cell in merged cell range, whenever any range of cells is merged in ParamQuery grid.

Code: [Select]
                refresh(){                   
                    var mc = this.options.mergeCells,
                        mcLast = mc.at(-1);
                    if( mcLast ){
                        //debugger;
                        let {r1, c1, r2, c2, rc, cc, cleared} = mcLast,
                            count = rc * cc;
                        if(count > 1 && !cleared){
                            let val = this.Range({r1, c1}).value()[0],
                                r = this.Range({r1, c1: c1, r2, c2});

                            mcLast.cleared = true;
                            this.one('beforeValidate', (evt, ui) => {ui.history = false});
                            r.value([val]);                           
                        }
                    }
                },