/// <summary> /// 非大批量数据便捷导出 /// </summary> /// <returns></returns> public IActionResult LiteDataExport() { //此方式对象全部在内存中,故数据量大的时候会占用内存,适合数据量不大使用;大数据量不占用内存的请采用上述的AppendData方式 var users = Enumerable.Range(1, ExportCount).Select(index => new UserExportDto { Account = $"2021-{index}", Name = $"测试用户-{index}", IsMan = true, IsConfirm = true }).ToList(); var excelInfo = LiteDataHelper.ExportToWebDown(users, fileName: "用户数据"); return(File(excelInfo.Stream, excelInfo.WebContentType, excelInfo.FileName)); }
/// <summary> /// 非大批量数据便捷导出 /// </summary> /// <returns></returns> public IActionResult LiteDataExport() { var users = new List <UserExportDto>(); for (int i = 1; i <= ExportCount; i++) { users.Add(new UserExportDto { Account = $"2020-{i}", Name = $"测试用户-{i}" }); } var excelInfo = LiteDataHelper.ExportToWebDown(users, fileName: $"用户数据-{DateTime.Now.ToString("yyyyMMddHHmm")}"); return(File(excelInfo.Stream, excelInfo.WebContentType, excelInfo.FileName)); }