/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
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.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.util.CellRangeAddress;
/**
* File for HSSF testing/examples
*
* THIS IS NOT THE MAIN HSSF FILE!! This is a utility for testing functionality.
* It does contain sample API usage that may be educational to regular API
* users.
*
* @see #main
* @author Andrew Oliver (acoliver at apache dot org)
*/
public final class HSSFReadWrite {
/**
* creates an {@link HSSFWorkbook} the specified OS filename.
*/
public static void main(String[] args) throws IOException
{
try {
InputStream input = new FileInputStream("d:\\poi.xls");
POIFSFileSystem fs = new POIFSFileSystem(input);
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
// Iterate over each row in the sheet
Iterator rows = sheet.rowIterator();
while (rows.hasNext()) {
HSSFRow row = (HSSFRow) rows.next();
// Iterate over each cell in the row and print out the cell"s
// content
Iterator cells = row.cellIterator();
while (cells.hasNext()) {
HSSFCell cell = (HSSFCell) cells.next();
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:
System.out.print(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_STRING:
System.out.print(cell.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
System.out.print(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_FORMULA:
System.out.print(cell.getCellFormula());
break;
default:
System.out.print("unsuported sell type");
break;
}
} System.out.println();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
分享到:
相关推荐
利用POI读取excel写入到word 利用POI读取excel写入到word 利用POI读取excel写入到word,压缩包里包含了jar包
poi读写excel,poi总结; poi读写excel,poi总结 poi读写excel,poi总结
JAVA IO操作 POI读取excel的内容
poi读取excel所需jar包,可用来使用poi读写word excel。
poi读取excel并输出到jsp页面
POI读取Excel
NULL 博文链接:https://yxhcquedu.iteye.com/blog/828707
POI读写excel(.xls/.xlsx)的Demo,直接import到myeclipse即可运行。 IDE:myeclipse 9.1 含jar包
实现了JAVA 窗口,读取EXCEL文件,用poi读取EXCEL内容只是一个小例子
apache poi 读取 Excel 的 jar 包 博文链接:https://wxinpeng.iteye.com/blog/231895
POI生成Excel POI读取Excel java操作Excel Servlet生成Excel web项目,包含含读取Excel与生成Excel方法
poi读写excel表的实例,用java实现,在eclipse里直接运行
POI读写excel文件+poi简单文档; POI读写excel文件+poi简单文档。
POI读取excel的例子
本案例中利用Apache Poi读取Excel用法,源码注释详细基本用法!
poi读取excel2007和2003兼容工具例子.利用简单工厂方法
解决poi读取excel2007出现内存溢出问题代码参
之前用jxl发现不支持excel2007,不得以就去用poi实现excel的读取了!本人亲测的一个实例,支持excel2007!
android5使用poi读取excel,android5使用poi读取excel,android5使用poi读取excel,android5使用poi读取excel