Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EPPlus/Core/ChangableDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal virtual void InsertAndShift(int fromPosition, int add)
pos = ~pos;
}

if (pos + 1 >= _index[0].Length - 1)
if (_count >= _index[0].Length - 1)
{
Array.Resize(ref _index[0], _index[0].Length << 1);
Array.Resize(ref _index[1], _index[1].Length << 1);
Expand Down
18 changes: 18 additions & 0 deletions src/EPPlusTest/Issues/WorksheetIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using OfficeOpenXml.Drawing;
using OfficeOpenXml.Drawing.Chart;
using OfficeOpenXml.FormulaParsing;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
using OfficeOpenXml.FormulaParsing.Excel.Functions.MathFunctions;
using OfficeOpenXml.RichData;
Expand Down Expand Up @@ -1112,5 +1113,22 @@ public void i2258()
Assert.AreEqual("Negative 4000,000", d3);
}

[TestMethod]
public void InsertAndShift_ShouldNotThrow_WhenArrayIsFull()
{
using var package = new ExcelPackage();
var sheet = package.Workbook.Worksheets.Add("Sheet1");

// Fill 7 columns with formatting to trigger the boundary condition
for (int col = 1; col <= 7; col++)
{
sheet.Column(col).Width = 15;
}

// These two inserts should not throw ArgumentException
sheet.InsertColumn(3, 1);
sheet.InsertColumn(5, 1);
}

}
}