In this post http://forums.arcgis.com/threads/13460-Export-to-ExcelKaren Blaney mentioned that the file won't export if there are null attributes.THIS IS MY ISSUE. The export works if every field has a value, if not it doesn't save.I'm trying to add code to handle this but running into no love. 'I changed the simple if statement I added to the color of RED to highlight the change
//Create the rows
foreach (Graphic data in graphics)
{
lstValues.Clear();
foreach (string field in fields)
{
string strValue = string.Empty;
if ((data.Attributes[field]) != null)
{
strValue = data.Attributes[field].ToString();
}
lstValues.Add(FormatField(strValue, strFormat));
//strValue = data.Attributes[field].ToString();
//lstValues.Add(FormatField(strValue, strFormat));
}
//Build the row
BuildStringOfRow(strBuilder, lstValues, strFormat);
}
WriteExcelFile(objSFD, strFormat, strBuilder);
//Build the column headers row
BuildStringOfRow(strBuilder, lstFields, strFormat);
//Create the rows
foreach (Graphic data in graphics)
{
lstValues.Clear();
foreach (DataGridColumn field in columns)
{
string strValue = string.Empty;
if ((data.Attributes[field.Header.ToString()]) != null)
{
strValue = data.Attributes[field.Header.ToString()].ToString();
}
lstValues.Add(FormatField(strValue, strFormat));
}
//Build the row
BuildStringOfRow(strBuilder, lstValues, strFormat);
}
WriteExcelFile(objSFD, strFormat, strBuilder);
}
Could any one point me in the right direction.ThanksNathalie