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



SheetJS & Error: Sheet names cannot exceed 31 chars的更多相关文章

  1. <command-line>:0: error: macro names must be identifiers

    编译时的出错信息:<command-line>:0: error: macro names must be identifiers 原因: You have a -D flag with ...

  2. SharePoint 2013 Error - File names can't contain the following characters: & " ? < > # {} % ~ / \.

    错误截图: 错误信息: --------------------------- Message from webpage --------------------------- File names ...

  3. Error: member names cannot be the same as their enclosing type

    在编译的时候会遇到如下问题:member names cannot be the same as their enclosing type 原因:方法名和类名不能一样,如果一样就是一个构造函数.而构造 ...

  4. VS2008 error PRJ0002 : 错误的结果 31 (从“C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\rc.exe”返回)。

    解决方案,选择属性->配置属性->清单工具->输入和输出->嵌入清单,把是改成否

  5. linux系统中errno与error对照表

    1.使用了一个小程序输出所有的errno对应的error字符串,代码如下 #include <errno.h> void showError(int err){ printf(" ...

  6. BIP Requests Are Failing With Error &quot;OPP Error Oracle.apps.xdo.XDOException: Error Creating Lock Fil

    In this Document   Symptoms   Cause   _afrLoop=975833031487795&id=1512691.1&displayIndex=1&a ...

  7. BIP Requests Are Failing With Error "OPP Error Oracle.apps.xdo.XDOException: Error Creating Lock Fil

    In this Document   Symptoms   Cause   Solution   References Applies to: BI Publisher (formerly XML P ...

  8. Manjaro下带供电的USB Hub提示error -71

    问题描述 这款USB Hub是绿联出的1转7带供电的白色款. 在lsusb中显示为 Bus 004 Device 023: ID 05e3:0616 Genesys Logic, Inc. hub B ...

  9. tp3.2 phpexcel 简单导出多个sheet(execl表格)

    参考链接:https://blog.csdn.net/u011341352/article/details/70211962 以下是公共类PHPExcel.php文件: // 开始 <?php/ ...

随机推荐

  1. 初尝微信小程序2-基本框架

    基本框架: .wxml :页面骨架 .wxss :页面样式 .js :页面逻辑    描述一些行为 .json :页面配置 创建一个小程序之后,app.js,app.json,app.wxss是必须的 ...

  2. chisel(安装)

    github地址 先安装homeBrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/m ...

  3. 如何将一个div水平垂直居中

    方案一: div绝对定位水平垂直居中[margin:auto实现绝对定位元素的居中], 兼容性:,IE7及之前版本不支持 div{ width: 200px; height: 200px; backg ...

  4. Mybatis与Hibernate区别

    Mybatis与Hibernate区别 mybatis: 1. 入门简单,即学即用,提供了数据库查询的自动对象绑定功能,而且延续了很好的SQL使用经验,对于没有那么高的对象模型要求的项目来说,相当完美 ...

  5. centos 7 ifconfig 命令找不到

    最近在配置linux 环境: 在官网看到centOS除了最新版本7,那就尝试一下吧.最小安装centOS 7之后发现没有ifconfig命令,在网上找了一下都说是路径的路问题. 我用echo $PAT ...

  6. 本地通过VMware Workstation创建虚拟机,配置网络环境

    通过VMware Workstation创建虚拟机,系统安装完成后,需要配置相应网卡设置: 打开配置文件:vim /etc/sysconfig/network-scripts/ifcfg-ens33 ...

  7. C++基础 new和delete

    1.new delete 的使用 (1)基本数据类型 ); delete p; int *p = (int *)malloc(sizeof(int)); *p = ;free(p); (2)数组 ]; ...

  8. [BZOJ2243][SDOI2011]染色(树链剖分)

    [传送门] 树链剖分就行了,注意线段树上颜色的合并 Code #include <cstdio> #include <algorithm> #define N 100010 # ...

  9. Hibernate---架构

    Hibernate 架构是分层的,作为数据访问层,你不必知道底层 API .Hibernate 利用数据库以及配置数据来为应用程序提供持续性服务(以及持续性对象). 下面是一个非常高水平的 Hiber ...

  10. JavaScript - 问题集 - 含function的json对象与json字符串之间相互转换

    基本的转换为:JSON.parse与JSON.stringify. 但是json数据中含function,则转换后,function会丢失,如: var json={ test:'test', log ...