About four lines will be output, and the data at the bottom will be lost. I don't know if it's Chinese. How should I solve it? #2521

Closed
opened 2022-02-13 09:47:16 +00:00 by lanchengkai · 10 comments
lanchengkai commented 2022-02-13 09:47:16 +00:00 (Migrated from github.com)

About four lines will be output, and the data at the bottom will be lost. I don't know if it's chinese. How should I solve it?

I don't think it's the code problem. Maybe the problem is in chinese. How can we solve it

its my code

data{
{啊啊:'123',是是是是:'456','的的的的':'可能会消失',发发:'123'},
...
}
var tempWS = XLSX.utils.json_to_sheet(data, { header: ['啊啊', '是是是是', '的的的的', '发发'] });
var tempWB = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(tempWB, tempWS, '信息');
XLSX.writeFile(tempWB, "bookmarks.xlsx");

About four lines will be output, and the data at the bottom will be lost. I don't know if it's chinese. How should I solve it? I don't think it's the code problem. Maybe the problem is in chinese. How can we solve it its my code > data{ > {啊啊:'123',是是是是:'456','的的的的':'可能会消失',发发:'123'}, > ... > } > var tempWS = XLSX.utils.json_to_sheet(data, { header: ['啊啊', '是是是是', '的的的的', '发发'] }); > var tempWB = XLSX.utils.book_new(); > XLSX.utils.book_append_sheet(tempWB, tempWS, '信息'); > XLSX.writeFile(tempWB, "bookmarks.xlsx");
SheetJSDev commented 2022-02-13 09:56:25 +00:00 (Migrated from github.com)

Can you share a more detailed example? Here's a simple demo that appears to export everything: https://jsfiddle.net/5rze96q2/

In case you can't pull it up, it uses https://unpkg.com/xlsx/dist/xlsx.full.min.js (the dist/xlsx.full.min.js script) with the following JS code:

var data = Array.from({length: 1000}, (_, i) => ({
  '啊啊':Math.random(),
  '是是是是':String(Math.floor(1000*Math.random())),
  '的的的的':'可能会消失' + i,
  '发发':1024-i}));

var tempWS = XLSX.utils.json_to_sheet(data, { header: ['啊啊', '是是是是', '的的的的', '发发'] });
var tempWB = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(tempWB, tempWS, '信息');
XLSX.writeFile(tempWB, "bookmarks.xlsx");

Sample run: bookmarks.xlsx

Can you share a more detailed example? Here's a simple demo that appears to export everything: https://jsfiddle.net/5rze96q2/ In case you can't pull it up, it uses https://unpkg.com/xlsx/dist/xlsx.full.min.js (the `dist/xlsx.full.min.js` script) with the following JS code: ```js var data = Array.from({length: 1000}, (_, i) => ({ '啊啊':Math.random(), '是是是是':String(Math.floor(1000*Math.random())), '的的的的':'可能会消失' + i, '发发':1024-i})); var tempWS = XLSX.utils.json_to_sheet(data, { header: ['啊啊', '是是是是', '的的的的', '发发'] }); var tempWB = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(tempWB, tempWS, '信息'); XLSX.writeFile(tempWB, "bookmarks.xlsx"); ``` Sample run: [bookmarks.xlsx](https://github.com/SheetJS/sheetjs/files/8055286/bookmarks.xlsx)
lanchengkai commented 2022-02-13 09:58:35 +00:00 (Migrated from github.com)

i use xlsx.full.min.js in my demo, but still.

image
like this

i use xlsx.full.min.js in my demo, but still. ![image](https://user-images.githubusercontent.com/62948104/153747893-6d81303e-00d1-4ca1-8162-b87ff563ed88.png) like this
SheetJSDev commented 2022-02-13 10:01:19 +00:00 (Migrated from github.com)

Do you have rows that have partial data? json_to_sheet will generate a row even if the full data is not available. In your JS code, log the data before converting and be sure the data set is good.

Do you have rows that have partial data? `json_to_sheet` will generate a row even if the full data is not available. In your JS code, log the data before converting and be sure the data set is good.
lanchengkai commented 2022-02-13 10:24:40 +00:00 (Migrated from github.com)

image
i log my data..
data is complete,but even lost two complete data after output.

var tempData = []
    data.forEach(element => {
        tempData.push(element);
        console.log(element);
    });

    var tempWS = XLSX.utils.json_to_sheet(tempData, { header: ['标题', '发布时间', '来源网站', '作者', 'URL', '关键词', '问题'] });
    var tempWB = XLSX.utils.book_new();
    XLSX.utils.book_append_sheet(tempWB, tempWS, '信息');
    XLSX.writeFile(tempWB, "bookmarks.xlsx");
![image](https://user-images.githubusercontent.com/62948104/153748827-58f2787b-df24-4fad-aae8-9949baf6ff8d.png) i log my data.. data is complete,but even lost two complete data after output. ``` var tempData = [] data.forEach(element => { tempData.push(element); console.log(element); }); var tempWS = XLSX.utils.json_to_sheet(tempData, { header: ['标题', '发布时间', '来源网站', '作者', 'URL', '关键词', '问题'] }); var tempWB = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(tempWB, tempWS, '信息'); XLSX.writeFile(tempWB, "bookmarks.xlsx"); ```
SheetJSDev commented 2022-02-13 10:28:01 +00:00 (Migrated from github.com)

It's hard to say what is happening, since the generated file actually opens in Excel. Do you see the same problem if you write to "bookmarks.xls" or "bookmarks.xlsb" or "bookmarks.csv"?

It's hard to say what is happening, since the generated file actually opens in Excel. Do you see the same problem if you write to `"bookmarks.xls"` or `"bookmarks.xlsb"` or `"bookmarks.csv"`?
lanchengkai commented 2022-02-13 10:36:40 +00:00 (Migrated from github.com)

xls is fine

xls is fine
SheetJSDev commented 2022-02-13 10:42:17 +00:00 (Migrated from github.com)

That is very weird indeed. Can you share the dataset / XLSX / XLS directly to the org email address (hello@sheetjs.com)?

If not, can you try saving the XLS file, then reading and saving as XLSX:

    XLSX.utils.book_append_sheet(tempWB, tempWS, '信息');
    // generate the XLS file in memory
    var bstr = XLSX.write(tempWB, {type:"binary", bookType: "xls"});
    // read the generated file
    var newWB = XLSX.read(bstr, {type: "binary"});
    // try exporting the new workbook
    XLSX.writeFile(newWB, "bookmarks.xlsx");
That is very weird indeed. Can you share the dataset / XLSX / XLS directly to the org email address (hello@sheetjs.com)? If not, can you try saving the XLS file, then reading and saving as XLSX: ```js XLSX.utils.book_append_sheet(tempWB, tempWS, '信息'); // generate the XLS file in memory var bstr = XLSX.write(tempWB, {type:"binary", bookType: "xls"}); // read the generated file var newWB = XLSX.read(bstr, {type: "binary"}); // try exporting the new workbook XLSX.writeFile(newWB, "bookmarks.xlsx"); ```
lanchengkai commented 2022-02-13 10:46:37 +00:00 (Migrated from github.com)

oh sorry, the data is private. But thank you very much for your help. Thank you.

oh sorry, the data is private. But thank you very much for your help. Thank you.
reviewher commented 2022-02-14 01:57:12 +00:00 (Migrated from github.com)

If you can share the specific row causing issues, or at least some way we can reproduce the issue, it can be reopened.

If you can share the specific row causing issues, or at least some way we can reproduce the issue, it can be reopened.
SheetJSDev commented 2022-02-15 07:43:12 +00:00 (Migrated from github.com)

We pushed an update (0.18.2) which should resolve the issue. Please verify, and sincere apologies for the issue in the first place.

We pushed an update (0.18.2) which should resolve the issue. Please verify, and sincere apologies for the issue in the first place.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2521
No description provided.