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 ...
随机推荐
- Yarn 的工作流-创建一个新项目
Microsoft Windows [版本 10.0.16299.125] (c) Microsoft Corporation.保留所有权利. C:\Users\Administrator>cd ...
- django 名词解释
1) 什么是slug http://stackoverflow.com/questions/427102/what-is-a-slug-in-django 如上链接红色部分就是slug,它就是链接的最 ...
- Hadoop之——HBASE结合MapReduce批量导入数据
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46463889 废话不多说.直接上代码,你懂得 package hbase; imp ...
- Linux 编译C++ 与 设置 Vim
1. Linux 下编译c++ vim test.cpp // 创建文件 g++ test.cpp // 编译文件 ./a.out // 执行文件 g++ test.cpp ...
- 中文分词实践(基于R语言)
背景:分析用户在世界杯期间讨论最多的话题. 思路:把用户关于世界杯的帖子拉下来.然后做中文分词+词频统计,最后将统计结果简单做个标签云.效果例如以下: 兴许:中文分词是中文信息处理的基础.分词之后.事 ...
- 大文本 通过 hadoop spark map reduce 获取 特征列 的 属性值 计算速度
大文本 通过 hadoop spark map reduce 获取 特征列 的 属性值 计算速度
- 在64位的ubuntu 14.04 上开展32位Qt 程序开发环境配置(pro文件中增加 QMAKE_CXXFLAGS += -m32 命令)
为了能中一个系统上开发64或32位C++程序,费了些周折,现在终于能够开始干过了.在此记录此时针对Q5.4版本的32位开发环境配置过程. 1. 下载Qt 5.4 的32位版本,进行安装,安装过程中会发 ...
- 加密散列算法——SHA-1
与MD5算法类似,SHA-1算法也是在接收到消息后产生消息摘要,能够用来验证数据的完整性. 不同的是SHA1会产生一个160位的消息摘要(MD5产生的是128位). 其它的性质之类的不多说(请參考前面 ...
- Aaron Swartz Rewriting Reddit中关于web.py的创建思路
这天才少年居然自杀了,哎 原文点这 So how should things work? The first principle is that code should be clear and si ...
- 怎么在当前的view上获取所在的控制器(UIViewController),实现跳转
- (UIViewController *)viewController { for (UIView* next = [self superview]; next; next = next.super ...