1.要想对Excel进行读取,修改,删除等操作,需要先导入jxl包
2.
想要输出上面Excel的内容,具体代码如下:
package selenium3;
import java.io.File;
import java.io.IOException;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class test005 {
public static void main(String[] args) throws BiffException, IOException{
Workbook book = Workbook.getWorkbook(new File("D:\\1.xls"));
Sheet sheet = book.getSheet(0);
int rows = sheet.getRows();
int columns = sheet.getColumns();
for(int i=0;i<rows;i++){
for(int j=0;j<columns;j++){
System.out.println(sheet.getCell(j, i).getContents());
}
}
}
}
输出结果为: