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



最新文章

  1. What is the difference between the ways to implement inheritance in javascript.
  2. winform 自定义控件引用问题
  3. CentOS-6.5安装配置Tengine
  4. LINUX yum用法
  5. EF扩展库(批量操作)
  6. mybatis分页插件PageHelper的使用(转)
  7. T-SQL备忘(2):聚合函数运算和NULL
  8. 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。如果是则输出Yes,否则输出No。假设输入的数组的任意两个数字都互不相同。
  9. jsonp是什么以及jsonp的使用
  10. EasyUi 中datagrid 实现查询方法
  11. git 提交到github时不用每次都输入用户名,密码
  12. 有状态InheritableThreadLocal 配合 JDK8 ,异步方法调用
  13. [HCNA]VLAN配置Access接口
  14. Java并发编程的4个同步辅助类
  15. rebar3自动编译
  16. DTLS协议中client/server的认证过程和密钥协商过程
  17. JUnit pass/failure/error区别
  18. 分形之谢尔宾斯基(Sierpinski)四面体
  19. Maven <Profiles>定义不同环境的参数变量
  20. zsh: command not found: pip 解决方法

热门文章

  1. Python的socket编程
  2. AMD、CMD、CommonJs和ES6对比
  3. JT796、JT808、JT809、JT1076、JT1077、JT1078部标平台过检道路运输车辆卫星定位系统企业视频监控平台检测登记表
  4. OCCI的迭代修改
  5. poj_1284_Primitive root
  6. spring框架中@PostConstruct的实现原理
  7. vue学习笔记-:class
  8. yii自定义行为组件(简介版)
  9. jquery 配合 ajax 完成 在线编辑 你值得拥有
  10. 笔记-selenium+chrome headless