扫码关注官方订阅号
JavaScript 如何实现导出excel文件
人生最曼妙的风景,竟是内心的淡定与从容!
js-xlsx
Parser and writer for various spreadsheet formats. Pure-JS cleanroom implementation from official specifications and related documents.
Supported read formats:
Supported write formats:
Demo: http://oss.sheetjs.com/js-xlsx
Source: http://git.io/xlsx
js-xlsx 比较难用,代码比较混乱,而且导出带样式的也比较麻烦,最近写了一个,导出还算方便,项目地址:https://github.com/d-band/bet...
附一个简单的 Demo:
const fs = require('fs'); const xlsx = require('better-xlsx'); const file = new xlsx.File(); const sheet = file.addSheet('Sheet1'); const row = sheet.addRow(); const cell = row.addCell(); cell.value = 'I am a cell!'; cell.hMerge = 2; cell.vMerge = 1; const style = new xlsx.Style(); style.fill.patternType = 'solid'; style.fill.fgColor = '00FF0000'; style.fill.bgColor = 'FF000000'; style.align.h = 'center'; style.align.v = 'center'; cell.style = style; file .saveAs() .pipe(fs.createWriteStream(__dirname + '/simple.xlsx')) .on('finish', () => console.log('Done.'));
可以使用phpExcelhttps://phpexcel.codeplex.com/
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
js-xlsx
xlsx
Parser and writer for various spreadsheet formats. Pure-JS cleanroom
implementation from official specifications and related documents.
Supported read formats:
Supported write formats:
Demo: http://oss.sheetjs.com/js-xlsx
Source: http://git.io/xlsx
js-xlsx比较难用,代码比较混乱,而且导出带样式的也比较麻烦,最近写了一个,导出还算方便,项目地址:https://github.com/d-band/bet...附一个简单的 Demo:
可以使用phpExcel
https://phpexcel.codeplex.com/