在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ 請問js怎么生成word文件呀

請問js怎么生成word文件呀

我從一個excel中讀取了數(shù)據(jù)現(xiàn)在需要將數(shù)據(jù)導出成為word,我查到了activeX這個,但是只能ie用,有什么好辦法嗎

回答
編輯回答
傲嬌范

可以看下這個,html-docx-js

2018年7月16日 00:27
編輯回答
喵小咪

大概是這樣,我用過這種方法生成過pdf和csv, 可能需要微調一下。

let blob: Blob = new Blob([data], {
            type: "application/msword"
        });
        let url: string = URL.createObjectURL(blob);
        let link: HTMLElement = document.createElement('a');
        link.setAttribute("href", url);
        link.setAttribute("download", `word.docx`);
        link.style.visibility = 'hidden';
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
2017年10月24日 06:23