コード例 #1
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <returns></returns>
        public ActionResult OutExcel(string jsonString)
        {
            T_InStockInfo model = JsonConvert.DeserializeObject <T_InStockInfo>(jsonString);

            string strErrMsg = string.Empty;
            List <T_InStockInfo> lstExport = new List <T_InStockInfo>();
            DividPage            page      = new DividPage {
                CurrentPageShowCounts = 10000000
            };

            tfunc.GetModelListByPage(ref lstExport, currentUser, model, ref page, ref strErrMsg);

            HSSFWorkbook book  = new HSSFWorkbook();
            ISheet       sheet = book.CreateSheet();
            IRow         row1  = sheet.CreateRow(0);

            row1.CreateCell(0).SetCellValue("单据号");
            row1.CreateCell(1).SetCellValue("据点编号");
            row1.CreateCell(2).SetCellValue("据点名");
            row1.CreateCell(3).SetCellValue("ERP单号");
            row1.CreateCell(4).SetCellValue("单据类型");
            row1.CreateCell(5).SetCellValue("状态");
            row1.CreateCell(6).SetCellValue("仓库");
            row1.CreateCell(7).SetCellValue("创建时间");
            row1.CreateCell(8).SetCellValue("供应商");
            for (int i = 0; i < lstExport.Count(); i++)
            {
                IRow row = sheet.CreateRow(i + 1);//给sheet添加一行
                row.CreateCell(0).SetCellValue(lstExport[i].VoucherNo);
                row.CreateCell(1).SetCellValue(lstExport[i].StrongHoldCode);
                row.CreateCell(2).SetCellValue(lstExport[i].StrongHoldName);
                row.CreateCell(3).SetCellValue(lstExport[i].ErpVoucherNo);
                row.CreateCell(4).SetCellValue(lstExport[i].StrVoucherType);
                row.CreateCell(5).SetCellValue(lstExport[i].StrStatus);
                row.CreateCell(6).SetCellValue(lstExport[i].FromErpWareHouse);
                row.CreateCell(7).SetCellValue(lstExport[i].CreateTime.ToString());
                row.CreateCell(8).SetCellValue(lstExport[i].SupplierName);
            }
            string       fileName     = "入库单据列表" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
            MemoryStream memoryStream = new MemoryStream();

            book.Write(memoryStream);
            memoryStream.Seek(0, SeekOrigin.Begin);
            return(File(memoryStream, "application/vnd.ms-excel", fileName));
        }
コード例 #2
0
ファイル: ServiceInStock.cs プロジェクト: shew990/TaiBang
        public bool GetT_InStockListByPage(ref List <T_InStockInfo> modelList, UserInfo user, T_InStockInfo t_instock, ref DividPage page, ref string strError)
        {
            T_InStock_Func tfunc = new T_InStock_Func();

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