no message
Former-commit-id: 4fb4102e6baa9adca376f3558e320e268972a9ae Former-commit-id: 4df54bfc47b07b9310bcd5889684a307e0508683 Former-commit-id: 1bfbc1b3dab2d61f43ad777ff0c2aeddd9b2f666
This commit is contained in:
@@ -2,20 +2,20 @@
|
|||||||
<Container>
|
<Container>
|
||||||
<PageHeader
|
<PageHeader
|
||||||
slot="header"
|
slot="header"
|
||||||
title="导入 CSV"
|
title="导入 csv"
|
||||||
url="https://github.com/mholt/PapaParse">
|
url="https://github.com/mholt/PapaParse">
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<div class="dd-mb">
|
<div class="dd-mb">
|
||||||
<el-button @click="download">
|
<el-button @click="download">
|
||||||
<Icon name="download"></Icon>
|
<Icon name="download"></Icon>
|
||||||
下载演示CSV
|
下载演示 .csv 表格
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="dd-mb">
|
<div class="dd-mb">
|
||||||
<el-upload :before-upload="handleUpload" action="default">
|
<el-upload :before-upload="handleUpload" action="default">
|
||||||
<el-button type="success">
|
<el-button type="success">
|
||||||
<Icon name="file-o"></Icon>
|
<Icon name="file-o"></Icon>
|
||||||
选择要导入的 CSV 文件
|
选择要导入的 .csv 表格
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -5,17 +5,17 @@
|
|||||||
title="导入 xlsx"
|
title="导入 xlsx"
|
||||||
url="https://github.com/SheetJS/js-xlsx">
|
url="https://github.com/SheetJS/js-xlsx">
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<!-- <div class="dd-mb">
|
<div class="dd-mb">
|
||||||
<el-button @click="download">
|
<el-button @click="download">
|
||||||
<Icon name="download"></Icon>
|
<Icon name="download"></Icon>
|
||||||
下载演示CSV
|
下载演示 .xlsx 表格
|
||||||
</el-button>
|
</el-button>
|
||||||
</div> -->
|
</div>
|
||||||
<div class="dd-mb">
|
<div class="dd-mb">
|
||||||
<el-upload :before-upload="handleUpload" action="default">
|
<el-upload :before-upload="handleUpload" action="default">
|
||||||
<el-button type="success">
|
<el-button type="success">
|
||||||
<Icon name="file-o"></Icon>
|
<Icon name="file-o"></Icon>
|
||||||
选择要导入的 xlsx 文件
|
选择要导入的 .xlsx 表格
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</div>
|
</div>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
:label="item.label">
|
:label="item.label">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<Markdown url="/static/markdownFiles/article/插件 - 导入 - csv.md"></Markdown>
|
<!-- <Markdown url="/static/markdownFiles/article/插件 - 导入 - csv.md"></Markdown> -->
|
||||||
</Container>
|
</Container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -74,10 +74,10 @@ export default {
|
|||||||
const headers = []
|
const headers = []
|
||||||
const range = XLSX.utils.decode_range(sheet['!ref'])
|
const range = XLSX.utils.decode_range(sheet['!ref'])
|
||||||
let C
|
let C
|
||||||
const R = range.s.r /* start in the first row */
|
const R = range.s.r
|
||||||
for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */
|
for (C = range.s.c; C <= range.e.c; ++C) {
|
||||||
var cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })] /* find the cell in the first row */
|
var cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]
|
||||||
var hdr = 'UNKNOWN ' + C // <-- replace with your desired default
|
var hdr = 'UNKNOWN ' + C
|
||||||
if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
|
if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
|
||||||
headers.push(hdr)
|
headers.push(hdr)
|
||||||
}
|
}
|
||||||
@@ -94,6 +94,9 @@ export default {
|
|||||||
this.generateDate({ header, results })
|
this.generateDate({ header, results })
|
||||||
}
|
}
|
||||||
reader.readAsArrayBuffer(file)
|
reader.readAsArrayBuffer(file)
|
||||||
|
},
|
||||||
|
download () {
|
||||||
|
window.location.href = 'http://fairyever.qiniudn.com/d2-admin-import-xlsx-demo.xlsx'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user