I am looking for a way to update an existing Excel spreadsheet with data from a SQL query via C# putting data in columns based on column header. For instance, if I have the following returned query/dataset
Width Height Length
2 2 2
2 3 4
3 4 5
And I have an Excel workbook like so:
Width Height Area Length Volume
=(A1*B1) =(C1*D1)
=(A2*B2) =(C2*D2)
=(A3*B3) =(C3*D3)
I would like to insert Width, Length and Height into the workbook without affecting Area or Volume, i.e.:
Width Height Area Length Volume
2 2 =(A1*B1) 2 =(C1*D1)
2 3 =(A2*B2) 4 =(C2*D2)
3 4 =(A3*B3) 5 =(C3*D3)
Is there a way to specify in code that the Width from the dataset should go in the Width column, etc.? I am currently using the EPPlus package to do Excel tasks.