💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# 组件源码 /** * <b>方法描述:</b> 获取工作簿(文件名) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2019-06-20 10:10:57 <br/> * * @param filepath * 入参|文件名称|{@link java.lang.String} * @param book * 出参|工作簿|{@link org.apache.poi.ss.usermodel.Workbook} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "获取工作簿(文件名)", style = "判断型", type = "同步组件", comment = "根据文件名称获取工作簿 5", version = "1.0.0", deprecated = false, author = "admin", date = "2019-06-20 10:10:57") @InParams(param = { @Param(name = "filepath", comment = "文件名称", type = java.lang.String.class) }) @OutParams(param = { @Param(name = "book", comment = "工作簿", type = org.apache.poi.ss.usermodel.Workbook.class) }) @Returns(returns = { @Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功") }) public static ResultBase A_getWorkbookByFilePath(String filepath) { try { File file = new File(filepath); if (!file.exists()) { return ResultBase.newFailureResult("999", "数据转换,读取文件异常,文件不存在!文件:" + filepath); } Workbook wb = WorkbookFactory.create(file); return ResultBase.newSuccessResult(wb); } catch (Exception e) { AppLog.error("读取工作簿异常", e); return ResultBase.newFailureResult("999", "获得文件:" + filepath + ",异常:" + AppLog.errorMsg(e)); } } 交易中组件使用方式: ![](https://img.kancloud.cn/89/70/89700965f7d7cf05644d0a2c70614f1e_950x750.jpg) ## 参数说明及示例 文件名称:Excel文件全路径,示例: `__INNER__["file"]`或者`/home/usr/local/test.xls` 工作簿:返回文件工作簿对象,示例: `__INNER__["workBook"]` > 根据文件名称获取工作簿