jxlsteam / jxls

Java library for creating Excel reports using Excel templates
http://jxls.sourceforge.net
Apache License 2.0
405 stars 92 forks source link

Using "each" and "merge" cause problem #62

Open Younsion opened 4 years ago

Younsion commented 4 years ago

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.

SoltauFintel commented 4 years ago

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

Younsion commented 4 years ago

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...

SoltauFintel commented 4 years ago

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

SoltauFintel commented 4 years ago

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

Younsion commented 4 years ago

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

howiewant commented 9 months ago

这个问题解决了吗

gastendonk commented 9 months ago

Nein.

fitzyyf commented 7 months ago

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);
  }