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

System.ArgumentOutOfRangeException when using ExcelWorksheet.InsertRow #582

Open
thetilliwilli opened this issue Jan 21, 2022 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@thetilliwilli
Copy link

thetilliwilli commented Jan 21, 2022

[Description]
EPPlus version: 5.8.1

  1. Put some data (it may be even cell with changed background only) at last row of excel
    image

  2. insert 1 row at any position, e.g. ExcelWorksheet.InsertRow(1,1)

[Result]

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'Can't insert. Rows will be shifted outside the boundries of the worksheet.')
   at OfficeOpenXml.Core.Worksheet.WorksheetRangeInsertHelper.ValidateInsertRow(ExcelWorksheet ws, Int32 rowFrom, Int32 rows)
   at OfficeOpenXml.Core.Worksheet.WorksheetRangeInsertHelper.InsertRow(ExcelWorksheet ws, Int32 rowFrom, Int32 rows, Int32 copyStylesFromRow)
   at OfficeOpenXml.ExcelWorksheet.InsertRow(Int32 rowFrom, Int32 rows, Int32 copyStylesFromRow)
   at OfficeOpenXml.ExcelWorksheet.InsertRow(Int32 rowFrom, Int32 rows)

[ExpectedResult]
No exception, new rows inserted, excessing count of rows (i mean Rows beyond > 1,048,576) are annihilated.

[AdditionalInfo]
I'm aware of Excel behaviour:
image

but, it seems to be ok in GUI app - cause user get instant feedback and can react.

another story: EPPlus on backend without direct interaction with user - it could handle this on behalf of user (kind of cool)

Right now before any insertion, a developer should check Sheet.Dimension.End, find last index of Row, count how many Rows to delete to free space. Maybe the more appropriate place for such code is inside EPPlus library?

@JanKallman
Copy link
Contributor

This is the intended behaviour. Discarding overflowing cells on rows or columns without a notification sounds dangerous to me. If you are writing a rolling log appender I can understand this behaviour, but Excel data is usually financial data. What is the use case for your scenario?

@thetilliwilli
Copy link
Author

thetilliwilli commented Jan 26, 2022

Use case:
Report system which uses excel template file (like in the screenshot below) and fills with data.

Example
image

The system inserts data at marker position {{table1}} (see (1) in the screenshot). Below the marker there is some text (see (2) in the screenshot) that is not important in case of overflowing.

@OssianEPPlus OssianEPPlus added the question Further information is requested label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants