我的代码运行正常,但它显示列标题(用户名,密码)...如何更改我的代码,只能接受值而不是标题....
public Object [][] readExcel() throws BiffException,IOException
{
//Create file instance
File f = new File("T:/SeleniuminputFiles/input1.xls");
Workbook w = Workbook.getWorkbook(f);
Sheet s = w.getSheet("Sheet1");
int rows = s.getRows();
int column =s.getColumns();
String inputData [][] = new String [rows][column];
for (int i = 0; i < rows; i++ ) {
for (int j = 0; j <column; j++) {
Cell c = s.getCell(j, i);
inputData[i][j] = c.getContents();
System.out.println(inputData[i][j]);
}
}
return inputData;
}
我的Excel文件在下面给出,在输出中我不希望列标题用户名,密码被读出。
非常感谢任何帮助。
答案 0 :(得分:0)
我在你的for循环中做了一些改动。它应该工作。
for (int i = 1; i < rows; i++ ) {
for (int j = 0; j <column; j++) {
Cell c = s.getCell(i, j);
inputData[i-1][j] = c.getContents();
System.out.println(inputData[i][j]);
}
}