java操作excel,下载poi jar包

输出excel的某个单元格

对于Excel文件的后缀名是xls的情况

需要下载jar包poi,网址:

                https://www.apache.org/dyn/closer.lua/poi/release/bin/poi-bin-4.1.1-20191023.zip

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class excelread {
	
	public static void main(String[] args) throws FileNotFoundException, IOException {
		//得到Excel工作簿对象 
		//POIFSFileSystem fs=new POIFSFileSystem(new FileInputStream("D:/briup/hadoop-eclipse/test/litest.xlsx"));
		//得到Excel工作表对象
		XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream("D:/briup/hadoop-eclipse/test/litest.xlsx")); 
		//根据index取得sheet对象
		XSSFSheet sheet = wb.getSheetAt(0); 
		//取得有效的行数
		int rowcount = sheet.getLastRowNum(); 
		for(int i=0;i<rowcount;i++){
			//获取第三列
			Row row = sheet.getRow(i);
			//转换成string
			if(row != null){
                int columNos = row.getLastCellNum();
                Cell cell = row.getCell(3);
                String er = cell.toString();
                System.out.println(er);
                }
            }
		}
	}
	 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值