excel-templates icon indicating copy to clipboard operation
excel-templates copied to clipboard

Merged cells not expanding properly

Open smahood opened this issue 8 years ago • 1 comments

If a merged cell is contained in a row of the template Excel file, and that row is replaced by more than one row, the resulting Excel file only carries the merge over for the original row.

So if row 22 has a merged cells, and it is replaced by 3 rows, then row 22 in the new file will still contain the merged cells but rows 23 and 24 will not.

smahood avatar Apr 11 '16 16:04 smahood

It looks like merged cell info is stored in the worksheet (eg. "sheet1.xml") in the <mergeCells> tag under the root tag.

There is a count attribute that has to be updated as well.

<mergeCells count="4"> <mergeCell ref="A38:G38"/> <mergeCell ref="A39:G39"/> <mergeCell ref="A40:G40"/> <mergeCell ref="A32:G32"/> </mergeCells>

Reference on page 1639 of ECMA-376, 4th Edition, Office Open XML File Formats — Fundamentals and Markup Language Reference.

smahood avatar Apr 22 '16 22:04 smahood