Hi , we have requirment to achieve to export excel from json string , that json array wil have different column name , For example
Can anyone suggest with example code . ?
[
{
"CASH":"866.6000",
"CASHCount":"127",
"SHOPBACK_P":"113.4000",
"SHOPBACK_PCount":"8",
"U_Credit":"560.9000",
"U_CreditCount":"54",
"VREDEEM":"20.0000",
"VREDEEMCount":"4",
"PayOut Count":"3",
"PayOut Amount":"$87.60",
"Receiving Count":"0",
"Receiving Amount":"$0.00",
"Cash in Drawer":"$779.00",
"Rounding":"$0.00",
"Refund":"$0.00",
"Item Discount":"$0.00",
"Total Discount":"$0.00",
"Member Total Disc Amount":"$0.00",
"Total Price Shift Disc Amount":"$0.00",
"Total Disc Amount":"$0.00",
"Voucher Amount":"($26.00)",
"Total Sale":2239.0000,
"Net Amount":"$2,239.00",
"Gross Amount":"$2,265.00",
"Hold Count":"0",
"Hold Amount":"$0.00",
"Cancel Count":"0",
"Cancel Amount":"$0.00",
"Void Count":"0",
"Void Amount":"$0.00",
"Exchange Amount":"$0.00",
"No Sales Open":"0",
"No. Of Receipts":"252",
"Receipts Avg":"$8.88"
},
{
"CASH":"660.9000",
"CASHCount":"98",
"REDEEM":"469.1000",
"REDEEMCount":"50",
"SHOPBACK_P":"49.9000",
"SHOPBACK_PCount":"7",
"U_Credit":"319.3000",
"U_CreditCount":"38",
"VREDEEM":"25.0000",
"VREDEEMCount":"5",
"PayOut Count":"2",
"PayOut Amount":"$118.55",
"Receiving Count":"0",
"Receiving Amount":"$0.00",
"Cash in Drawer":"$542.35",
"Rounding":"$0.00",
"Refund":"$0.00",
"Item Discount":"$0.00",
"Total Discount":"$0.00",
"Member Total Disc Amount":"$0.00",
"Total Price Shift Disc Amount":"$0.00",
"Total Disc Amount":"$0.00",
"Voucher Amount":"($15.00)",
"Total Sale":1524.2000,
"Net Amount":"$1,524.20",
"Gross Amount":"$1,539.20",
"Hold Count":"0",
"Hold Amount":"$0.00",
"Cancel Count":"0",
"Cancel Amount":"$0.00",
"Void Count":"0",
"Void Amount":"$0.00",
"Exchange Amount":"$0.00",
"No Sales Open":"0",
"No. Of Receipts":"192",
"Receipts Avg":"$7.94"
}
]
Thanks in advance
Karthik.K

Amit MohantyPosted Sep 4, 2023, 6:19 AM
By using ClosedXML library you can export data from a JSON array to an Excel file in C#:
Lokesh VarmanPosted Sep 4, 2023, 5:45 AM
To export data from a JSON array with different column names to an Excel file in Python, you can use libraries like
pandasandopenpyxl. Here's an example codeMake sure you installed pandas and openpyxl using pip.
This code reads your JSON data into a pandas DataFrame, reorders the columns in the desired order, and then exports it to an Excel file named "output.xlsx." You can modify the
column_orderlist to specify the order in which you want the columns to appear in the Excel file.