public static double[] read2(String filepath, int row, int lie) throws IOException, BiffException, WriteException {
InputStream stream = new FileInputStream(filepath);
Workbook rwb = Workbook.getWorkbook(stream);
Sheet sheet = rwb.getSheet("Sheet2");
int rows = row;
int cols = lie;
double[] array = new double[rows];
for (int i = 1; i < row + 1; i++) {
Cell cell= sheet.getCell(lie - 1, i);
NumberCell nc = (NumberCell) cell;
double value = nc.getValue();
//double value = Double.valueOf(cell.getContents());
array[i - 1] = value;
}
return array;
}
原始代码:
public static double[] read1(String filepath, int lie) throws IOException, BiffException, WriteException {
InputStream stream = new FileInputStream(filepath);
Workbook rwb = Workbook.getWorkbook(stream);
Sheet sheet = rwb.getSheet("Sheet2");
int rows = sheet.getRows();
int cols = lie;
double[] array = new double[rows - 1];
for (int i = 1; i < sheet.getRows(); i++) {
Cell cell= sheet.getCell(lie - 1, i);
double value = Double.valueOf(cell.getContents());
array[i - 1] = value;
}
return array;
}