在ms访问中插入结果集中的excel文件数据

我有一个方法来检查员工的出勤情况。 雇员的名字,姓氏,职位是从数据库中检索的。 日常出勤方法工作正常。 现在,我也有一种方法,从每日出勤方式创build每月出勤报告。 它也检索数据库中的数据。 在查询中,我使用了一个数据透视表。 它不起作用。 错误表示它在from子句中有错误。 但是当我在ms访问中testing这个查询时,它完美的工作。 大家可以帮助我吗? 这是我的代码。

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()方法访问数据库,我想插入到Excel文件的数据透视查询结果。

您可以使用EasyXLS库将结果集导出到Excel文件。 在这里查看一些源代码示例。