Get dynamic field values from list and display in excel

Hi,

we have a list in which we have 30 columns and some amount of datas from database.
we have to export this to excel but not all the 30 columns only 4 columns among that those 4 columns is choosen by user dynamic.

we are getting those selected column names as parameters say string fieldname1
Sample code:(to display heading in excel)

Var fifthcellheading=cells[“E3”];
fifthcellheading.value=fieldname1;

so in E4 i need to display value of fieldname1 say “RiskRef” like
for(int 1=0;i<rpt.count;i++)
{
rpt[i]. ?
}

@Sindujaa,

If you need to import data from some external data source/database into Excel spreadsheet, you have to first import data (you may use your own code using e.g., ADO.NET or relevant .NET APIs, you may write/use your own queries/statements yourselves to fetch those four columns data only) and then fill it to some container like DataTable or Arrays/ List). Now, you may use Aspose.Cells APIs to import it into worksheet cells, see the document on data importing options provided by Aspose.Cells for your complete reference.
https://docs.aspose.com/cells/net/import-data-into-worksheet/