I have a set of objects in JSON format within my JavaScript code and I am looking to transform this data into an Excel worksheet. Within the JSON structure, there are certain key-value pairs that I do not wish to include in the Excel output. For instance, I want to exclude any information related to the year as shown below (PLEASE EXECUTE HTML CODE TO VIEW DESIRED EXCEL OUTPUT):
JSON example:
[
{
car: "Range Rover",
color: "silver",
year: "2021"
},
{
car: "Benz",
color: "black",
year: "2019"
},
{
car: "Toyota",
color: "silver",
year: "2020"
}
]
Desired Excel view (Execute snippet):
<html>
<body>
<table>
<tr>
<th>car</th>
<th>color</th>
</tr>
<tr>
<td>Range Rover</td>
<td>silver</td>
</tr>
<tr>
<td>Benz</td>
<td>black</td>
</tr>
<tr>
<td>Toyota</td>
<td>silver</td>
</tr>
</table>
</body>
</html>
Is it possible to accomplish this using XLSX library in JavaScript?