Use the Range.Copy method to report an error when there is a particular text box on the worksheet
EPPlus usage
Noncommercial use
Environment
Windows
Epplus version
7.4.1
Spreadsheet application
Excel365
Description
Very weird behavior, as long as this text box exists on my worksheet (a new text box cannot be reproduced, I copied it from an error sheet)
using (var package = new ExcelPackage("testcopyRange1.xlsx"))
{
var syncSht = package.Workbook.Worksheets["syncSht"];
var snapSht = package.Workbook.Worksheets["snapSht"];
var address = "B7:B16";
try
{
snapSht.Cells[address].Copy(syncSht.Cells[address]);
}
catch (Exception ex)
{
throw;
}
}
the exception stack trace below:
System.NullReferenceException HResult=0x80004003 Message=未将对象引用设置到对象的实例。 Source=EPPlus StackTrace: at OfficeOpenXml.Core.RangeCopyHelper.CopyDrawings() at OfficeOpenXml.Core.RangeCopyHelper.Copy() at OfficeOpenXml.ExcelRangeBase.Copy(ExcelRangeBase Destination) at ConsoleApp2.Program.Main(String[] args) in \Program.cs:line 54
I tried to change the Placement property of the text box that caused the failure from the original xlMove to xlMoveAndSize without error, but very strange, I directly created a text box and changed its Placement property to xlMove without error.
Yes, this is a bug. I will provide a fix.
Fixed in EPPlus 7.5.0