【发布时间】:2018-07-09 06:41:39
【问题描述】:
我想通过替换单元格中的一些值来导出表格。我正在共享jsfiddle 链接以在handsonTable 中导出
<div id="example1" class="hot handsontable htRowHeaders htColumnHeaders"></div>
document.addEventListener("DOMContentLoaded", function() {
var temp = {"A1":"first","A2":"second","B1":"third","B2":"fourth"};
var example1 = document.getElementById('example1');
var hot = new Handsontable(example1, {
data: Handsontable.helper.createSpreadsheetData(2, 2),
colHeaders: true,
rowHeaders: true
});
var buttons = {
file: document.getElementById('export-file')
};
var exportPlugin = hot.getPlugin('exportFile');
buttons.file.addEventListener('click', function() {
exportPlugin.downloadFile('csv', {filename: 'MyFile'});
});
});
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="https://docs.handsontable.com/pro/1.6.0/bower_components/handsontable-pro/dist/handsontable.full.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://docs.handsontable.com/pro/1.6.0/bower_components/handsontable-pro/dist/handsontable.full.min.css">
在结果表中,单元格的值将是 A1、A2、B1、B2。我想用 temp 对象中的相应值替换这些值
提前致谢
【问题讨论】: