public PartialViewResult ProductList(ProductListRequest request) { PagerModel pager = new PagerModel(request.PageIndex, request.PageSize); var result = ThirdShopManager.ForProductListAsync(request, pager, true); if (result.Any()) { pager.TotalItem = result.Count; result = result.Skip((request.PageIndex - 1) * request.PageSize).Take(request.PageSize).ToList(); } ViewBag.Request = request; return(PartialView(new ListModel <ProductPriceModel>() { Pager = pager, Source = result })); }
public FileResult ExportExcel(ProductListRequest request) { PagerModel pager = new PagerModel(request.PageIndex, request.PageSize); var result = ThirdShopManager.ForProductListAsync(request, pager, true); var pagesize = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ExportSize"]); var book = new HSSFWorkbook(); NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1"); NPOI.SS.UserModel.IRow row = sheet1.CreateRow(0); var fileName = $"第三方平台{ThreadIdentity.Operator.Name.Split('@')[0]}.xls"; row.CreateCell(0).SetCellValue("品牌"); row.CreateCell(1).SetCellValue("PID"); row.CreateCell(2).SetCellValue("产品名称"); row.CreateCell(3).SetCellValue("进货价"); row.CreateCell(4).SetCellValue("最小毛利"); row.CreateCell(5).SetCellValue("可用券"); row.CreateCell(6).SetCellValue("官网价格"); row.CreateCell(7).SetCellValue("自有平台最低价"); row.CreateCell(8).SetCellValue("途虎淘宝"); row.CreateCell(9).SetCellValue("途虎淘宝最低价"); row.CreateCell(10).SetCellValue("途虎淘宝2"); row.CreateCell(11).SetCellValue("途虎淘宝2最低价"); row.CreateCell(12).SetCellValue("途虎天猫1"); row.CreateCell(13).SetCellValue("途虎天猫1最低价"); row.CreateCell(14).SetCellValue("途虎天猫2"); row.CreateCell(15).SetCellValue("途虎天猫2最低价"); row.CreateCell(16).SetCellValue("途虎天猫3"); row.CreateCell(17).SetCellValue("途虎天猫3最低价"); row.CreateCell(18).SetCellValue("途虎天猫4"); row.CreateCell(19).SetCellValue("途虎天猫4最低价"); row.CreateCell(20).SetCellValue("途虎京东2"); row.CreateCell(21).SetCellValue("途虎京东2最低价"); row.CreateCell(22).SetCellValue("途虎京东旗舰"); row.CreateCell(23).SetCellValue("途虎京东旗舰最低价"); row.CreateCell(24).SetCellValue("最低面价(平时)"); row.CreateCell(25).SetCellValue("最低面价(大促)"); row.CreateCell(26).SetCellValue("最低券后价(平时)"); row.CreateCell(27).SetCellValue("最低券后价(大促)"); var i = 0; foreach (var item in result) { NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(++i); rowtemp.CreateCell(0).SetCellValue(item.Brand); rowtemp.CreateCell(1).SetCellValue(item.PID); rowtemp.CreateCell(2).SetCellValue(item.ProductName); rowtemp.CreateCell(3).SetCellValue(item.Cost == null ? "" : item.Cost.Value.ToString("0.00")); rowtemp.CreateCell(4).SetCellValue(item.Min_maoliValue == null ? "" : item.Min_maoliValue.Value.ToString("0.00")); rowtemp.CreateCell(5).SetCellValue(item.CanUseCoupon.HasValue ? (item.CanUseCoupon.Value ? "是" : "否") : "是"); rowtemp.CreateCell(6).SetCellValue(item.Price == null ? "" : item.Price.Value.ToString("0.00")); rowtemp.CreateCell(7).SetCellValue(item.LowestPrice == null ? "" : item.LowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(8).SetCellValue(item.TBPrice == null ? "" : item.TBPrice.Value.ToString("0.00")); rowtemp.CreateCell(9).SetCellValue(item.TBLowestPrice == null ? "" : item.TBLowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(10).SetCellValue(item.TB2Price == null ? "" : item.TB2Price.Value.ToString("0.00")); rowtemp.CreateCell(11).SetCellValue(item.TB2LowestPrice == null ? "" : item.TB2LowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(12).SetCellValue(item.TM1Price == null ? "" : item.TM1Price.Value.ToString("0.00")); rowtemp.CreateCell(13).SetCellValue(item.TM1LowestPrice == null ? "" : item.TM1LowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(14).SetCellValue(item.TM2Price == null ? "" : item.TM2Price.Value.ToString("0.00")); rowtemp.CreateCell(15).SetCellValue(item.TM2LowestPrice == null ? "" : item.TM2LowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(16).SetCellValue(item.TM3Price == null ? "" : item.TM3Price.Value.ToString("0.00")); rowtemp.CreateCell(17).SetCellValue(item.TM3LowestPrice == null ? "" : item.TM3LowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(18).SetCellValue(item.TM4Price == null ? "" : item.TM4Price.Value.ToString("0.00")); rowtemp.CreateCell(19).SetCellValue(item.TM4LowestPrice == null ? "" : item.TM4LowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(20).SetCellValue(item.JDPrice == null ? "" : item.JDPrice.Value.ToString("0.00")); rowtemp.CreateCell(21).SetCellValue(item.JDLowestPrice == null ? "" : item.JDLowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(22).SetCellValue(item.JDFlagShipPrice == null ? "" : item.JDFlagShipPrice.Value.ToString("0.00")); rowtemp.CreateCell(23).SetCellValue(item.JDFlagShipLowestPrice == null ? "" : item.JDFlagShipLowestPrice.Value.ToString("0.00")); rowtemp.CreateCell(24).SetCellValue(item.LowestPrice_Normal.HasValue ? item.LowestPrice_Normal.Value.ToString("0.00") : ""); rowtemp.CreateCell(25).SetCellValue(item.LowestPrice_Promotion.HasValue ? item.LowestPrice_Promotion.Value.ToString("0.00") : ""); rowtemp.CreateCell(26).SetCellValue(item.CouponPrice_Normal.HasValue ? item.CouponPrice_Normal.Value.ToString("0.00") : ""); rowtemp.CreateCell(27).SetCellValue(item.CouponPrice_Promotion.HasValue ? item.CouponPrice_Promotion.Value.ToString("0.00") : ""); } var ms = new MemoryStream(); book.Write(ms); ms.Seek(0, SeekOrigin.Begin); return(File(ms, "application/vnd.ms-excel", fileName)); }