【发布时间】:2014-07-17 17:22:14
【问题描述】:
我正在使用 Apache_poi 制作 Excel 文件。该文件将在我的 Swing 应用程序中按钮的操作事件上创建。 Excel 工作表创建得很好,但是当我打开它时,我得到了这个错误:
您尝试打开的文件与文件扩展名指定的格式不同
当我打开文件时,它完全是空的。
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
try {
// String personalclass=jComboBox1.getSelectedItem().toString();
// String ac="academic";
// FileOutputStream output=new FileOutputStream("D:\\"+personalclass+ac+".xls");
FileOutputStream output=new FileOutputStream("D:\\workbook.xls");
Workbook wb=new HSSFWorkbook();
Sheet sheet =wb.createSheet("Class 1");
Cell cell=sheet.createRow(0).createCell(3);
cell.setCellValue("Thisisatestofmerging");
//sheet.addMergedRegion(new CellRangeAddress(1, 1, 1, 2));
output.close();
}
catch(Exception e)
{
}
}
【问题讨论】:
标签: java excel swing apache apache-poi