Open uganh opened 2 weeks ago
Please upload a workbook or provide code that helps us to replicate this issue.
Please upload a workbook or provide code that helps us to replicate this issue.
This is a sample file, and if you unzip it, you will find that the x:Anchor
field is missing in xl/drawings/vmlDrawing1.vml
. I can operate it through Microsoft Office.
But when I modified it using the following code, an unexpected exception was thrown.
using OfficeOpenXml;
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
FileInfo fileInfo = new FileInfo(fileName);
ExcelPackage package = new ExcelPackage();
using (var stream = fileInfo.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
package.Load(stream);
}
ExcelWorkbook workbook = package.Workbook;
ExcelWorksheet worksheet = workbook.Worksheets[1];
worksheet.DeleteRow(256);
I hope you can fix this issue in future versions. best wishes.
Thanks, I will have a look at it and get back to you here.
The commentsDrawing1.vml inside this workbook misses the the element x:ClientData/x:Anchor, that EPPlus currently requires. If you resave the workbook with Excel, it works as expected. I'll see if I can add fix so it works without this element as well.
EPPlus usage
Noncommercial use
Environment
Windows
Epplus version
7.3.1
Spreadsheet application
Excel
Description
https://github.com/EPPlusSoftware/EPPlus/blob/5bb2d0dab7ce9445506e0980d3988fb0d8fb4b95/src/EPPlus/Drawing/Vml/ExcelVmlDrawingPosition.cs#L114
When calling
ExcelWorksheet.DeleteRow
on a xlsx file, an exception is thrown:Anchor element is invalid in vmlDrawing
.According to the specifications, the
x:Anchor
field is not mandatory, so exceptions should not be thrown here.