• c# 导出表格


    
    

    var record = m_editor.getMasterRecord();
    var Check_Id = record.Check_Id;
    var url = "/Storage/Storage_Check/StorageExport?Check_Id="+Check_Id;
    window.open(url);







    #region
    库存明细导出 /// <summary> /// 说明:库存明细导出 /// 时间:2015-2-20 /// </summary> /// <param name="idLists"></param> /// <param name="Provider_Ids"></param> /// <returns></returns> public ActionResult StorageExport(string Check_Id) { string where = string.Empty; string sql = string.Empty; ResultInfo info = new ResultInfo(); where = "Check_Id=" + Check_Id; Storage_Check Detail = Storage_CheckRepository.Instance.Get(where); IList<Storage_CheckList> DetailList = Storage_CheckListRepository.Instance.GetMany(where).ToList(); #region 将数据写入到Execl中,并下载 string path = Server.MapPath("~/Upload/ImportCheck/库存盘点数量导入.xlsx"); //HttpContext.Current.Server //指定Templete文档Text.xlsx FileInfo newFile = new FileInfo(path); //开启 using (ExcelPackage pck = new ExcelPackage(newFile)) { //设定ExcelWorkBook ExcelWorkbook workBook = pck.Workbook; workBook.Worksheets.Delete(1); ExcelWorksheet currentWorksheet = pck.Workbook.Worksheets.Add("库存盘点数据"); if (workBook != null) { if (workBook.Worksheets.Count > 0) { currentWorksheet.Cells[1, 1].Value = "盘点ID";//盘点ID currentWorksheet.Cells[1, 2].Value = "盘点明细ID";//盘点明细ID currentWorksheet.Cells[1, 3].Value = "货位";//货位 currentWorksheet.Cells[1, 4].Value = "编号"; currentWorksheet.Cells[1, 5].Value = "商品名称"; currentWorksheet.Cells[1, 6].Value = "条形码"; currentWorksheet.Cells[1, 7].Value = "商品规格"; currentWorksheet.Cells[1, 8].Value = "小单位"; currentWorksheet.Cells[1, 9].Value = "批次号"; currentWorksheet.Cells[1, 10].Value = "账面库存量"; currentWorksheet.Cells[1, 11].Value = "盘点数量"; currentWorksheet.Cells[1, 12].Value = "生产日期"; currentWorksheet.Cells[1, 13].Value = "到期日期"; currentWorksheet.Cells[1, 14].Value = "备注"; int i = 1; foreach (Storage_CheckList list in DetailList) { i += 1; // var SmallUnit = ""; // var Product = Base_ProductInfoRepository.Instance.GetMany("ProductCode =" + list.ProductCode).ToList(); //foreach (var a in Product) //{ // SmallUnit = a.SmallUnit; //} var Product = Base_ProductInfoRepository.Instance.Get("ProductCode ='" + list.ProductCode+"'"); int ProductStorage = (Detail.IsBlind ?? 0) == 1 ? 0 : (list.ProductStorage??0); //Cells[RowIndex,CellIndex] currentWorksheet.Cells[i, 1].Value = list.Check_Id;//盘点ID currentWorksheet.Cells[i, 2].Value = list.CheckList_Id;//盘点明细ID currentWorksheet.Cells[i, 3].Value = list.PositionName; currentWorksheet.Cells[i, 4].Value = list.ProductCode; currentWorksheet.Cells[i, 5].Value = list.ProductName; currentWorksheet.Cells[i, 6].Value = list.ProductModel; currentWorksheet.Cells[i, 7].Value = list.ProductSpec; currentWorksheet.Cells[i, 8].Value = Product.SmallUnit; currentWorksheet.Cells[i, 9].Value = list.BatchNumber; currentWorksheet.Cells[i, 10].Value = ProductStorage; currentWorksheet.Cells[i, 11].Value = list.CheckQuantity; currentWorksheet.Cells[i, 12].Value = list.ProduceDate.HasValue ? list.ProduceDate.Value.ToString("yyyy-MM-dd") : ""; currentWorksheet.Cells[i, 13].Value = list.LimitDate.HasValue ? list.LimitDate.Value.ToString("yyyy-MM-dd") : ""; currentWorksheet.Cells[i, 14].Value = list.Remark; // string Check_Id = worksheet.Cells[i, 1].Value != null ? worksheet.Cells[i, 1].Value.ToString() : null; } } } //存至库存盘点数据导出.xlsx //pck.SaveAs(new FileInfo("E:" + @"库存盘点数量导入.xlsx")); string pathInfoList = Server.MapPath("~/Upload/ImportCheck/库存盘点数据导出.xlsx"); pck.SaveAs(new FileInfo(pathInfoList)); } return new RedirectResult("/Upload/ImportCheck/库存盘点数据导出.xlsx"); #endregion } #endregion
  • 相关阅读:
    结对编程作业——毕设导师智能匹配
    结对项目之需求分析与原型设计
    Excel绘制之甘特图
    Excel绘图之数据波动条形图
    Excel绘图之漏斗图
    Excel绘图之四象限散点图
    软件工程实践总结
    发送手机验证码
    个人作业——软件产品案例分析
    用例图
  • 原文地址:https://www.cnblogs.com/lvqianqian/p/10725274.html
Copyright © 2020-2023  润新知