javascript - jexcel从带有空单元格的ajax加载数据
问题描述
<html>
<script src="https://bossanova.uk/jexcel/v3/jexcel.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jexcel/v3/jexcel.css" type="text/css" />
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script>
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" />
<div id="spreadsheet2"></div>
<script>
jexcel(document.getElementById('spreadsheet2'), {
jexcel(document.getElementById('spreadsheet2'), {
url:'/v3/test.json',
columns: [
{ type:'text', width:300 },
{ type:'text', width:100 },
]
});
});
</script>
</html>
我的外部 JSON 响应如下;
{
"0": {
"0": "Trawex", // This should mapped on row=0, col=0
"1": "Restel", // This should mapped on row=0, col=1
// now here col 2 and 3 should be filled empty itself.
"4": "Restel" // This should mapped on row=0, col=4
},
"1": {
"0": "MP",
"3": "DZ"
},
"4": {
"8": "$ 333",
"0": "$ 23.424",
"13": "$ 222"
},
"2": {
"0": "AL",
"4": "AX"
},
"3": {
"0": "true",
"4": "true"
},
"5": {
"15": "$ 2.541"
},
"6": {
"16": "$ "
},
"7": {
"16": "#c62828"
},
"8": {
"16": "2020-05-19 00:00:00"
}
}
现在我的 JSON 响应是一个具有特定索引的关联数组(JSON 对象)(索引不按顺序排列)。jexcel 是否支持任何类型的功能?
解决方案
试试下面的代码。文档中似乎有错误。
<div id="spreadsheet2"></div>
<script>
jexcel(document.getElementById('spreadsheet2'), {
url:'/URL-TO-YOUR-JSON.json',
columns: [
{ type:'text', width:'300px' },
{ type:'text', width:'100px' },
]
});
</script>
</html>
推荐阅读
- csv - 为什么我会收到带有以下代码的 NameError?
- python - 如何在 Pandas 中使用 Group by 构造一个 df,其中第二列单元格作为列标题,第三列作为单元格数据?
- python - 当.py程序停止错误时如何重新启动它
- python - 无法将输入数组从形状 (100,2) 广播到形状 (100)
- networking - 我无法从子域为父域设置 cookie
- c - 将2个数组的排序合并到C中的第三个数组中
- javascript - 动态 jQuery 输入因错误而刷新页面
- flutter - 使用 Facebook 登录
- git - 不相关 repos 的 Git 合并是否需要特定版本的 Git?
- python - 在 Colab 中使用网络摄像头进行 TensorFlow 对象检测