How to skip rows? #947

Closed
opened 2018-01-08 12:42:00 +00:00 by fpasxos · 2 comments
fpasxos commented 2018-01-08 12:42:00 +00:00 (Migrated from github.com)

Hello everyone,
I hope that this is the right topic to open a thread.
I am currently new on using the library, so I have a quick question.

Is there a way to write the first three rows with some info, and afterwards add the excel data? I am attaching a screenshot of some sort of desired outcome.

image

In the picture above, aaaaa-bbbbb-ccccc are some random data, and x,y,z are the column names and the numbers below them are the data.
Is there any way to achieve that?

Thanks a lot for your time.

Hello everyone, I hope that this is the right topic to open a thread. I am currently new on using the library, so I have a quick question. Is there a way to write the first three rows with some info, and afterwards add the excel data? I am attaching a screenshot of some sort of desired outcome. ![image](https://user-images.githubusercontent.com/21210590/34671127-ee93a71c-f481-11e7-9fdc-d5f526b74b60.png) In the picture above, aaaaa-bbbbb-ccccc are some random data, and x,y,z are the column names and the numbers below them are the data. Is there any way to achieve that? Thanks a lot for your time.
SheetJSDev commented 2018-01-09 08:00:24 +00:00 (Migrated from github.com)

We added a few helper functions for adding to an existing worksheet. Here's one way to reproduce your screenshot:

/* generate a new workbook with the first three rows */
var ws = XLSX.utils.aoa_to_sheet([
	["aaaaaa"],
	["bbbbb"],
	["cccccc"]
]);

/* this array controls the column order in the generated sheet */
var header = ["x", "y", "z"];

/* add row objects to sheet starting from cell A6 */
XLSX.utils.sheet_add_json(ws, [
	{x:1, y:2, z:3},
	{x:435, y:345, z:54}
], {header:header, origin:"A6"});

/* append two more rows without header */
XLSX.utils.sheet_add_json(ws, [
	{x:345, y:345, z:345},
	{x:345, y:3, z:345}
], {header:header, origin:-1, skipHeader:true});

https://jsfiddle.net/re2x441s/ is a live example that generates an XLSX workbook

We added a few helper functions for adding to an existing worksheet. Here's one way to reproduce your screenshot: ```js /* generate a new workbook with the first three rows */ var ws = XLSX.utils.aoa_to_sheet([ ["aaaaaa"], ["bbbbb"], ["cccccc"] ]); /* this array controls the column order in the generated sheet */ var header = ["x", "y", "z"]; /* add row objects to sheet starting from cell A6 */ XLSX.utils.sheet_add_json(ws, [ {x:1, y:2, z:3}, {x:435, y:345, z:54} ], {header:header, origin:"A6"}); /* append two more rows without header */ XLSX.utils.sheet_add_json(ws, [ {x:345, y:345, z:345}, {x:345, y:3, z:345} ], {header:header, origin:-1, skipHeader:true}); ``` https://jsfiddle.net/re2x441s/ is a live example that generates an XLSX workbook
yvzkr commented 2020-02-23 17:41:47 +00:00 (Migrated from github.com)

adamsın uleyyn. Good job. You are best coder. @SheetJSDev

adamsın uleyyn. Good job. You are best coder. @SheetJSDev
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#947
No description provided.