我试图使用导出到Excel、PDF、文本文件的方式生成报告。在MVC中进行此操作。我有一个类,我将其命名为SPBatch(这是我的SQL存储过程的确切名称),其中包含以下内容:
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 时,我总是在代码的这一部分遇到问题 "DataSet does not support 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
,因为它似乎不支持您的需求。 - John Saunders