java - 带有 apache POI 的验证字符串
问题描述
我需要进行验证,我需要知道单元格 c3 是否存在字符串“Numero”
但我得到一个错误:
> private int validaLinha(Row row) { String pedidoExcel = “Numero”;
>
> Cell teste = row.getCell(new CellReference("C3").getCol());
>
> try{
> if (teste == null || teste.getCellType() == Cell.CELL_TYPE_BLANK)
> return 0;
>
> if (teste == pedidoExcel)
> return 1;
>
> }catch (Exception e){
> return -1;
> }
}
解决方案
您需要获取单元格和用户等于的值。 https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/Cell.html
if (pedidoExcel.equals(teste.getStringCellValue()))
return 1;
推荐阅读
- nested - JustBasic,在代码中出现“错误的嵌套错误选择/案例”
- javascript - Page.addScriptTag() 不适用于路径或内容
- graphql - Vercel Apollo 服务器(无服务器)的“无法发布 /api/graphql”
- javascript - 如何在 mongoose 中获取当前时间在文档中两个日期值范围内的文档?
- python-3.x - 使用 Python 和 SQL Server 根据分层规则进行分类
- android - 构建 aab 时的文件大小 (mb) 比在 android 中使用 apk 构建时更大
- copyleaks-api - 为什么我会从 CopyLeaks 收到关于导出 API 调用的“冲突”HTTP 409 响应?
- javascript - 弹性容器的过渡高度
- javascript - 搜索引擎功能
- xamarin.forms - 与 xamarin forms android 的深层链接不起作用