title: How to convert a nested json object into an excel table using the xlsx npm library?
body: <p>I've got a nested json object. For the sake of simplicity:</p>
  
  <pre><code>data = {'key1': 1, 'key2': 2, 'key3': {'nestedKey1': 3, 'nestedKey2': 4}}
  </code></pre>
  
  <p>A real object is bigger but the point is that it's a nested one. Values may be strings, numbers or other objects.
  Now I need to get an excel table that (for this specific json would look like this):</p>
  
  <pre><code>|----------------------------------------
  | key1 | key2 |           key3          |
  |      |      |--------------------------
  |      |      | nestedKey1 | nestedKey2 |
  |----------------------------------------
  |  1   |  2   |     3      |      4     |
  |----------------------------------------
  </code></pre>
  
  <p>In order to do this I tried using the xlsx library. I import the lib as follows:</p>
  
  <pre><code>import { WorkSheet, WorkBook, utils, writeFile } from 'xlsx';
  </code></pre>
  
  <p>Inside my method I define the object:</p>
  
  <pre><code>let myObj = {'key1': 1, 'key2': 2, 'key3': {'nestedKey1': 3, 'nestedKey2': 4}}
  </code></pre>
  
  <p>then I create a worksheet and workbook:</p>
  
  <pre><code>const workSheet: WorkSheet = utils.json_to_sheet([myObj]);
  const workBook: WorkBook = utils.book_new();
  utils.book_append_sheet(workBook, workSheet, 'object_to_save');
  </code></pre>
  
  <p>and finally write it to a file:</p>
  
  <pre><code>writeFile(workBook, 'Tests.xlsx');
  </code></pre>
  
  <p>But quite expectedly it doesn't process the nested object the way I would like it to. I can't figure out what I should do to get the desired result.</p>