日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線(xiàn)咨詢(xún)客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

項(xiàng)目需求:

開(kāi)發(fā)一套基于Vue框架的工程檔案管理系統(tǒng),用于工程項(xiàng)目資料的填寫(xiě)、編輯和歸檔,經(jīng)調(diào)研需支持如下功能:

  • Excel報(bào)表的導(dǎo)入、導(dǎo)出
  • PDF文件的導(dǎo)出
  • 打印表格經(jīng)過(guò)技術(shù)選型,項(xiàng)目組一致決定通過(guò)表格組件SpreadJS 來(lái)實(shí)現(xiàn)。

以下是實(shí)現(xiàn)Excel報(bào)表的導(dǎo)入導(dǎo)出、PDF導(dǎo)出、打印表格的一些思路,供大家參考:

環(huán)境介紹

1.后臺(tái):Spring Boot 2.x

2.前臺(tái):vue、vue-element、webpack、iview、Vuex.js 2.x

3.組件:SpreadJs V11

SpreadJS 組件下載地址:https://www.grapecity.com.cn/download/?pid=57

初始化Vue項(xiàng)目

這里,可以參考這篇技術(shù)博客: 只需3 分鐘,就能創(chuàng)建 一個(gè)SpreadJS 的 Vue 項(xiàng)目

項(xiàng)目運(yùn)行效果:

如下是本地的一個(gè)Excel文件:

技術(shù)干貨:Vue框架下實(shí)現(xiàn)導(dǎo)入導(dǎo)出Excel及PDF

 

通過(guò)SpreadJS,導(dǎo)入到項(xiàng)目中的效果:

技術(shù)干貨:Vue框架下實(shí)現(xiàn)導(dǎo)入導(dǎo)出Excel及PDF

 

我的項(xiàng)目中應(yīng)用了SpreadJS V12.2.5的版本(目前官網(wǎng)SpreadJS的最新版本是V13),其中package.json 需要添加的引用如下:

1. "dependencies": {

2. "@grapecity/spread-excelio": "12.2.5",

3. "@grapecity/spread-sheets": "12.2.5",

4. "@grapecity/spread-sheets-pdf": "^12.2.5",

5. "@grapecity/spread-sheets-print": "12.2.5",

6. "@grapecity/spread-sheets-resources-zh": "12.2.5",

7. "@grapecity/spread-sheets-vue": "12.2.5",

8. "@grapecity/spread-sheets-charts": "12.2.5" ,

9. "file-saver": "2.0.2",

10. "jquery": "2.2.1",

11. "vue": "^2.5.2",

12. "vue-router": "^3.0.1"

13. },

執(zhí)行npm install 命令安裝SpreadJS 組件

可以參考這篇技術(shù)博客:

https://www.grapecity.com.cn/blogs/spread-sheets-v11sp1-support-npm

導(dǎo)入導(dǎo)出Excel報(bào)表

1. 安裝相關(guān)的資源包: "@grapecity/spread-excelio"、 "file-saver"

2. 在頁(yè)面中引入: import ExcelIO from '@grapecity/spread-excelio'、import FaverSaver from 'file-saver'

3. 如下代碼可實(shí)現(xiàn)導(dǎo)入導(dǎo)出Excel:

1. exportXlsx () {

2. let ex = new ExcelIO.IO()

3. let json = this.spread.toJSON()

4. ex.save(json, function (blob) {

5. FaverSaver.saveAs(blob, 'export.xlsx')

6. }, function (e) {

7. console.log(e)

8. })

9. },

10. importXlsx(){

11. let self = this;

12. var excelIO = new ExcelIO.IO();

13. console.log(excelIO);

14. const excelFile = document.getElementById("fileDemo").files[0];

15. excelIO.open(excelFile, function (json) {

16. let workbookObj = json;

17. self.spread.fromJSON(workbookObj);

18. }, function (e) {

19. alert(e.errorMessage);

20. });

21. }

導(dǎo)出PDF的注意事項(xiàng)

1. 安裝相同版本的 PDF包: "@grapecity/spread-sheets-pdf"

2. 在需要打印的頁(yè)面引入該包: import "@grapecity/spread-sheets-pdf";

3. 引入該包需要注意引入順序,先引入 @grapecity/spread-sheets和 grapecity/spread-sheets-print

4. 需引入第三方插件file-saver : import FaverSaver from 'file-saver'

5. 如下幾行代碼可實(shí)現(xiàn)導(dǎo)出PDF功能

1. savePdf(){

2. let self = this;

3. let jsonString = JSON.stringify(self.spread.toJSON());

4. let printSpread = new GC.Spread.Sheets.Workbook();

5. printSpread.fromJSON(JSON.parse(jsonString));

6.

7. printSpread.savePDF(function(blob) {

8. // window.open(URL.createObjectURL(blob))

9. FaverSaver.saveAs(blob, 'Hello.pdf')

10. }, function(error) {

11. console.log(error);

12. }, {

13. title: 'Print',

14. });

15. }

示例代碼下載

大家可下載下方的示例代碼,實(shí)現(xiàn)導(dǎo)出PDF、導(dǎo)入導(dǎo)出Excel功能。

SpreadJSVue.zip


SpreadJS 純前端表格控件

SpreadJS 是一款基于 html5 的純前端電子表格控件,兼容 450 種以上的 Excel 公式,憑借其 “高性能、跨平臺(tái)、與 Excel 高度兼容”的產(chǎn)品特性,備受以華為、招商銀行、蘇寧易購(gòu)、天弘基金等為代表的企業(yè)用戶(hù)青睞。在帶來(lái)親切的 Excel 使用體驗(yàn)的同時(shí),滿(mǎn)足 Web Excel 組件開(kāi)發(fā)、數(shù)據(jù)填報(bào)、Excel 類(lèi)報(bào)表設(shè)計(jì)、在線(xiàn)Excel 協(xié)同應(yīng)用等業(yè)務(wù)場(chǎng)景,極大降低了企業(yè)研發(fā)成本和項(xiàng)目交付風(fēng)險(xiǎn)。

分享到:
標(biāo)簽:Excel
用戶(hù)無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定