Allow cell objects to be passed in when importing data from JSON #1169

Closed
mattandrews wants to merge 1 commits from cell-object-import into master
mattandrews commented 2018-07-03 12:13:09 +00:00 (Migrated from github.com)

This relates to https://github.com/SheetJS/js-xlsx/issues/1168 – it basically implements the fix that @SheetJSDev suggests, which I've confirmed works on my test case in the code listed there.

Essentially this allows us to pass a structured cell object into utilities like json_to_sheet(), eg:

let myArray = [
  {
    name: 'bob',
    age: 23,
    link: {
        f: 'HYPERLINK("http://www.google.com", "Google")',
        t: 'n',
        v: 'http://www.google.com'
    }
  }
];

let worksheet = XLSX.utils.json_to_sheet(myArray);
let workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, "SheetJS");

Note: I couldn't get the indentation to work properly for this PR – I tried in two different editors and despite telling both to use spaces, not tabs, the output of this PR is different from how the code looks in both IntelliJ and VS Code:

image

Is there a required editor config to make this work?

This relates to https://github.com/SheetJS/js-xlsx/issues/1168 – it basically implements the fix that @SheetJSDev suggests, which I've confirmed works on my test case in the code listed there. Essentially this allows us to pass a structured cell object into utilities like `json_to_sheet()`, eg: ``` let myArray = [ { name: 'bob', age: 23, link: { f: 'HYPERLINK("http://www.google.com", "Google")', t: 'n', v: 'http://www.google.com' } } ]; let worksheet = XLSX.utils.json_to_sheet(myArray); let workbook = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(workbook, worksheet, "SheetJS"); ``` Note: I couldn't get the indentation to work properly for this PR – I tried in two different editors and despite telling both to use spaces, not tabs, the output of this PR is different from how the code looks in both IntelliJ and VS Code: ![image](https://user-images.githubusercontent.com/394376/42219151-c270db8e-7ec2-11e8-8210-b56480b744a2.png) Is there a required editor config to make this work?
SheetJSDev commented 2018-07-07 16:57:09 +00:00 (Migrated from github.com)

Switch to vim :D but it honestly doesn't matter, we will fix it later

Switch to vim :D but it honestly doesn't matter, we will fix it later

Pull request closed

Sign in to join this conversation.
No description provided.