SheetJS & Error: Sheet names cannot exceed 31 chars
2024-09-04 11:28:33
SheetJS
Error: Sheet names cannot exceed 31 chars
title + version
https://github.com/SheetJS/js-xlsx/issues/870
https://github.com/SheetJS/js-xlsx/commit/aff7b952720a466bb739ffbbe1cb5d1f9635dcb5
solution
https://support.office.com/en-us/article/Rename-a-worksheet-3F1F7148-EE83-404D-8EF0-9FF99FBAD1F9
export-excel.js
"use strict";
/**
* @description export table to excel with HTML5 Bolb!
* @author xgqfrms 2018.02.05
* @param {String} type
* @param {String} uid
* @param {String} title
* @param {Boolean} debug
*/
const exportExcel = (
uid = `data-table`,
title = `excel-title`,
type = `xlsx`,
debug = false
) => {
if (debug) {
console.log(`uid= `, uid);
console.log(`type = `, type);
console.log(`title = `, title);
}
// fixed bug: error = Error: Sheet names cannot exceed 31 chars
const short_mock_title = `xgqfrms`;
let result = ``;
try {
let elt = document.querySelector(uid),
wb = XLSX.utils.table_to_book(
elt,
{
// sheet: "Sheet JS",// excel sheet name
// sheet: title,
// fixed bug: error = Error: Sheet names cannot exceed 31 chars
sheet: short_mock_title,
}
);
if (debug) {
console.log(`document.querySelector(uid) = `, elt);
}
result = XLSX.writeFile(
wb,
`${title}.${type}`,
// `${short_mock_title}.${type}`,
);
// console.log(`result =`, result);
// bolb
// bolb to url
// true title name
return result;
} catch (error) {
console.log(`export error = `, error);
}
};
export {exportExcel};
export default exportExcel;
old version
"use strict";
/**
* @description export table to excel with HTML5 Bolb!
* @author xgqfrms 2018.02.05
* @param {String} type
* @param {String} uid
* @param {String} title
* @param {Boolean} debug
*/
const exportExcel = (
uid = `data-table`,
title = `excel-title`,
type = `xlsx`,
debug = false
) => {
if (debug) {
console.log(`uid= `, uid);
console.log(`type = `, type);
console.log(`title = `, title);
}
// fixed bug: error = Error: Sheet names cannot exceed 31 chars
const short_mock_title = `xgqfrms`;
let result = ``;
try {
let elt = document.querySelector(uid),
wb = XLSX.utils.table_to_book(
elt,
{
// sheet: "Sheet JS",// excel sheet name
// sheet: title,
// fixed bug: error = Error: Sheet names cannot exceed 31 chars
sheet: short_mock_title,
}
);
if (debug) {
console.log(`document.querySelector(uid) = `, elt);
}
result = XLSX.writeFile(
wb,
`${title}.${type}`,
// true title name
);
return result;
} catch (error) {
console.log(`error = `, error);
}
};
export {exportExcel};
export default exportExcel;
download pdf & rename
seeing comments
download image & rename
seeing comments
最新文章
- What is the difference between the ways to implement inheritance in javascript.
- winform 自定义控件引用问题
- CentOS-6.5安装配置Tengine
- LINUX yum用法
- EF扩展库(批量操作)
- mybatis分页插件PageHelper的使用(转)
- T-SQL备忘(2):聚合函数运算和NULL
- 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则输出Yes,否则输出No。假设输入的数组的任意两个数字都互不相同。
- jsonp是什么以及jsonp的使用
- EasyUi 中datagrid 实现查询方法
- git 提交到github时不用每次都输入用户名,密码
- 有状态InheritableThreadLocal 配合 JDK8 ,异步方法调用
- [HCNA]VLAN配置Access接口
- Java并发编程的4个同步辅助类
- rebar3自动编译
- DTLS协议中client/server的认证过程和密钥协商过程
- JUnit pass/failure/error区别
- 分形之谢尔宾斯基(Sierpinski)四面体
- Maven <;Profiles>;定义不同环境的参数变量
- zsh: command not found: pip 解决方法