table2excel
table2excel copied to clipboard
添加caption为表格标题
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/js-table2excel/index.js b/node_modules/js-table2excel/index.js
index 56cda1f..3f1cf98 100644
--- a/node_modules/js-table2excel/index.js
+++ b/node_modules/js-table2excel/index.js
@@ -123,11 +123,12 @@ const tableToNotIE = (function () {
})()
// 导出函数
-const table2excel = (column, data, excelName) => {
+const table2excel = (column, data, excelName, captionName) => {
const typeMap = {
image: getImageHtml,
text: getTextHtml
}
+ let caption = captionName ? `<caption style="font-weight:bold">${captionName}</caption>` : '';
let thead = column.reduce((result, item) => {
result += `<th>${item.title}</th>`
@@ -147,7 +148,7 @@ const table2excel = (column, data, excelName) => {
tbody = `<tbody>${tbody}</tbody>`
- const table = thead + tbody
+ const table = caption + thead + tbody
// 导出表格
exportToExcel(table, excelName)
This issue body was partially generated by patch-package.