java读取03、07版EXCEL
03版excel,需要用到jxl.jar这个jar包
package test.poi; import java.io.File;
import java.io.IOException; import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException; //03版excel
public class getExcel {
public static void main(String[] args){
show03Excel();
}
public static void show03Excel(){
Sheet sheet;
Workbook book = null;
try {
book= Workbook.getWorkbook(new File("F:\\Book1.xls"));
} catch (BiffException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// System.out.println(book);
//获得第一个工作表对象(ecxel中sheet的编号从0开始,0,1,2,3,....)
sheet=book.getSheet(0);
int rows = 0;
int r=0,l=0;
String value=null;
while(sheet.getCell(0,r).getContents()!=""&&sheet.getCell(0,r).getContents()!=null){
r++;
}
while(sheet.getCell(l,0).getContents()!=""&&sheet.getCell(l,0).getContents()!=null){
l++;
}
for(int i=0;i<(r);i++){
for(int j=0;j<(l);j++)
System.out.print(sheet.getCell(j,i).getContents()+"\t\t");
System.out.println();
}
}
}
07版EXCEL,需要用到poi这个jar包
package test.poi; import java.io.IOException; import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class get07Excel {
public static void main(String[] arg){
show07excel();
}
public static void show07excel(){
XSSFWorkbook xwb =null;
try {
xwb= new XSSFWorkbook("F:\\Book1.xlsx");
} catch (IOException e) {
e.printStackTrace();
}
XSSFSheet sheet=xwb.getSheetAt(0);
XSSFRow row;
String cell;
int r=0,l=0;
row = sheet.getRow(0);
while(row.getCell(l).toString()!=""&&row.getCell(l).toString()!=null){
l++;
}
while(row.getCell(0).toString()!=""&&row.getCell(0).toString()!=null){
r++;
row = sheet.getRow(r);
}
System.out.println("the rows is "+r+" and the number of one row is "+l);
// 循环输出表格中的内容
for (int i = sheet.getFirstRowNum(); i < r; i++)
{
row = sheet.getRow(i);
for (int j = row.getFirstCellNum(); j < l; j++)
{
cell = row.getCell(j).toString();
System.out.print(cell + "\t");
}
System.out.println("");
}
}
}
java读取03、07版EXCEL的更多相关文章
- Java读取txt文件、excel文件的方法
Java读取txt文件.excel文件的方法 1.读取txt文件 public static String getFileContent(String filePath,String charset) ...
- PHPExcel读取excel03/07版到数组
想总结下PHPExcel的读取excel到数组的function,用的时候直接调取,懒…… 参考了以下链接: http://www.jb51.net/article/29071.htm http:// ...
- 第四篇:java读取Excel简单模板
场景:对于经常需要导入Excel模板或数据来解析后加以应用的,使用频率非常之高,做了一个比较稳定的版本,体现在这些地方工具:org.apache.poi使用前必须了解这些:1.要解析,那肯定先判断是不 ...
- [转] JAVA读取excel数据(插入oracle数据库)
原文地址:http://blog.csdn.net/zczzsq/article/details/16803349 本实例做的是读取execl(只能读取.xls的execl,即只能读取03版的),如果 ...
- 原!操作 excel 03/07
参考 所用jar包: poi-3.11.jar poi-ooxml-3.11.jar poi-ooxml-schemas-3.11.jar /* * Project: fusion-may-open- ...
- Java读取、写入、处理Excel文件中的数据(转载)
原文链接 在日常工作中,我们常常会进行文件读写操作,除去我们最常用的纯文本文件读写,更多时候我们需要对Excel中的数据进行读取操作,本文将介绍Excel读写的常用方法,希望对大家学习Java读写Ex ...
- NPOI 导入导出excel 支持 03 07
因为微软的office成本太高了,所以开发项目的时候电脑上没安装office,而是安装了wps.但开发语言用的是C#,所以直接调用微软的office组件是很方便的,但一方面慢,一方面成本高,所以从网上 ...
- java 读取excel poi 和cell 方法
http://poi.apache.org/spreadsheet/quick-guide.html http://www.aspose.com/docs/display/cellsjava/Eval ...
- java 读取excel内容转为JSONArray
需要引入的JAR <!--*.xls--> <dependency> <groupId>net.sourceforge.jexcelapi</grou ...
随机推荐
- Maven+Mybatis+Spring+SpringMVC实现分页查询(附源代码)
以下小宝鸽将分享一篇Mybatis分页功能的博文,以下将给出具体的步骤.跟着博主的节奏肯定能实现.另外最后还会附上整个project的源代码.假设是没有使用过maven的猿友可自行下载相关的jar包就 ...
- Eclipse插件开发中的选择监听机制(Selection Provider-Listener)
Eclipse插件开发中的选择监听机制(Selection Provider-Listener) 监听机制是eclipse插件开发或rcp应用开发中经常使用的技术,比方点击TableViewer或Tr ...
- chrome.socket
chrome.socket https://chajian.baidu.com/developer/apps/socket.html#method-create 描述: 使用 chrome.socke ...
- mysql数据库批量高速插入
近期在处理一批数据,须要从库中表里的字段进行处理然后导出到一个新表中.只是这个表的数据量有近500w条. 这数据量出现的的问题是须要处理的时间好长. 首先想到,一句一句的插入,大数据量处理时间好长,忽 ...
- Zend Studio如何调试?
1.安装Zend Studio之前,本机已安装Apache2.如果使用Apache2作为服务器 Window-Preferences-Php-Php Servers 配置好 URL和Server Ro ...
- 依赖注入【转自知乎 PHP】
第一章:小明和他的手机 从前有个人叫小明 小明有三大爱好,抽烟,喝酒…… 咳咳,不好意思,走错片场了.应该是逛知乎.玩王者农药和抢微信红包 <img src="https://pic1 ...
- 关于移动平台的viewport
viewport是用来设置移动平台上的网页宽度,写device-width比较好,不然会和设备上不一样 在使用device-width之后,图片资源最好使用百分比布局,进行自动缩放. 文字大小是一样的 ...
- html5 canvas程序演示--P1197 [JSOI2008]星球大战
html5 canvas程序演示--P1197 [JSOI2008]星球大战 <!doctype html> <html> <head> <meta char ...
- .net 接收存储过程的返回值 。。。。
.net 接收存储过程的返回值 .... Posted on 2009-06-10 20:26 且行且思 阅读(...) 评论(...) 编辑 收藏 例如在向数据库添加新数据时,需要检测是否有重复 本 ...
- 配置文件git config介绍
Git有一个工具被称为git config,它允许你获得和设置配置变量:这些变量可以控制Git的外观和操作的各个方面. 一. 配置文件的存储位置 这些变量可以被存储在三个不同的位置: 1./etc/g ...