I have 2 data sets – main
table and sub
table – which are related. I want to export the merged data, but the main row contains multiple sub rows.
I tried for loop and foreach datarow1 (insert datarow2) but I want all the sub rows which are related to the main row.
Surya is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
1 Retrieve and Merge Data
2 Format Data for Excel
3 Export to Excel
Data Retrieval: GetMainTable and GetSubTable methods simulate the retrieval of data. Replace them with your actual data source.
Creating Excel Package: ExcelPackage creates a new Excel file, and ExcelWorksheet represents the sheet.
Writing Data: Loop through each row in the main table, writing its data to the Excel file. For each main row, also find and write related sub rows.
Saving the File: Finally, save the Excel file to disk.
Akindu Venul is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1