Hi,
I recently found a bug in these methods where calling them correctly deletes the row/column on the workbook, but does not update the formula references based on this deletion. I am attaching a snippet of the code I ran:
using NUnit.Framework;
using System;
namespace Aspose_bug_in_Delete_Row
{
class Program
{
static void Main(string[] args)
{
using (Workbook workbook = new Workbook())
{
Worksheet sheet2 = workbook.Worksheets[workbook.Worksheets.Add()];
Worksheet sheet3 = workbook.Worksheets[workbook.Worksheets.Add()];
string formula = $"{sheet2.Name}!B2";
sheet3.Cells["A1"].Formula = formula;
sheet2.Cells.DeleteRows(
rowIndex: 0,
totalRows: 1);
workbook.CalculateFormula();
Assert.AreEqual(
expected: $"={sheet2.Name}!B1",
actual: sheet3.Cells["A1"].Formula);
}
}
}
}
The result that we get is this:
test failure.PNG (23.6 KB)
We are aware that there are methods (like the ones below) that can be used to update references, but updating references and recalculating with each deletion seems computationally excessive. Without this bug we would be able to aggregate delete operations and ideally have Workbook.CalculateFormula()
update the references for us.
public void DeleteColumn(int columnIndex);
public void DeleteColumn(int columnIndex, bool updateReference);
public void DeleteColumns(int columnIndex, int totalColumns, bool updateReference);
public void DeleteRow(int rowIndex);
public bool DeleteRows(int rowIndex, int totalRows);
public bool DeleteRows(int rowIndex, int totalRows, bool updateReference);
This bug leads to some undesired compromise of the integrity of workbook formulas and it would be great if you could fix this on your end. Thanks.
Best,
YJ