private void WriteRow(ExcelWorksheet worksheet, int rowNum, IList <FieldDiscriptor> fields, CruiseDAL.DataObject data) { //populate columns for (int j = 0; j < fields.Count; j++) { FieldDiscriptor field = fields[j]; object value = GetFieldValue(data, field); worksheet.SetValue(rowNum, j + 1, value); } }
protected string GetFieldText(object data, FieldDiscriptor field) { object value = this.GetFieldValue(data, field); if (value != null && !(value is string)) { return(value.ToString()); } return(value as String ?? string.Empty); }
protected object GetFieldValue(object data, FieldDiscriptor field) { object obj = field.PropInfo.GetValue(data, null); if (obj is IFormattable && !string.IsNullOrEmpty(field.Format)) { return(((IFormattable)obj).ToString(field.Format, System.Globalization.CultureInfo.CurrentCulture)); } else if (obj == null) { return(string.Empty); } else { return(obj); } }