is there any javascript library available to convert the nested array of object to table rows and columns...
sample data..
 [
  {
    "headerName": "Product"
  },
  {
    "headerName": "Sale Rate",
    "children": [
      {
        "headerName": "Sales",
        "children": [
          {
            "headerName": "Last Year Sale"
          },
          {
            "headerName": "This Year Sale"
          }
        ]
      },
      {
        "headerName": "Profits",
        "children": [
          {
            "headerName": "Last Year Profit"
          },
          {
            "headerName": "This Year Profit"
          }
        ]
      }
    ]
  }
]
need to build the below table structure(row, column along with row and col span) from the data
<table>
  <tr>
    <th rowspan="3">Product</th>
    <th colspan="4">Sale Rate</th>
  </tr>
  <tr>
    <th colspan="2">Sales</th>
    <th colspan="2">Profits</th>
  </tr>
  <tr>
    <th>Last Year Sale</th>
    <th>This Year Sale </th>
    <th>Last Year Profit</th>
    <th>This Year Profit</th>
  </tr>
</table>
what i tried so far https://codesandbox.io/s/modest-booth-inhzvm
struggling to get the column and row span from data
 
    