最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

将希伯来语(.xlsx)中的Excel工作表解析为JSON会产生问号

运维笔记admin8浏览0评论

将希伯来语(.xlsx)中的Excel工作表解析为JSON会产生问号

将希伯来语(.xlsx)中的Excel工作表解析为JSON会产生问号

我正在尝试将Excel(* .xlsx)解析为Node JS中的JSON对象,但是所有带有希伯来字符的列都带有问号。

例如:

这里是代码:

"use strict";
const excelToJson = require("convert-excel-to-json");

// -> Read Excel File to Json Data

const excelData = excelToJson({
  sourceFile: "customers.xlsx",
  sheets: [
    {
      // Excel Sheet Name
      name: "Customers",

      header: {
        rows: 1
      }
    }
  ]
});

任何想法如何解决?

回答如下:

我相信只有您的控制台显示无效字符。尝试将excel文件内容转储到文件中,如下所示:

"use strict";
const excelToJson = require("convert-excel-to-json");

// -> Read Excel File to Json Data

const excelData = excelToJson({
sourceFile: "customers.xlsx",
sheets: [
    {
    // Excel Sheet Name
    name: "Customers",

    header: {
        rows: 1
    }
    }
]
});

const fs = require("fs");
fs.writeFileSync("customers.json", JSON.stringify(excelData));

然后打开记事本++。您应该正确看到希伯来语字符。我正在得到这种行为。我在命令窗口中看到无效字符,但是当我打开customers.json文件时,一切都很好。

例如

{"Customers":[{"A":"לקוח 1"},{"A":"לקוח 2"}]}
发布评论

评论列表(0)

  1. 暂无评论