MiniExcel icon indicating copy to clipboard operation
MiniExcel copied to clipboard

An item with the same key has already been added

Open kissxic opened this issue 4 years ago • 2 comments

Excel Type

  • [x] XLSX

MiniExcel Version

0.18.0

Description

当用户导入的.xlsx文件 表格尾部存在许多空行时,系统会出现如下错误,读取不了Excel的数据。毕竟表格一下拉都是空行,用户很多时候也分辨不出来空行。看有没好的方式优化下读取方式?

Message:An item with the same key has already been added. Key: 0

Stack: at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key) at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at MiniExcelLibs.OpenXml.ExcelOpenXmlStyles..ctor(ExcelOpenXmlZip zip) at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetReader.<Query>d__8.MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable1 source, Boolean& found) at MiniExcelLibs.OpenXml.ExcelOpenXmlSheetReader.<Query>d__111.MoveNext() at MiniExcelLibs.MiniExcel.<Query>d__161.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at xxxController.<ImportDailyJson>d__13.MoveNext() in D:\xxxController.cs:line 154 at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.<Execute>d__0.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.ValueTask1.get_Result() at System.Runtime.CompilerServices.ValueTaskAwaiter1.GetResult() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeNextActionFilterAsync>g__Awaited|10_0>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeInnerFilterAsync>g__Awaited|13_0>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<<InvokeNextExceptionFilterAsync>g__Awaited|25_0>d.MoveNext()

kissxic avatar Sep 14 '21 02:09 kissxic

@kissxic 需要提供Excel跟代码逻辑做判断 我这边测试不会有这问题 image

shps951023 avatar Sep 14 '21 03:09 shps951023

await MiniExcel.QueryAsync < T >(filePath, startCell: "A2"); ToList()的时候报的上面的错 8d4b9ea3a18e4bb8b2d322aea844d7ed.xlsx image

kissxic avatar Sep 14 '21 05:09 kissxic