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. AutoCAD菜单加载失败 找不到文件mnc 怎么办

    菜单加载失败,找不到文件 SWFILECONV(mnu/mns/mnc)   找到CAD安装目录下的swfileconv.arx文件,用记事本打开,清空内容,然后保存即可.  

  2. YII数据流程浅析

    MVC就不解释,直接上代码分析数据流程: 数据库图: 模型部分介绍: <?php /* * 前两个方法必须写 * 继承自CActiveRecord类 这个类位于 \framework\db\ar ...

  3. ZOJ 3684 Destroy 树的中心

    中心节点就是树的中心,2遍dfs求到树的直径.而中心一定在直径上,顺着直径找到中心就够了. 然后能够一遍树形DP找到最小值或者二分+推断是否訪问到叶子节点. #include <iostream ...

  4. 中文分词实践(基于R语言)

    背景:分析用户在世界杯期间讨论最多的话题. 思路:把用户关于世界杯的帖子拉下来.然后做中文分词+词频统计,最后将统计结果简单做个标签云.效果例如以下: 兴许:中文分词是中文信息处理的基础.分词之后.事 ...

  5. hdu 4990 Reading comprehension(等比数列法)

    题目链接:pid=4990" style="color:rgb(255,153,0); text-decoration:none; font-family:Arial; line- ...

  6. VS-按F12无法跳转到函数定义,点击右键也无法跳转

    工具->选项->项目和解决方案->常规,把“在解决方案资源管理器中跟踪活动项”反选.

  7. go语言--time.After

    go语言--time.After https://blog.csdn.net/cyk2396/article/details/78873396 1.源码分析: // After waits for t ...

  8. C的结构体函数

    #include<stdio.h> #include<string.h> struct Test { int age; ]; double score; }std1; //结构 ...

  9. java用户角色权限设计

    实现业务系统中的用户权限管理 B/S系统中的权限比C/S中的更显的重要,C/S系统因为具有特殊的客户端,所以访问用户的权限检测可以通过客户端实现或通过客户端+服务器检测实现,而B/S中,浏览器是每一台 ...

  10. 13.Ext.extend用法以及代码解读

    转自:http://www.blogjava.net/dragonshrimp/archive/2008/03/01/183060.html Ext.extend用法以及代码解读 概述 Ext.ext ...