首页 > 代码库 > NPOI实现Excel导入
NPOI实现Excel导入
导入功能实现:var file = HttpContext.Current.Request.Files[0];GetExtensionsFromFileStream(file.InputStream);using NPOI.XSSF.UserModel;public List<MaterialExtend> GetExtensionsFromFileStream(Stream excelFielStream) { var list = new List<DBOMS_MaterialExtend>(); var book = new XSSFWorkbook(excelFielStream); var firstSheet = book.GetSheetAt(0); var ExtendType = firstSheet.SheetName; for (int i = 1; i <= firstSheet.LastRowNum; i++) { var entity = new DBOMS_MaterialExtend(); XSSFRow row = firstSheet.GetRow(i) as XSSFRow; entity.MaterialCode = (row.GetCell(0) as XSSFCell).StringCellValue; entity.ReferFactory = (row.GetCell(1) as XSSFCell).StringCellValue; entity.ExtendType = (int)Enum.Parse(typeof(ExtendTypeEnum), ExtendType, true); list.Add(entity); } return list; }
NPOI实现Excel导入
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。