excel
// ( , , )
java.util.Date curdate = new java.util.Date();
String outFileName = new Long(curdate.getTime()).toString();
//
FileOutputStream fileOut = null;
//
HSSFWorkbook wb = new HSSFWorkbook();、
// sheet , sheet1 sheet ,
HSSFSheet sheet = wb.createSheet("sheet1");
// sheet
wb.setSheetName(0,"sheet1", HSSFWorkbook.ENCODING_UTF_16);
// cell, row
HSSFRow row = null;
HSSFCell cell = null;
// , , list
//
cell = row.createCell((short)0);
// ,
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(" ");
String exptfile = outFileName + ".xls";//
// ( D )
fileOut = new FileOutputStream("D:"+File.separator+outFileName+".xls");
//
wb.write(fileOut);
// ,
ileOut.flush();
fileOut.close();
---------------------- ----------------------
// ( D )
String filename = "D:\\Test.xls";
FileInputStream fi = null;//
POIFSFileSystem fs = null;//
HSSFWorkbook wb = null;
HSSFSheet sheet = null;
fi = new FileInputStream(filename);
fs = new POIFSFileSystem(fi);
wb = new HSSFWorkbook(fs);
sheet = wb.getSheetAt(0);
int count = sheet.getLastRowNum() + 1;
System.out.println(" ==" + count);
HSSFCell cell = null;
for (int i = 1; i < count; i++) {// ,
HSSFRow hssfRow = sheet.getRow(i); //
HSSFCell xm = hssfRow.getCell((short) 0);//
String value = String.valueOf(xm.getStringCellValue());//
//
}
fi.close();