Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tables gets corrupted when removing rows #1539

Closed
spearmootz opened this issue May 13, 2023 · 4 comments
Closed

Tables gets corrupted when removing rows #1539

spearmootz opened this issue May 13, 2023 · 4 comments

Comments

@spearmootz
Copy link

spearmootz commented May 13, 2023

Description

Table becomes corrupt when removing rows. i have found no way to modify the sample file to have only 1 record without some form of corruption on the table.

NOTE: i am using excelize-wasm

maybe related. #387

i am trying to modify an excel template, but i have to hack certain things to achieve non corrupt files and even then there are limitations.

Steps to reproduce the issue:

  1. download sample file output.xlsx
  2. read sample file
  3. then do one of the following actions
  • Remove row 2 (first data row) (Table loses formatting and its no longer a table)
  • Remove row 3 (last data row) (Table loses formatting and its no longer a table)

Describe the results you received:

table formatting was lost or file became corrupt

Describe the results you expected:

that the table is left intact with no corruption in the file

things that do work

  • INSERT a row 2 and then removing it
  • INSERT a row 3 and then removing row 2 (first with data)
  • INSERT a row 3 and then removing row 4 (last with data)

Output of go version:

NODE VERSION (not using go directly)
v16.18.0

Excelize version or commit ID:

on NPM
"excelize-wasm": "^0.0.3",

Mac OS

Environment details (OS, Microsoft Excel™ version, physical, etc.):
Mac OS 13.3.1
Excel 16.69.1

@spearmootz
Copy link
Author

it also happens when you have a table with one record and then duplicating the row (kinda needed to extend the table per say)

my findings are the following.

  • the table xml does not get updated
  • the table parts count and table part goes missing: for example
       <tableParts count="1">
        <tablePart r:id="rId3" />
    </tableParts>

turns to

 <tableParts>    </tableParts>

@spearmootz
Copy link
Author

so, did more research and just tried to create the table from the library.

lets say i create a 3 x 3 table (including header)

if i set values to the 4th row, the table does not expand which i think its fine.

if i insert or duplicate a record on the 2nd row (1st row with values) and then set the values, it works.

if i insert on 3rd row it works.

if i duplicate 3rd row into 4th row, it does not work

OK! so at least i found a way for my use case. the workaround i did was. if the template only has one record, then i insert a record which makes the table 2 records. then i can duplicate the last record with data which persists some styles and formulas, overwrite variables. then i delete that last empty record i created on the table.

so now i can work, hopefully all this information allows you to get to the bottom of this.

@spearmootz
Copy link
Author

Here is my guess. i dont test it because i dont have go setup

InsertRows does "adjustHelper" at the very last step.

in contrast, the duplicateStep does it somewhere in the middle. maybe either move it to the end or do it twice? not sure.

@xuri xuri closed this as completed in 76cd099 May 22, 2023
@xuri
Copy link
Member

xuri commented May 24, 2023

Hi @spearmootz, thanks for your issue. I have fixed this, please try to upgrade the master branch code, and I have updated the WebAssembly ports excelize-wasm. This patch will be released in the next version.

xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants