试图编写一个方法从单元读取数据并将其转换为字符串。 方法: p默认构造函数未定义隐式超级构造函数getdata()。必须定义一个明确的构造函数
ublic class getStringValue {
public getStringValue(Cell cell) {
}
String display()
{
Cell cell = null;
DataFormatter df = new DataFormatter();
String value = df.formatCellValue(cell);
return value;
}
}
calling the method in another class
public class acessUser extends getdata {
void login(String filepath ,String filename ,String sheetname) throws IOException{
File file = new File(filepath + "\\"+ filename) ;
FileInputStream datafile = new FileInputStream(file);
HSSFWorkbook wb = new HSSFWorkbook (datafile);
Sheet sh = wb.getSheet(sheetname);
int rownum = sh.getLastRowNum()+1;
int colnum = sh.getRow(0).getLastCellNum();
String [][] data = new String [rownum][colnum];
for (int i=0 ; i< rownum ; i++)
{
Row row = sh.getRow(i);
for (int j =0 ; j < colnum ; j ++)
{
Cell cell = row.getCell(j);
getStringValue gt = new getStringValue(cell);
String value = gt.display();
//java.lang.String value = cell.getStringCellValue();
data[i][j]=value;
System.out.println(value);
//String ui = data[i][j];
}
}
}
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
acessUser n = new acessUser();
n.login("A:\\selenium", "selenium.xls", "sheet1");
}
}
错误: - 例外在线程 “主要” java.lang.Error的:未解决的问题,编译: 隐超构造的GetData()是未定义默认构造函数。必须定义一个明确的构造函数