I'm trying to solve an issue in my code. It's a devBooster
code, so pretty similar to .NET
.
I have a List of objects and I'm looping over each one to populate a stream and finally export this Stream to Excel file thanks to a Template.
This is my foreach loop which populate Stream :
foreach (var resultat in ListeDesGroupesNotationsItemVM.Resultat)
{
string codeAlgo = resultat.CodeAlgo.ToString();
string codeSegment = resultat.CodeSegment.ToString();
worksheet.Cells[ligne, 1].Value = resultat.Nom;
worksheet.Cells[ligne, 2].Value = resultat.IdCMCIC;
worksheet.Cells[ligne, 3].Value = resultat.NomGac;
worksheet.Cells[ligne, 4].Value = resultat.Refbilancielle;
worksheet.Cells[ligne, 5].Value = resultat.Cotation;
worksheet.Cells[ligne, 6].Value = resultat.Secteur;
worksheet.Cells[ligne, 7].Value = codeAlgo.IsBlank() ? "" : codeAlgo;
worksheet.Cells[ligne, 8].Value = codeSegment.IsBlank() ? "" : codeSegment;
worksheet.Cells[ligne, 9].Value = resultat.DateDerniereCotation;
worksheet.Cells[ligne, 10].Value = resultat.Statut;
worksheet.Cells[ligne, 11].Value = resultat.PolePresentateur;
worksheet.Cells[ligne, 12].Value = resultat.Pays;
ligne++;
}
I have an issue with two fields which are ENUM field
: resultat.CodeAlgo
and resultat.CodeSegment
.
The error message when I try to compile is :
NullReferenceException was unhandled by user code Additional information: The object reference is not defined as an object instance (sorry for translation)
To my mind, I have to manage NULL field right ?
Thank you by advance