jxls icon indicating copy to clipboard operation
jxls copied to clipboard

Using "each" and "merge" cause problem

Open Younsion opened this issue 4 years ago • 8 comments

hi,jxls team when i am using 'each' and 'mergeCells' at the same time,i found the problem below here。 my template: image

what i want: image

But what I actually got is: image

am i wrong or it is a bug? waiting for your reply...thank you.

Younsion avatar Oct 19 '20 08:10 Younsion

I don't know. But I see that you have 5 extra rows and have a +5 in your formula!?

SoltauFintel avatar Oct 19 '20 09:10 SoltauFintel

yes...as you see,what i want is the piture 2,the each-loop include the '分组平均水平'(the extra 5 rows),so i do '+5' in the merge command...

Younsion avatar Oct 19 '20 09:10 Younsion

Because of Corona, we are currently spending significantly less time on JXLS. Therefore an answer or processing can take longer.

SoltauFintel avatar Oct 27 '20 09:10 SoltauFintel

You could upload an example template and a piece of source code. But please with no Chinese chars.

SoltauFintel avatar Oct 29 '20 06:10 SoltauFintel

hi,here is a example of it: sample.zip

Younsion avatar Oct 30 '20 03:10 Younsion

这个问题解决了吗

howiewant avatar Jan 23 '24 01:01 howiewant

Nein.

gastendonk avatar Jan 23 '24 08:01 gastendonk

I just happened to encounter the same problem, which might be an issue. It could be that after merging the cells , the mergeCells command adjusts the Size, not using the default template cell Size. This leads to an increase in row or column index labels during subsequent loops, which results in new rows. You can customize a merge command that only performs the merge without changing the columns.

 @Override
  public Size applyAt(CellRef cellRef, Context context) {
    int rows = getVal(this.rows, context);
    int cols = getVal(this.cols, context);

    if (rows > 1 || cols > 1) {
      getTransformer().mergeCells(cellRef, rows, cols);
    }
    area.applyAt(cellRef, context);
    return area.applyAt(cellRef, context);
  }

fitzyyf avatar Mar 30 '24 12:03 fitzyyf