{"action":"created","issue":{"url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1253","repository_url":"https://api.github.com/repos/SheetJS/js-xlsx","labels_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1253/labels{/name}","comments_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1253/comments","events_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1253/events","html_url":"https://github.com/SheetJS/js-xlsx/issues/1253","id":356533773,"node_id":"MDU6SXNzdWUzNTY1MzM3NzM=","number":1253,"title":"When I use XLSX.utils..json_to_sheet(data,{header:[...]}),but my \"header\"  has no effect.","user":{"login":"164000215","id":40616344,"node_id":"MDQ6VXNlcjQwNjE2MzQ0","avatar_url":"https://avatars3.githubusercontent.com/u/40616344?v=4","gravatar_id":"","url":"https://api.github.com/users/164000215","html_url":"https://github.com/164000215","followers_url":"https://api.github.com/users/164000215/followers","following_url":"https://api.github.com/users/164000215/following{/other_user}","gists_url":"https://api.github.com/users/164000215/gists{/gist_id}","starred_url":"https://api.github.com/users/164000215/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/164000215/subscriptions","organizations_url":"https://api.github.com/users/164000215/orgs","repos_url":"https://api.github.com/users/164000215/repos","events_url":"https://api.github.com/users/164000215/events{/privacy}","received_events_url":"https://api.github.com/users/164000215/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-03T14:49:37Z","updated_at":"2018-09-03T17:13:59Z","closed_at":null,"author_association":"NONE","body":"data88 =JSON.stringify(data1).trim();//data1 is Handsontable's sourceData\r\ndata888 = JSON.parse(data88);\r\nworkbook = XLSX.utils.book_new();\r\nvar ws1 = XLSX.utils.json_to_sheet(data888,{header:[\"medicineId\",................}); \r\nXLSX.utils.book_append_sheet(workbook, ws1, \"Sheet1\");XLSX.writeFile(workbook, 'out.xlsx');\r\n Object.keys  can not be overridden.The result is like below:\r\nMy header1  2 3 4 ObjectKeys1 keys2 keys3 keys4\r\n                                      data1  data2   data3 data4"},"comment":{"url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/comments/418164056","html_url":"https://github.com/SheetJS/js-xlsx/issues/1253#issuecomment-418164056","issue_url":"https://api.github.com/repos/SheetJS/js-xlsx/issues/1253","id":418164056,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODE2NDA1Ng==","user":{"login":"SheetJSDev","id":6070939,"node_id":"MDQ6VXNlcjYwNzA5Mzk=","avatar_url":"https://avatars1.githubusercontent.com/u/6070939?v=4","gravatar_id":"","url":"https://api.github.com/users/SheetJSDev","html_url":"https://github.com/SheetJSDev","followers_url":"https://api.github.com/users/SheetJSDev/followers","following_url":"https://api.github.com/users/SheetJSDev/following{/other_user}","gists_url":"https://api.github.com/users/SheetJSDev/gists{/gist_id}","starred_url":"https://api.github.com/users/SheetJSDev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SheetJSDev/subscriptions","organizations_url":"https://api.github.com/users/SheetJSDev/orgs","repos_url":"https://api.github.com/users/SheetJSDev/repos","events_url":"https://api.github.com/users/SheetJSDev/events{/privacy}","received_events_url":"https://api.github.com/users/SheetJSDev/received_events","type":"User","site_admin":false},"created_at":"2018-09-03T17:13:59Z","updated_at":"2018-09-03T17:13:59Z","author_association":"CONTRIBUTOR","body":"The `header` specifies the order for keys.  If there are other keys in the data objects, they will still be written but will appear after the specified headers.\r\n\r\nConsider the following:\r\n\r\n```js\r\nvar ws = XLSX.utils.json_to_sheet([\r\n  { A:\"S\", B:\"h\", C:\"e\", D:\"e\", E:\"t\", F:\"J\", G:\"S\" },\r\n  { A: 1,  B: 2,  C: 3,  D: 4,  E: 5,  F: 6,  G: 7  },\r\n  { A: 2,  B: 3,  C: 4,  D: 5,  E: 6,  F: 7,  G: 8  }\r\n], {header:[\"B\",\"D\",\"F\", \"H\"]});\r\n```\r\n\r\nThe header array specifies the order `\"B\", \"D\", \"F\", \"H\"` so those keys will be populated first (the first column will hold the data from the \"B\" key, second column from \"D\", etc.)\r\n\r\nTo see the output, convert to an array of arrays: `var aoa = XLSX.utils.sheet_to_json(ws, {header:1});`\r\n\r\n```js\r\n[ [ 'B', 'D', 'F', 'H', 'A', 'C', 'E', 'G' ],\r\n  [ 'h', 'e', 'J', <1 empty item>, 'S', 'e', 't', 'S' ],\r\n  [ '2', '4', '6', <1 empty item>, '1', '3', '5', '7' ],\r\n  [ '3', '5', '7', <1 empty item>, '2', '4', '6', '8' ] ]\r\n```\r\n\r\nThe specified headers are used first, in the order they appear.  The other keys are still written, but they are written after the known headers in an order based on Object.keys for the first data row in which they appear."}}
{"actor":{"display_login":"SheetJSDev"}}