[英]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.