private static ExcelPackage MergeExcelPackages(ExcelPackage aExcelPackage,
ExcelPackage bExcelPackage)
{
var excelPackage = new ExcelPackage();
excelPackage.Workbook.Worksheets.Add("AInfo", aExcelPackage.Workbook.Worksheets[1]);
excelPackage.Workbook.Worksheets.Add("BInfo", bExcelPackage.Workbook.Worksheets[1]);
return excelPackage;
}
上面的代码在 EPPlus 3.1.3.3 中有效,但在 vesion 4.0.4 中无效。它抛出以下错误:
System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at OfficeOpenXml.ExcelStyleCollection`1.get_Item(Int32 PositionID)
at OfficeOpenXml.Style.ExcelStyle.get_XfId()
at OfficeOpenXml.ExcelStyles.CreateNamedStyle(String name, ExcelStyle Template)
at OfficeOpenXml.ExcelStyles.CloneStyle(ExcelStyles style, Int32 styleID, Boolean isNamedStyle, Boolean allwaysAdd)
at OfficeOpenXml.ExcelStyles.CloneStyle(ExcelStyles style, Int32 styleID)
at OfficeOpenXml.ExcelWorksheets.CloneCells(ExcelWorksheet Copy, ExcelWorksheet added)
at OfficeOpenXml.ExcelWorksheets.Add(String Name, ExcelWorksheet Copy)