我的问题是这样的:我想将某个文件夹下的所有excel导进数据库,但是这些原始的excel都是存成了htm格式(excel能够存成该类型),如果要导进数据库,必须先将这些excel另存为xls文件,我想请教java中如何修改文件的类型,即从htm格式改为xls格式 
源代码如下: 
public void importExcel(File dir,String file) throws SQLException { if (dir.isDirectory()) { 
String[] s = dir.list(); 
for (int j = 0; j < s.length; j++) { 
if (file.equals(s[j])) { Connection con = null; 
CallableStatement cstmt = null; 
ResultSet rs = null; 
POIFSFileSystem fs = null; 
HSSFWorkbook wb = null; 
try { 
fs = new POIFSFileSystem(new FileInputStream(dir.getPath() + "\\" + file)); 
wb = new HSSFWorkbook(fs); 
} catch (IOException e) { 
e.printStackTrace(); } 
HSSFSheet sheet = wb.getSheetAt(0); 
HSSFRow row = null; 
HSSFCell cell = null; 
String name = ""; 
String name2 = ""; 
String name3 = ""; 
String flag= null; 
double value; 
String value2; 
int rowNum, cellNum; 
int i; 
rowNum = sheet.getLastRowNum(); 
for (i = 0; i <= rowNum; i++) { 
row = sheet.getRow(i); 
//cellNum = row.getLastCellNum(); cell = row.getCell((short) 0); 
name2 = cell.getStringCellValue(); cell = row.getCell((short) 1); 
name3 = cell.getStringCellValue(); 
cell = row.getCell((short) 2); 
name = cell.getStringCellValue(); 
cell = row.getCell((short) 3); 
// System.out.println(cell.getCellType()); value = cell.getNumericCellValue(); 
try { 
con = DBConnection.getConnection(); 
cstmt = con.prepareCall(IConstants.SP_IMPORTEXCEL_KEY); 
cstmt.setString(1, flag); 
cstmt.setString(2, name2); 
cstmt.setString(3, name3); 
cstmt.setString(4, name); 
cstmt.setDouble(5, value); 
cstmt.execute(); 
} catch (SQLException e) { 
e.printStackTrace(); 
logger.error(e.getMessage()); 
throw e; 
} finally { 
try { if (cstmt != null) { 
cstmt.close(); 

if (con != null) { 
con.close(); 

} catch (SQLException e) { 
e.printStackTrace(); 
logger.error(e.getMessage()); 
throw e; 
} } 
} } 
} else { 
importExcel(new File(dir, s[j]), file); } 
} }