Load a file, Add one column (or row) and write a value in, how to do? #561

Closed
opened 2017-02-17 11:10:39 +00:00 by Ideandro · 2 comments
Ideandro commented 2017-02-17 11:10:39 +00:00 (Migrated from github.com)

I can not figure out how to do it:

  • Load a .xlsx file (done!)
  • Add a column (or row) (???)
  • Write a value in (???)

It's possible to do it?
It's possible write a value out of ws['!ref']?
How to update this value (!ref)?
It's possible to see an example?
Thanks!

I can not figure out how to do it: - Load a .xlsx file (done!) - Add a column (or row) (???) - Write a value in (???) It's possible to do it? It's possible write a value out of ws['!ref']? How to update this value (!ref)? It's possible to see an example? Thanks!
SheetJSDev commented 2017-03-29 23:22:47 +00:00 (Migrated from github.com)

There's a wildly destructive way to do this:

  • convert worksheet to an array of arrays (sheet_to_json with {raw:true, header:1})
  • manipulate the array of arrays:
    -- insert your row by splicing the outer array with a empty row
    -- insert your column by iterating through every row
  • convert array of arrays back to a worksheet (aoa_to_sheet)

The hard part of manipulating the raw object representation is making sure everything else is consistent. Take formulae. How do you ensure that you update formula references when you insert or delete rows or columns? You need to walk every formula and fix them.

There's a wildly destructive way to do this: - convert worksheet to an array of arrays (`sheet_to_json` with `{raw:true, header:1}`) - manipulate the array of arrays: -- insert your row by splicing the outer array with a empty row -- insert your column by iterating through every row - convert array of arrays back to a worksheet (`aoa_to_sheet`) The hard part of manipulating the raw object representation is making sure everything else is consistent. Take formulae. How do you ensure that you update formula references when you insert or delete rows or columns? You need to walk every formula and fix them.
SheetJSDev commented 2018-01-09 08:11:47 +00:00 (Migrated from github.com)

We added a sheet_add_aoa helper function that can modify an existing worksheet with data specified in an array of arrays. sheet_add_json takes an array of JS objects. See #947 for a complete example.

We added a `sheet_add_aoa` helper function that can modify an existing worksheet with data specified in an array of arrays. `sheet_add_json` takes an array of JS objects. See #947 for a complete example.
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#561
No description provided.