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

Doesn't work properly when inserting additional rows to named table

Open smahood opened this issue 8 years ago • 2 comments

When inserting rows to a named table, upon opening the new file Excel asks to repair the file. Repair message indicates Repaired Records: Table from /xl/tables/table1.xml part (Table)

The new rows do insert, but do not extend the length of the table to accommodate the new rows.

Reference to tableParts on pages 1698-1699, reference to Tables in general on page 1718, all in ECMA-376, 4th Edition, Office Open XML File Formats — Fundamentals and Markup Language Reference.

smahood avatar Apr 22 '16 22:04 smahood

Looking briefly into a simple file, it looks like we are not properly updating the <table ref> and <autoFilter>attributes in table1.xml

In a manually added and correct file, the section in table1.xml is `<table xmlns='http://schemas.openxmlformats.org/spreadsheetml/2006/main' id='1' name='Table1' displayName='Table1' ref='A1:C5' totalsRowShown='0'> <autoFilter ref='A1:C5'/> ...

`

In the version produced by excel-templates, that same section is `<table id='1' name='Table1' displayName='Table1' ref='A1:C4' totalsRowShown='0' xmlns='http://schemas.openxmlformats.org/spreadsheetml/2006/main'> <autoFilter ref='A1:C4'/> ...

`

Both files have had one row added in the middle of the table from the original template.

I haven't found anything else different but it is definitely possible there are other things missing.

smahood avatar Apr 22 '16 22:04 smahood

This is just not implemented because I didn't think of it/need it.

What we need to do is simply parse and rewrite the range formula in the ref nodes in the context of the correct sheet (just like we do for chart formulas already). Since we're already starting #28, I'm inclined to use the new transformation engine that we'll build for that because I think that doing this with POI will be difficult. If it's a blocker for anyone, let me know and I'll see if I can fix it quickly in the current implementation.

I think that we'll end up having cloning problems with tables as well.

tomfaulhaber avatar Apr 22 '16 23:04 tomfaulhaber