[英]Unexpected identifier error for shieldui export to excel
我需要将所有数据导出到Excel工作表。 我在网格中有以下列
<table id="exportTable" class="table table-responsive table-condensed table-bordered table-hover table-striped">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>User ID</th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Vino</td>
<td>vino123</td>
<td>vino@gmail.com</td>
</tr>
</tbody>
</table>
我使用下面的代码导出到Excel工作表。
<link rel="stylesheet" type="text/css" href="http://www.shieldui.com/shared/components/latest/css/light/all.min.css" />
<script type="text/javascript" src="http://www.shieldui.com/shared/components/latest/js/shieldui-all.min.js"></script>
<script type="text/javascript" src="http://www.shieldui.com/shared/components/latest/js/jszip.min.js"></script>
<script type="text/javascript">
jQuery(function ($) {
$("#exportButton").click(function () {
// parse the HTML table element having an id=exportTable
var dataSource = shield.DataSource.create({
data: "#exportTable",
schema: {
type: "table",
fields: {
Name: { type: String },
User ID: { type: String },
Email: { type: String }
}
}
});
// when parsing is done, export the data to Excel
dataSource.read().then(function (data) {
new shield.exp.OOXMLWorkbook({
author: "PrepBootstrap",
worksheets: [
{
name: "PrepBootstrap Table",
rows: [
{
cells: [
{
style: {
bold: true
},
type: String,
value: "Name"
},
{
style: {
bold: true
},
type: String,
value: "User ID"
},
{
style: {
bold: true
},
type: String,
value: "Email"
}
]
}
].concat($.map(data, function(item) {
return {
cells: [
{ type: String, value: item.Name },
{ type: String, value: item.User ID },
{ type: String, value: item.Email }
]
};
}))
}
]
}).saveAs({
fileName: "Processhistoryexcel"
});
});
});
});
当列名没有空格时,它的工作。 例如,我有一列用户ID ,当我提供用户ID时会给出错误,但是当它没有像UserID这样的空格时它会工作。
它给我在字段和单元格中提到位置的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.