Greetings for the assistance in advance. Currently, I am working with TypeScript, but I believe any JS solution will suffice. I aim to create something akin to the following:
class ExcelData {
'Id 1': items[0].id,
'Quantity 1': items[0].quantity,
'Id 2': items[1].id,
'Quantity 2': items[1].quantity
//...
'Id 40': items[39].id,
'Quantity 40': items[39].quantity,
}
I am endeavoring to utilize it with the 'xlsx' module to export project data into an Excel spreadsheet. The module mandates this be a class rather than multiple arrays. While I could manually input the data, with 7 properties per item, the code would become quite messy. Moreover, there may be a requirement to include additional items in the future. In Python, I could achieve a similar result as classes and dictionaries are distinct entities:
excel_data = {}
for i in range (40):
excel_data['Id '+ str(i)] = items[i].id
excel_data['Quantity '+ str(i)] = items[i].quantity
Is there a TypeScript alternative that can serve this purpose?
Many thanks!