---
title: "poi兼容excel2003和2007写法"
author: "_____bEn-beN"
date: "2015-01-19T15:45:28Z"
tags: []
categories: ["编程语言"]
slug: "poi-excel2003-2007"
draft: false
lastmod: "2015-01-19T15:45:28Z"
id: 2177296
url: "https://510891769.iteye.com/blog/2177296"
---

//创建excel文件薄对象

            Workbook workBook;

            

            fileInputStream = new FileInputStream(phonesUrl);

            

            try 

            {

                //读取exl 2007

                workBook = new XSSFWorkbook(fileInputStream);

            } 

            catch (Exception ex) 

            {

                //读取exl 2003

                fileInputStream.close();

                fileInputStream = new FileInputStream(phonesUrl);

                workBook = new HSSFWorkbook(fileInputStream);

            }