我用java读取一个简单的Execl文件,是成功的,但是一个复杂的Exec就不行了,错误如下:
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space代码如下:
public static void reader(File file,String sheet,int startrow) throws Exception{
String trans_execl_id="";
InputStream isProduct = new FileInputStream(file);
Workbook rwb = Workbook.getWorkbook(isProduct);
Sheet st = rwb.getSheet(sheet);
int excelRows = st.getRows();
System.out.println("Total rows: " + (excelRows - startrow));
for(int i = startrow; i < excelRows; i++){
trans_execl_id = st.getCell(0, i).getContents(); //序号
}
rwb.close();
isProduct.close();
}
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Warning: Shared template formula is null - trying most recent formula template
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space代码如下:
public static void reader(File file,String sheet,int startrow) throws Exception{
String trans_execl_id="";
InputStream isProduct = new FileInputStream(file);
Workbook rwb = Workbook.getWorkbook(isProduct);
Sheet st = rwb.getSheet(sheet);
int excelRows = st.getRows();
System.out.println("Total rows: " + (excelRows - startrow));
for(int i = startrow; i < excelRows; i++){
trans_execl_id = st.getCell(0, i).getContents(); //序号
}
rwb.close();
isProduct.close();
}
解决方案 »
- hibernate处了hbm.xml的映射之外,还可以标注映射.这个标注映射可以自动生成吗?
- 向高手请教如何读取XML文件,然后将标签内的值拼成一个字符串
- struts部署到WebLogic 出现ActionServlet找不到
- JSP连接MySQL问题
- byte[] To String 大家有什么好的编码方法(except BASE64)
- 哪位大哥有论坛的源代码?
- 我的SERVLET为何不能响应?
- 请教:该如何在客户端和服务器端之间传递对象?
- 是不是只有查询需要关闭结果集?其他的如,增、删、改不需要关闭结果集?
- JavaWeb生成路径的选择
- 表单 multipart/form-data 如何提交中文乱码
- 各位大侠说说这是什么错?(谢谢大家检查一下!)
你这里光这个只能看出是内存溢出。
楼主找下jxl或poi的例子,看看别人怎么弄的。很多的。
int excelRows = st.getRows();好像不是这么得到行数的,具体忘了,LZ可以网上找个,不是什么都在自己写的,呵呵