
已解决问题
谷歌womeiwh用户在2013.09.09提交了关于“2046j**a中for循环里的冒号”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-10-25T20:48:10。importj**a.io.FileInputStream;importj**a.io.FileOutputStream;
importj**a.io.IOException;
importj**a.io.InputStream;
importj**a.io.OutputStream;
importorg.apache.poi.hssf.usermodel.h**SSFWorkbook;
importorg.apache.poi.ss.usermodel.Cell;
importorg.apache.poi.ss.usermodel.Row;
importorg.apache.poi.ss.usermodel.Sheet;
importorg.apache.poi.ss.usermodel.Workbook;
importorg.apache.poi.xssf.usermodel.XSSFWorkbook;
publicclasspair{
publicstaticvoidmain(String[]args)throwsIOException{
Stringpath="y:/";
StringfileName="abc";
StringfileType="xlsx";
//writer(path,fileName,fileType);
read(path,fileName,fileType);
}
publicstaticvoidread(Stringpath,StringfileName,StringfileType)throwsIOException
{
InputStreamstream=newFileInputStream(path+fileName+"."+fileType);
Workbookwb=**ll;
if(fileType.equals("xls")){
wb=newh**SSFWorkbook(stream);
}
elseif(fileType.equals("xlsx")){
wb=newXSSFWorkbook(stream);
}
else{
System.out.println("Wrongexcelformat");
}
Sheetsheet1=wb.getSheetAt(0);
for(Rowrow:sheet1){
for(Cellcell:row){
System.out.print(cell.getNumericCellValue()+"");
}
System.out.println();
}
}
}
这其中的
for(Rowrow:sheet1){
for(Cellcell:row)
是什么意思,用比较笨的传统的for循环应该怎么写?求高手指导!急求!谢谢希望大家能够帮助她。
详细问题描述及疑问:importj**a.io.FileInputStream;
importj**a.io.FileOutputStream;
importj**a.io.IOException;
importj**a.io.InputStream;
importj**a.io.OutputStream;
importorg.apache.poi.hssf.usermodel.h**SSFWorkbook;
importorg.apache.poi.ss.usermodel.Cell;
importorg.apache.poi.ss.usermodel.Row;
importorg.apache.poi.ss.usermodel.Sheet;
importorg.apache.poi.ss.usermodel.Workbook;
importorg.apache.poi.xssf.usermodel.XSSFWorkbook;
publicclasspair{
publicstaticvoidmain(String[]args)throwsIOException{
Stringpath="y:/";
StringfileName="abc";
StringfileType="xlsx";
//writer(path,fileName,fileType);
read(path,fileName,fileType);
}
publicstaticvoidread(Stringpath,StringfileName,StringfileType)throwsIOException
{
InputStreamstream=newFileInputStream(path+fileName+"."+fileType);
Workbookwb=**ll;
if(fileType.equals("xls")){
wb=newh**SSFWorkbook(stream);
}
elseif(fileType.equals("xlsx")){
wb=newXSSFWorkbook(stream);
}
else{
System.out.println("Wrongexcelformat");
}
Sheetsheet1=wb.getSheetAt(0);
for(Rowrow:sheet1){
for(Cellcell:row){
System.out.print(cell.getNumericCellValue()+"");
}
System.out.println();
}
}
}
这其中的
for(Rowrow:sheet1){
for(Cellcell:row)
是什么意思,用比较笨的传统的for循环应该怎么写?求高手指导!急求!谢谢期待您的答案,你无异于雪中送炭,让我感激涕零
!