java - 用于访问 Excel 数据的 SQL 查询 - Java
问题描述
我正在尝试使用 Fillo-1.18 从 excel 中读取数据。下面是我的代码:
public static void main(String[] args) {
Fillo fillo=new Fillo();
Connection connection;
try {
connection = fillo.getConnection("C:\\Users\\Dish\\Desktop\\1.xlsx");
String strQuery="Select sum(Amount) as amnt, Run_ID from Sheet1 group by Run_ID";
Recordset recordset=connection.executeQuery(strQuery);
while(recordset.next()){
System.out.println(recordset.getField("amnt"));
}
recordset.close();
connection.close();
} catch (FilloException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
它适用于普通的选择子句。但是当我尝试使用像 SUM() 这样的聚合函数时,我无法访问该字段。在里面while
我收到以下错误:
com.codoid.products.exception.FilloException: amnt field is not found
at com.codoid.products.fillo.Recordset.getField(Recordset.java:163)
at ReadExcelSheetData.main(ReadExcelSheetData.java:18)
我该如何解决这个问题?
解决方案
推荐阅读
- ruby-on-rails - 如何使用参数的值为关联模型构建“.collection”方法?
- sql - 在 Postgresql 中按数组从 json/jsonb 列中查找数据
- virtual-machine - 适用于 Linux 的 Windows 子系统是 Linux 虚拟机的完全替代品吗?
- android - 将旧版 MapsV2 Eclipse 应用程序更新为最新的 API
- mongodb - java中的MongoDB聚合:如何获取总记录数和分页结果?
- javascript - 检测 HTML 视频变化
- c# - 对象引用未设置为对象的实例。模型为空
- r - 如何在表格和标题中的多列之间扩展 DT 数据表单元格
- r - R同时使用带有分类和数值变量的melt()和dcast()
- c - C - 矩阵乘法 - 使用最大可分配 RAM 大小