Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addRow by array don't work? #530

Open
t1hk opened this issue Apr 2, 2018 · 3 comments
Open

addRow by array don't work? #530

t1hk opened this issue Apr 2, 2018 · 3 comments

Comments

@t1hk
Copy link

t1hk commented Apr 2, 2018

exceljs 1.1.0
AddRow and addRows by array don’t work.
I’ve copied your examples, but only addRow by key-value works. The xlsx-result file shows only row "6; Barbara;.." . Previous rows added by arrays are empty. Here is the simple code:

`var Excel = require('exceljs');
var workbook = new Excel.Workbook();
var worksheet = workbook.addWorksheet('ExampleWS');

worksheet.columns = [
{ header: 'Id', key: 'id', width: 10 },
{ header: 'Name', key: 'name', width: 32 },
{ header: 'D.O.B.', key: 'dob', width: 10 }
];

// Add a row by sparse Array (assign to columns A, E & I)
var rowValues = [];
rowValues[1] = 4;
rowValues[5] = 'Kyle';
rowValues[9] = new Date();
worksheet.addRow(rowValues);

var rows = [
[5,'Bob',new Date()], // row by array
{id:6, name: 'Barbara', dob: new Date()}
];
worksheet.addRows(rows);

//write in File
var strFilename = "testExceljs01.xlsx";
workbook.xlsx.writeFile(strFilename)
.then(function() {
console.log("file OK");
});
`

And here is the xlsx-result file:
Uploading testExceljs01.xlsx…
image

@dilignt
Copy link

dilignt commented Apr 5, 2018

I can't get addRow or addRows to work at all - the values property of the row object is an empty array after calling the function.

@guyonroche
Copy link
Collaborator

@t1hk I can't seem to reproduce your issue. I copied your code and the spreadsheet looks fine:

2018-04-25 01 excel

@guggu1
Copy link

guggu1 commented Feb 27, 2023

I am probably kind of late.
The function addRow supplying an array of values such as in
addRow['1', '2', '3']

  • does NOT work for me executing it on a Rasperry PI, LINUX, computer from within th ioBroker (a home automation system) using a script developed in JS with the ioBroker javascript adapter. The row is added, but there are no data.
  • DOES work for me executing it in Visual Studio Code, on the same computer, i.e. Rasperry PI , LINUX.

Looks like the function depends to the js engine?

CCS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants