public FileResult Excel(T_InStockTaskInfo model)
        {
            DividPage page = new DividPage()
            {
                CurrentPageShowCounts = 10000000
            };
            string strErrMsg = string.Empty;
            List <T_InStockTaskInfo> lstExport = new List <T_InStockTaskInfo>();

            tfunc_task.GetModelListByPage(ref lstExport, currentUser, model, ref page, ref strErrMsg);
            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.ISheet sheet1 = book.CreateSheet("Sheet1");
            //给sheet1添加第一行的头部标题
            NPOI.SS.UserModel.IRow row1 = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue("据点名");
            row1.CreateCell(1).SetCellValue("单据类型");
            row1.CreateCell(2).SetCellValue("ERP单号");
            row1.CreateCell(3).SetCellValue("任务号");
            row1.CreateCell(4).SetCellValue("状态");
            row1.CreateCell(5).SetCellValue("任务下发人");
            row1.CreateCell(6).SetCellValue("凭证号");
            row1.CreateCell(7).SetCellValue("创建时间");
            row1.CreateCell(8).SetCellValue("仓库名");
            //将数据逐步写入sheet1各个行
            for (int i = 0; i < lstExport.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(lstExport[i].StrongHoldName);
                rowtemp.CreateCell(1).SetCellValue(lstExport[i].StrVoucherType);
                rowtemp.CreateCell(2).SetCellValue(lstExport[i].ErpVoucherNo);
                rowtemp.CreateCell(3).SetCellValue(lstExport[i].TaskNo);
                rowtemp.CreateCell(4).SetCellValue(lstExport[i].StrStatus);
                rowtemp.CreateCell(5).SetCellValue(lstExport[i].StrTaskIsSuedUser);
                rowtemp.CreateCell(6).SetCellValue(lstExport[i].ErpInVoucherNo);
                rowtemp.CreateCell(7).SetCellValue(lstExport[i].CreateTime.ToString());
                rowtemp.CreateCell(8).SetCellValue(lstExport[i].WareHouseName);
            }
            // 写入到客户端
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"));
        }
Exemple #2
0
        public bool GetT_InTaskListByPage(ref List <T_InStockTaskInfo> modelList, UserInfo user, T_InStockTaskInfo t_task, ref DividPage page, ref string strError)
        {
            T_InStockTask_Func tfunc = new T_InStockTask_Func();

            return(tfunc.GetModelListByPage(ref modelList, user, t_task, ref page, ref strError));
        }