已验证 提交 76cd0992 编写于 作者: xurime's avatar xurime

This closes #1539, fix adjust table issue when after removing rows

上级 c2327484
...@@ -242,7 +242,7 @@ func (f *File) adjustTable(ws *xlsxWorksheet, sheet string, dir adjustDirection, ...@@ -242,7 +242,7 @@ func (f *File) adjustTable(ws *xlsxWorksheet, sheet string, dir adjustDirection,
} }
coordinates = f.adjustAutoFilterHelper(dir, coordinates, num, offset) coordinates = f.adjustAutoFilterHelper(dir, coordinates, num, offset)
x1, y1, x2, y2 := coordinates[0], coordinates[1], coordinates[2], coordinates[3] x1, y1, x2, y2 := coordinates[0], coordinates[1], coordinates[2], coordinates[3]
if y2-y1 < 2 || x2-x1 < 1 { if y2-y1 < 1 || x2-x1 < 0 {
ws.TableParts.TableParts = append(ws.TableParts.TableParts[:idx], ws.TableParts.TableParts[idx+1:]...) ws.TableParts.TableParts = append(ws.TableParts.TableParts[:idx], ws.TableParts.TableParts[idx+1:]...)
ws.TableParts.Count = len(ws.TableParts.TableParts) ws.TableParts.Count = len(ws.TableParts.TableParts)
idx-- idx--
......
...@@ -320,6 +320,7 @@ func TestAdjustTable(t *testing.T) { ...@@ -320,6 +320,7 @@ func TestAdjustTable(t *testing.T) {
} }
assert.NoError(t, f.RemoveRow(sheetName, 2)) assert.NoError(t, f.RemoveRow(sheetName, 2))
assert.NoError(t, f.RemoveRow(sheetName, 3)) assert.NoError(t, f.RemoveRow(sheetName, 3))
assert.NoError(t, f.RemoveRow(sheetName, 3))
assert.NoError(t, f.RemoveCol(sheetName, "H")) assert.NoError(t, f.RemoveCol(sheetName, "H"))
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAdjustTable.xlsx"))) assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAdjustTable.xlsx")))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册