Skip to content

Commit 43bba35

Browse files
authored
Merge pull request #1383 from EPPlusSoftware/bug/issue1382
Fixes issue 1382
2 parents af0e644 + 6abff21 commit 43bba35

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

src/EPPlus/ExcelAddressBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ internal ExcelAddressBase DeleteRow(int row, int rows, bool setFixed = false, bo
11361136
else if (row+rows < _fromRow || (_fromRowFixed && row < _fromRow)) //Before
11371137
{
11381138
var toRow = ((setFixed && _toRowFixed) || (adjustMaxRow==false && _toRow==ExcelPackage.MaxRows)) ? _toRow : _toRow - rows;
1139-
return new ExcelAddressBase((setFixed && _fromRowFixed ? _fromRow : _fromRow - rows), _fromCol, toRow, _toCol, _fromRowFixed, _fromColFixed, _toRowFixed, _toColFixed, WorkSheetName, _address);
1139+
return new ExcelAddressBase((setFixed && _fromRowFixed ? _fromRow : Math.Max(row, _fromRow - rows)), _fromCol, toRow, _toCol, _fromRowFixed, _fromColFixed, _toRowFixed, _toColFixed, WorkSheetName, _address);
11401140
}
11411141
else //Partly
11421142
{

src/EPPlus/ExcelCellBase.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,6 @@ internal static string UpdateFormulaReferences(string formula, int rowIncrement,
10121012
tokens = SourceCodeTokenizer.Default.Tokenize(formula);
10131013
}
10141014
var f = "";
1015-
//string wsName = "";
10161015
for(int i=0;i<tokens.Count;i++)
10171016
{
10181017
var t = tokens[i];
@@ -1093,16 +1092,8 @@ internal static string UpdateFormulaReferences(string formula, int rowIncrement,
10931092
f += "#REF!";
10941093
}
10951094
else
1096-
{
1097-
var ix = address.Address.LastIndexOf('!');
1098-
if (ix > 0)
1099-
{
1100-
f += address.Address.Substring(ix + 1);
1101-
}
1102-
else
1103-
{
1104-
f += address.Address;
1105-
}
1095+
{
1096+
f += address.LocalAddress;
11061097
}
11071098

11081099

src/EPPlusTest/Core/Range/Delete/RangeDeleteTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,11 +1526,11 @@ public void DeleteRowValidateArrayFormula()
15261526
{
15271527
using var package = new ExcelPackage();
15281528
var sheet = package.Workbook.Worksheets.Add("Sheet 1");
1529-
sheet.Cells["A2"].Formula = "XLOOKUP($A$3,$B:$B,!$C:$C)";
1529+
sheet.Cells["A2"].Formula = "XLOOKUP($A$3,$B:$B,$C:$C)";
15301530
sheet.Calculate();
15311531
sheet.DeleteRow(1);
15321532

1533-
Assert.AreEqual("XLOOKUP($A$2,$B:$B,!$C:$C)", sheet.Cells["A1"].Formula);
1533+
Assert.AreEqual("XLOOKUP($A$2,$B:$B,$C:$C)", sheet.Cells["A1"].Formula);
15341534
}
15351535

15361536
}

src/EPPlusTest/Issues/WorksheetIssues.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,17 @@ public void s640()
303303
SaveAndCleanup(package);
304304
}
305305
}
306-
306+
[TestMethod]
307+
public void s640_2()
308+
{
309+
using (var package = OpenTemplatePackage("s640-2.xlsx"))
310+
{
311+
var sheet = package.Workbook.Worksheets.First();
312+
sheet.DeleteRow(6, 8);
313+
SaveAndCleanup(package);
314+
}
315+
}
316+
307317
[TestMethod]
308318
public void s641()
309319
{

0 commit comments

Comments
 (0)