表格填充数据时偶发性报错 Cannot read property 'range' of undefined,和列表最后一列偶发性不显示数据?有没有大神指定下

Viewed 150

大神看下这几个问题怎么处理🙏 视频:异常演示视频

从视频中就可以看到这几个偶发的异常,特别是跨页面时候有时报错了重试都不行页面就卡死了 1、 图片
2、
图片
3、
图片
4、最后一列没有显示数据,有时是中间某几个没有显示数据
图片
代码:
图片
数据:
[["序号","选择","清单编码","清单名称","规格/项目特征","品牌/厂家","单位","验收数量","结算单价(元)","含税总金额(元)","采购税率(%)","采购总税金(元)","采购不含税总价(元)","验收日期/退货日期","引用单据号"],["1","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["2","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["3","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["4","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["5","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["6","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["7","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["8","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["9","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["10","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["11","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["12","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["13","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["14","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["15","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["16","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["17","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["18","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["19","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["20","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["21","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["22","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["23","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["24","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["25","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["26","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["27","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["28","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["29","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["30","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["31","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["32","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["","","","","","","","1.28","","2.56","","","2.24","",""]]

3 Answers

你好,报错是指调用了空对象的Range,问题应该出在:appendTableRows函数里 await row.Cells.Item(j+1).Range,当ddate[i]某一项的数组长素大于创建表格时设定的列数 ddata[0].length时会产生越界,请检查你的数据源

[["序号","选择","清单编码","清单名称","规格/项目特征","品牌/厂家","单位","验收数量","结算单价(元)","含税总金额(元)","采购税率(%)","采购总税金(元)","采购不含税总价(元)","验收日期/退货日期","引用单据号"],["1","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["2","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["3","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["4","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["5","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["6","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["7","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["8","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["9","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["10","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["11","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["12","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["13","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["14","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["15","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["16","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["17","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["18","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["19","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["20","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["21","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["22","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["23","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["24","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["25","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["26","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["27","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["28","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["29","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["30","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["31","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["32","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["","","","","","","","1.28","","2.56","","","2.24","",""]]

数据源是正常的

大神看下这几个问题怎么处理🙏🏻

视频:异常演示视频

从视频中就可以看到这几个偶发的异常,特别是跨页面时候有时报错了重试都不行页面就卡死了 1、image.png 2、image.png
3、image.png
4、最后一列没有显示数据
image.png
代码:
image.png

数据: [["序号","选择","清单编码","清单名称","规格/项目特征","品牌/厂家","单位","验收数量","结算单价(元)","含税总金额(元)","采购税率(%)","采购总税金(元)","采购不含税总价(元)","验收日期/退货日期","引用单据号"],["1","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["2","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["3","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["4","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["5","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["6","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["7","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["8","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["9","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["10","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["11","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["12","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["13","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["14","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["15","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["16","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["17","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["18","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["19","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["20","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["21","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["22","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["23","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["24","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["25","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["26","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["27","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["28","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["29","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["30","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["31","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["32","","00000100010001","扣件","扣件规格","","把","0.040","2.00","0.08","9.00","0.01","0.07","2023-04-11 12:09","SHD-2023-000131"],["","","","","","","","1.28","","2.56","","","2.24","",""]]

你好,关于插入表格以及向表格批量填充大量数据,我们不建议使用循环的方式一个一个的填充,因为这样子操作很容易出错,原因如下:

  1. 如果单元格的文本内容较多(出现换行),可能会出现跨页单元格,我们内部会将这种单元格拆分为两个,所以您在批量填充时可能会出现填充失败或者表格末尾多出部分空白行情况,这是因为表格的总行数已经动态增加了。
  2. 向表格内循环填充大量数据是非常耗时的,会受到网络、设备等不可抗力的影响,这一过程中可能会出现一些未知的错误。

综上,我们推荐使用PasteHtml()来完成表格的相关操作,示例代码如下:

image.png