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的更多相关文章

  1. Java读取txt文件、excel文件的方法

    Java读取txt文件.excel文件的方法 1.读取txt文件 public static String getFileContent(String filePath,String charset) ...

  2. PHPExcel读取excel03/07版到数组

    想总结下PHPExcel的读取excel到数组的function,用的时候直接调取,懒…… 参考了以下链接: http://www.jb51.net/article/29071.htm http:// ...

  3. 第四篇:java读取Excel简单模板

    场景:对于经常需要导入Excel模板或数据来解析后加以应用的,使用频率非常之高,做了一个比较稳定的版本,体现在这些地方工具:org.apache.poi使用前必须了解这些:1.要解析,那肯定先判断是不 ...

  4. [转] JAVA读取excel数据(插入oracle数据库)

    原文地址:http://blog.csdn.net/zczzsq/article/details/16803349 本实例做的是读取execl(只能读取.xls的execl,即只能读取03版的),如果 ...

  5. 原!操作 excel 03/07

    参考 所用jar包: poi-3.11.jar poi-ooxml-3.11.jar poi-ooxml-schemas-3.11.jar /* * Project: fusion-may-open- ...

  6. Java读取、写入、处理Excel文件中的数据(转载)

    原文链接 在日常工作中,我们常常会进行文件读写操作,除去我们最常用的纯文本文件读写,更多时候我们需要对Excel中的数据进行读取操作,本文将介绍Excel读写的常用方法,希望对大家学习Java读写Ex ...

  7. NPOI 导入导出excel 支持 03 07

    因为微软的office成本太高了,所以开发项目的时候电脑上没安装office,而是安装了wps.但开发语言用的是C#,所以直接调用微软的office组件是很方便的,但一方面慢,一方面成本高,所以从网上 ...

  8. java 读取excel poi 和cell 方法

    http://poi.apache.org/spreadsheet/quick-guide.html http://www.aspose.com/docs/display/cellsjava/Eval ...

  9. java 读取excel内容转为JSONArray

    需要引入的JAR     <!--*.xls--> <dependency> <groupId>net.sourceforge.jexcelapi</grou ...

随机推荐

  1. [React] Spread Component Props in JSX with React

    You often find duplication between the name of a prop and a variable you will assign to the prop. JS ...

  2. Android 圆形/圆角图片的方法

    Android 圆形/圆角图片的方法 眼下网上有非常多圆角图片的实例,Github上也有一些成熟的项目.之前做项目,为了稳定高效都是选用Github上的项目直接用.但这样的结束也是Android开发必 ...

  3. Xubuntu 计划从 19.04 版本开始停止提供 32 位安装镜像(XDE/LXQt的 Lubuntu 成为了目前唯一仍然提供 32 位安装镜像的 Ubuntu 桌面发行版)

    Ubuntu 17.10 以及其他许多 *buntu 衍生品都已在今年早些时候停止提供 32 位安装镜像.但其中有一个依然坚持提供适用于 i386 架构的镜像,它就是 Xubuntu,但现在 Xubu ...

  4. HDU5806 NanoApe Loves Sequence Ⅱ

    NanoApe Loves Sequence Ⅱ Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/131072 K (Ja ...

  5. 自定义的Notification

    要创建一个自定义的Notification,可以使用RemoteViews.要定义自己的扩展消息,首先要初始化一个RemoteViews对象,然后将它传递给Notification contentVi ...

  6. bzoj 4337 树的同构

    4337: BJOI2015 树的同构 Description 树是一种很常见的数据结构. 我们把N个点,N-1条边的连通无向图称为树. 若将某个点作为根,从根开始遍历,则其它的点都有一个前驱,这个树 ...

  7. Redis: Redis on Windows Setup

    ylbtech-Redis: Redis on Windows Setup 1.返回顶部 1. 2. 3. 4. 5. 6. 7. 8. 9. 2.返回顶部   3.返回顶部   4.返回顶部   5 ...

  8. linux下解压zip文件时,文件名乱码的解决(转载)

    转自:http://blog.sina.com.cn/s/blog_6261f8690101c1gx.html windows下的zip文件,在linux下解压时,经常会出现文件名乱码的情况. 主要原 ...

  9. PCB 机器学习(ML.NET)初体验实现PCB加投率预测

    使用ML.NET建立PCB加投率模型对单一蚀刻工序进行加投率预测, 此实例为最简单预测,要想实现全流程加投率预测挑战难度还是挺大的,可以查看另一种关于大数据在PCB行业应用---加投率计算基本原理:P ...

  10. P4097 [HEOI2013]Segment

    传送门 简单来说就是对于每条线段,先把它拆成\(O(logn)\)条,然后对于每一条再\(O(logn)\)判断在所有子区间的优劣程度 //minamoto #include<bits/stdc ...