/// <summary> /// 导出数据 /// </summary> /// <returns></returns> public void ExportData() { //string ProductBZ = System.Web.HttpContext.Current.Request.Params["ProductBZ"]; HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook(); ISheet sheet = book.CreateSheet("sheet1"); IRow row1 = sheet.CreateRow(0); row1.CreateCell(0).SetCellValue("代码"); row1.CreateCell(1).SetCellValue("名称"); //row1.CreateCell(2).SetCellValue("备注"); Dictionary <string, object> dicWhere = new Dictionary <string, object>(); new CreateCriteria(dicWhere) .Add(ORMRestrictions <System.Int64> .NotEq("PhId", 0)); IList <ProcurementCatalogModel> procurementCatalogs = ProcurementCatalogService.Find(dicWhere).Data; for (int i = 0; i < procurementCatalogs.Count; i++) { ProcurementCatalogModel model = procurementCatalogs[i]; IRow row = sheet.CreateRow(i + 1); row.CreateCell(0).SetCellValue(model.FCode); row.CreateCell(1).SetCellValue(model.FName); //row.CreateCell(2).SetCellValue(model.FRemark); } System.IO.MemoryStream ms = new System.IO.MemoryStream(); book.Write(ms); Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"))); Response.BinaryWrite(ms.ToArray()); book = null; ms.Close(); ms.Dispose(); }
/// <summary> /// 根据主键获取数据 /// </summary> /// <returns>返回Json串</returns> public string GetProcurementCatalogInfo() { long id = Convert.ToInt64(System.Web.HttpContext.Current.Request.Params["id"]); //主表主键 string tabtype = System.Web.HttpContext.Current.Request.Params["tabtype"]; //Tab类型 var findedresult = ProcurementCatalogService.Find(id); return(DataConverterHelper.ResponseResultToJson(findedresult)); }