Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - When java is imported into excel, if the file exceeds 100k, an error will be reported, and if it is tens of kilos, there will be no problem. The data in the two EXCELs are the same.
When java is imported into excel, if the file exceeds 100k, an error will be reported, and if it is tens of kilos, there will be no problem. The data in the two EXCELs are the same.
Import excel locally and convert it into an array. Uploads above 1M are not reported as errors.

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();

}

}

}