hssf workbook workbook = new hssf workbook(new file inputstream(
file path));
hssf sheet sheet = workbook . get sheet at(0);
int rows = sheet . getphysicalnumberrows();
If (line number & gt0) {
int cells = sheet.getRow(0)。 getPhysicalNumberOfCells();
for(int r = 0; R< line; r++) {
HSS row row = sheet . getrow(r);
String[] cellsvalue = new string [cells+1];
For (short c = 0;; C< cells; c++) {
String value = "";
hssf cell cell = row . get cell(c);
If (cells! = null) {
switch (cell.getCellType()) {
Case HSSFCell. Cell type formula:
//
Break;
Case HSSFCell. Cell type value:
if(hssfdateutil . iscelldateformated(cell)){
value = new Java . text . simple date format(" yyyy-MM-DD ")。 format(cell . getdatecellvalue());
date date = cell . getdatecellvalue();
value =(date . getyear()+ 1900)+"-"+(date . getmonth()+ 1)+"-"+date . getdate();
} Otherwise {
Value = String.valueOf (cell
. getNumericCellValue());
}
Break;
Case HSSFCell. Cell type string:
value = cell . getstringcellvalue();
Break;
Case HSSFCell. Cell _ Type _ Blank:
Value = "";
Default value:
Break;
}
if (cell == null) {
Value = "";
}
}
Cellsvalue[c] = value;
}
S[r] = cell value;
Java . io . file my file = new Java . io . file(file path);
if (myfile.exists()) {
my file . delete();
}
}
}