question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sheet_add_json with origin: -1 leaves gap from bottom of worksheet

See original GitHub issue

I’m seeing strange behavior with the following code:

const XLSX = require('xlsx');

const wb = XLSX.utils.book_new();

const ws = XLSX.utils.json_to_sheet([
  { Product: 'p2', Qty: 2 },
]);

XLSX.utils.sheet_add_json(ws,
  [
    { Product: 'p3', Qty: 3 },
    { Product: 'p4', Qty: 4 },
    { Product: 'p5', Qty: 5 },
    { Product: 'p6', Qty: 6 },
    { Product: 'p7', Qty: 7 },
    { Product: 'p8', Qty: 8 },
  ],
  {
    header: ['Product', 'Qty'],
    skipHeader: true,
    origin: -1,  // append to bottom of worksheet starting on first column
  }
);


XLSX.utils.book_append_sheet(wb, ws, 'Bug sheet');

XLSX.writeFile(wb, 'bug.ods');

I expected p3p8 to be placed on rows 3 … 8, but they ended up on rows 6 … 11 (in LibreCalc at least).

image

I’m on 0.14.1. What might be going on?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
dandvcommented, Jan 24, 2021

Greetings from 2021 ❗

3reactions
dandvcommented, Jan 6, 2020

Here’s a 2020 ping!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Utility Functions - SheetJS Community Edition
aoa_to_sheet takes an array of arrays of JS values and returns a worksheet resembling the input data. Values are interpreted as follows: Numbers,...
Read more >
while using header option with XLSX.utils.json_to_sheet ...
I am passing the same numbers of header titles. Here is my code const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet(json, {header: headerColumns}); ...
Read more >
Origin: Data Analysis and Graphing Software - OriginLab
Origin's Graph toolbar lets you add layers to your graph, merge selected graphs, or extract data plots to separate layers or layers to...
Read more >
Origin 2018 Features - OriginLab Wiki - Confluence
1.XYZ column. support in both using existing xyz datasets or import from files. 2. Use existing worksheets. support using any sheet from opj ......
Read more >
xlsx - npm
SheetJS Spreadsheet data parser and writer. ... functions for translating JSON Arrays and other common JS structures into worksheet objects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found