[Solved] node-xlsx Write excel Error: TypeError: n.indexOf is not a function

Use node xlsx to write the assembled data into excel and always report errors. The error information is as follows:

(node:6357) UnhandledPromiseRejectionWarning: TypeError: n.indexOf is not a function
    at /Users/mac/project/reptile/invoice/node_modules/xlsx/xlsx.js:15693:8
    at Array.forEach (<anonymous>)
    at check_ws_name (/Users/mac/project/reptile/invoice/node_modules/xlsx/xlsx.js:15692:11)
    at /Users/mac/project/reptile/invoice/node_modules/xlsx/xlsx.js:15701:3
    at Array.forEach (<anonymous>)
    at check_wb_names (/Users/mac/project/reptile/invoice/node_modules/xlsx/xlsx.js:15700:4)
    at check_wb (/Users/mac/project/reptile/invoice/node_modules/xlsx/xlsx.js:15713:2)
    at Object.writeSync [as write] (/Users/mac/project/reptile/invoice/node_modules/xlsx/xlsx.js:21998:2)
    at Object.build (/Users/mac/project/reptile/invoice/node_modules/node-xlsx/lib/index.js:77:33)
    at writeXlsx (/Users/mac/project/reptile/invoice/index.js:269:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6357) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:6357) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

There is no useful information in the prompt. You can only use node xlsx to read the normal excel table into JSON, and then compare the normal Josn with the JSON assembled by yourself however, the goose did not find any difference
after careful comparison, the problem is finally found. The reason is that the table name of each table in Excel can only be the string,

let obj = {
    name: more.tatalAmount, // The name obtained here is Number, which must be converted to String with toString()
    data: [

Read More: