我有一个方法来检查员工的出勤情况。员工的名字、姓氏、职位是从数据库中检索的。每日出勤方法效果很好。现在,我还有一种方法,可以从每日考勤方法创建每月考勤报告。它还检索数据库中的数据。在查询时,我使用了枢轴。这不起作用。该错误表明 from 子句中有错误。但是当我在 ms access 中测试该查询时,它工作得很好。大家都可以帮我解决这个问题吗?这是我的代码。
private void attendanceView() throws ClassNotFoundException{
String query ="TRANSFORM COUNT(attendance.present)SELECT employees.ID,employees.firstName,employees.lastName,employees.position,employees.rate FROM employees LEFT JOIN attendance ON employees.ID = attendance.empID GROUP BY employees.ID,employees.firstName,employees.lastName,employees.position,employees.rate PIVOT attendance.dateAttended";
Object[][] result = connectToDB(query);
monthlyAttendanceTable.setModel(new javax.swing.table.DefaultTableModel(
result, new String [] {"Employee ID","First Name","Last Name", "Position", "Rate","",""}
)
{
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class, java.lang.Integer.class,java.lang.Integer.class,java.lang.Integer.class,java.lang.String.class
};
boolean[] canEdit = new boolean [] {
false, false, false, false, false, false, false, false, false,false
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
}
我从一些资源中了解到,结果集可以插入到 Excel 文件中。谁能帮我这个?我通过 connectToDB() 方法 Access 数据库,我想将数据透视表查询结果插入到 Excel 文件中。
最佳答案
关于java - 将ms access中结果集的数据插入到excel文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23565710/