試圖編寫一個方法從單元讀取數據並將其轉換爲字符串。 方法: 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()是未定義默認構造函數。必須定義一個明確的構造函數