package yuebao;import java.io.*;
import java.text.DateFormat;import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;public class CallRecord
{
public static void main(String[] args)
{
POIFSFileSystem pfs=null;
HSSFWorkbook hwb=null;
try
{
pfs=new POIFSFileSystem(new FileInputStream("07-06-28-07-07-27.xls"));
hwb=new HSSFWorkbook(pfs);
HSSFSheet sheet=hwb.getSheetAt(0);
System.out.println(sheet.getRow(4).getCell((short)1).toString());
HSSFCell cl=sheet.getRow(5).getCell((short)1);
System.out.println(Integer.parseInt(cl.toString().trim()));
FileOutputStream fos=new FileOutputStream("07-06-28-07-07-27.xls");
hwb.write(fos);
fos.flush();
fos.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
} }
} 执行到一半就出现异常提示:NumberFormatException,
发生异常的地方是System.out.println(Integer.parseInt(cl.toString().trim()));我的excel表中的数据格式为“常规”格式,实在不明白是出现了什么问题
import java.text.DateFormat;import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;public class CallRecord
{
public static void main(String[] args)
{
POIFSFileSystem pfs=null;
HSSFWorkbook hwb=null;
try
{
pfs=new POIFSFileSystem(new FileInputStream("07-06-28-07-07-27.xls"));
hwb=new HSSFWorkbook(pfs);
HSSFSheet sheet=hwb.getSheetAt(0);
System.out.println(sheet.getRow(4).getCell((short)1).toString());
HSSFCell cl=sheet.getRow(5).getCell((short)1);
System.out.println(Integer.parseInt(cl.toString().trim()));
FileOutputStream fos=new FileOutputStream("07-06-28-07-07-27.xls");
hwb.write(fos);
fos.flush();
fos.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
} }
} 执行到一半就出现异常提示:NumberFormatException,
发生异常的地方是System.out.println(Integer.parseInt(cl.toString().trim()));我的excel表中的数据格式为“常规”格式,实在不明白是出现了什么问题
解决方案 »
- 正则表达式匹配一串字符串中出现的第一个字母
- Socket编程问题,帮忙看看。
- com.sun.jdi.InvocationException,这个异常是什么意思???
- 有没有人用过adventNet SNMP API 做过SNMP网络监控程序?
- 用什么方法删除JTextArea其全部内容??
- 求:java随机函数详解 在线等
- 为什么我的Class.forName("oracle.jdbc.driver.OracleDriver")总是抛出ClassNotFoundException啊?
- 我不明白微软为什么要跟着java学习虚拟机,难道windows一定要越慢越值钱吗?
- 谢谢大家,200分已经结帖,现在又100分提问
- 请问如何使IE支持有swing的aaplet?
- 使用java poi操作excel表,如何将单元格的格式设置为百分比或数值等格式
- readLine()是循环地往下读取行数据,怎么样才能在读取的过程中返回到首行呢,我不想重复打开和关闭文件
看看cl是什么
然后看是每个cl都出错还是特定的那个有错
理论上是可以用cl.getStringCellValue()来获取某一单元格的值的,但是修改成
sheet.getRow(4).getCell((short)1).toString().getStringCellValue()
时却根本得不到值