WebContent/layui_exts/excel.js
(开头部分) 1.14MB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*
* @Author: Jeffrey Wang
* @Desc: 整理强大的 SheetJS 功能,依赖 XLSX.js 和 FileSaver
* @Version: v1.4
* @Date: 2018-03-24 09:54:17
* @Last Modified by: Jeffrey Wang
* @Last Modified time: 2019-01-15 11:49:09
*/
layui.define(['jquery'], function(exports){
var $ = layui.jquery;
exports('excel', {
/**
* 兼容老版本的导出函数
* @param {[type]} data [description]
* @param {[type]} filename [description]
* @param {[type]} type [description]
* @return {[type]} [description]
*/
downloadExl: function(data, filename, type) {
type = type ? type : 'xlsx';
this.exportExcel({sheet1: data}, filename+'.'+type, type, null);
},
/**
* 导出Excel并弹出下载框,具体使用方法和范围请参考文档
* @param data object
* @param {[type]} filename [description]
* @param {[type]} type [description]
* @param {[type]} opt [description]
* @return {[type]} [description]
*/
exportExcel : function(data, filename, type, opt) {
type = type ? type : 'xlsx';
filename = filename ? filename : '导出数据.'+type;
// 创建一个 XLSX 对象
var wb = XLSX.utils.book_new();
// 1. 定义excel对的基本属性
var Props = {
Title: filename,
Subject: 'Export From web browser',
Author: "excel.wj2015.com",
Manager: '',
Company: '',
Category: '',
Keywords: '',
Comments: '',
LastAuthor: '',
CreatedData: new Date(),
};
opt && opt.Props && (Props = $.extend(Props, opt.Props));
// 默认进行压缩
wb.compression = opt ? opt.compression : true
if(wb.compression !== false) {
wb.compression = true
}
wb.Props = Props;
// 特殊属性实现,比如合并单元格
var wbExtend = {
'!merges': null
,'!margins': null
后面还有 7545+ 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读 AI
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
