今天遇到一个poi导入的问题 参考别人的写了一个

package com.rshz.excel.derive;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

public class Excels {
	public static void main(String arg[]){
		 mx();
	}
	
	public static void mx(){
		HSSFWorkbook workbook=null;
		HSSFSheet sheet=null;

		FileInputStream in=null;
		try {
			in=new FileInputStream("E:"+File.separator+"你好.xlsx");
			workbook=new HSSFWorkbook(in);
			sheet=workbook.getSheetAt(0);
			Iterator<Row> it=sheet.rowIterator();
			while(it.hasNext()){
				HSSFRow row=(HSSFRow) it.next();
				Iterator<Cell> tor=row.cellIterator();
				while(tor.hasNext()){
					HSSFCell cl=(HSSFCell)tor.next();
					if(cl.getCellType()==Cell.CELL_TYPE_STRING){
						System.out.print(cl.getStringCellValue()+"\t");
					}else if(cl.getCellType()==Cell.CELL_TYPE_NUMERIC){
						System.out.print(cl.getNumericCellValue()+"\t");
					}else if(cl.getCellType()==Cell.CELL_TYPE_FORMULA){
						
					}else if(cl.getCellType()==Cell.CELL_TYPE_BLANK){
						
					}
				}
				System.out.println();
			}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}catch (IOException e) {
			e.printStackTrace();
		}
	}
}





输出结果:


性别 年龄 生日
李四 25.78 八月二十号
张三 26.3 四月三号


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值