<一> 根据模板下载Excel
模拟数据源数据:
private List<ExcursionistVM> GetDataSource()
{
List<ExcursionistVM> list = new List<ExcursionistVM>();
for (var i = 1; i <= 23; i++)
{
list.Add(new ExcursionistVM()
{
ID = 100 + i,
Name = "张三" + i,
EnglishName = i + "san/zhang",
Sex = "M",
BirthDate = DateTime.Now.ToShortDateString(),
Telephone = "1332148974" + i
});
}
return list;
}
实体类:
public class ExcursionistVM
{
public int ID { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 英文名称
/// </summary>
public string EnglishName { get; set; }
public string ELastName
{
get
{
if (string.IsNullOrEmpty(this.EnglishName)) return "";
var name = this.EnglishName.Split('/');
return name[0];
}
}
public string EFirstName
{
get
{
if (string.IsNullOrWhiteSpace(EnglishName))
{
return "";
}
var name = EnglishName.Split('/');
if (name.Length == 1)
{
return "";
}
return name[1];
}
}
/// <summary>
/// 性别
/// </summary>
public string Sex { get; set; }
/// <summary>
/// 出生日期
/// </summary>
public string BirthDate { get; set; }
public string Telephone { get; set; }