`
goto0917
  • 浏览: 46634 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论
  • take: 这是POI方式,不是JXLS方式. JXLS包路径都是net ...
    jxls

read excel

阅读更多
public class ReadExcel {
	public static void main(String[] args) throws Exception {
		InputStream is = new FileInputStream(new File("c://SummaryHSSF.xls"));
		//根据输入流创建Workbook对象
		Workbook wb = WorkbookFactory.create(is);
		//get到Sheet对象
		Sheet sheet = wb.getSheetAt(0);
		//这个必须用接口
		for(Row row : sheet){
			for(Cell cell : row){
				//cell.getCellType是获得cell里面保存的值的type
				//如Cell.CELL_TYPE_STRING
				switch(cell.getCellType()){
					case Cell.CELL_TYPE_BOOLEAN:
						//得到Boolean对象的方法
						System.out.print(cell.getBooleanCellValue()+" ");
						break;
					case Cell.CELL_TYPE_NUMERIC:
						//先看是否是日期格式
						if(DateUtil.isCellDateFormatted(cell)){
							//读取日期格式
							System.out.print(cell.getDateCellValue()+" ");
						}else{
							//读取数字
							System.out.print(cell.getNumericCellValue()+" ");
						}
						break;
					case Cell.CELL_TYPE_FORMULA:
						//读取公式
						System.out.print(cell.getCellFormula()+" ");
						break;
					case Cell.CELL_TYPE_STRING:
						//读取String
						System.out.print(cell.getRichStringCellValue().toString()+" ");
						break;					
				}
			}
			System.out.println("");
		}
	}
}
分享到:
评论

相关推荐

    Read Excel

    是关于读去excel中的数据,并且把excel中的信息封装到一个对象中。

    ReadExcel.zip

    使用vs2012开发,C# winform 可视化操作选择Excel文件并读取内容显示到DataTable

    lua read excel

    lua读取excel,用于批量数据的读写

    ReadExcel.rar

    use qt software to read excel data QT读取EXCEL表格数据并进行显示的两种方法,具体描述参考博客https://blog.csdn.net/import_new/article/details/117003163,这是完整的QT源码,欢迎学习交流

    readexcel.rar

    Using the QT software to open excel

    DXL_ReadExcel.exe

    该小工具功能为提取指定EXCEL文件中指定区域内的数据,并且可以重新导出为EXCEL文件。帮助他人提高工作效率

    ReadExcel.unitypackage

    Unity读取Excel,包括一个简单的Demo和必要的dll文件。谢谢下载!谢谢下载!谢谢下载!谢谢下载!谢谢下载!

    C#readExcel

    C# excel read oledb dataset

Global site tag (gtag.js) - Google Analytics