我試圖使用導出爲Excell,PDF,TextFile生成報告。那麼我在MVC中這樣做。我有一類我命名SPBatch(這是我的存儲過程的確切名稱在我的SQL),它包含以下內容:DataSet在Export中不支持System.Nullable <>
public string BatchNo { get; set; }
public string ProviderName { get; set; }
public Nullable<System.Int32> NoOfClaims { get; set; }
public Nullable<System.Int32> TotalNoOfClaims { get; set; }
public Nullable<System.Decimal> TotalBilled { get; set; }
public Nullable<System.Decimal> TotalInputtedBill { get; set; }
public Nullable<System.DateTime> DateCreated { get; set; }
public Nullable<System.DateTime> DateSubmitted { get; set; }
public Nullable<System.DateTime> DueDate { get; set; }
public string Status { get; set; }
public string RefNo { get; set; }
public string BatchStatus { get; set; }
public string ClaimType { get; set; }
,你可以看到我的一些列的聲明爲空。它順利地從表格中搜索和顯示結果。我有幾個按鈕下面這對出口和每次我嘗試在Excel導出時的圖像按鈕,我總是得到這個問題「集不支持System.Nullable <>」在我的這部分代碼:
foreach (MemberInfo mi in miArray)
{
if (mi.MemberType == MemberTypes.Property)
{
PropertyInfo pi = mi as PropertyInfo;
dt.Columns.Add(pi.Name, pi.PropertyType); //where the error pop's up.
}
else if (mi.MemberType == MemberTypes.Field)
{
FieldInfo fi = mi as FieldInfo;
dt.Columns.Add(fi.Name, fi.FieldType);
}
}
該錯誤在評論中顯示。你能幫我做些什麼嗎?我嘗試在代碼中添加DBNull,但仍然收到相同的錯誤。我試圖刪除我的SPBatch中的Nullable,但我得到一個錯誤,有些表需要聲明爲Nullable。
我該怎麼辦?
我不會使用'DataSet',因爲它似乎不支持您的需求建議。 –