从文本txt导入大量数据到excel报错
2015-08-07 15:37
423 查看
超过边界值
jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been exceeded
解决方法:
int i=0;
int maxRowCount=60000;//不能够超过excel的最大容量
String [] array = new String[8];//用于存储每一行的结果
WritableSheet sheet =book.createSheet("第"+m+"页", m);
while((tempString =reader.readLine())!=null){
if(0!=i && i % maxRowCount == 0)
{
m++;
sheet= book.createSheet("第"+m+"页",m);
i=0;
}
sheet = book.getSheet(m);
sheet.setColumnView(0, 8); // 第1列
sheet.setColumnView(1, 15); // 第2列
sheet.setColumnView(2, 25);
sheet.setColumnView(3, 15);
sheet.setColumnView(4, 28);
sheet.setColumnView(5, 12);
sheet.setColumnView(6, 28);
System.out.println(tempString);
String []str=tempString.split("----");
array[0]=str[2];
System.out.println(array[0]);
array[1]=str[1];
array[2]=str[3];
array[3]=str[4];
array[4]=str[0];
array[5]=str[5];
array[6]=str[6];
for(int j=0;j<array.length;j++){
//在Label对象的构造子中指明单元格的位置是第j列第i行(i,j)以及单元格内容为Str[j]
if(i==0){
sheet.addCell(new Label(0, 0, "姓名"));
sheet.addCell(new Label(1, 0, "性别"));
sheet.addCell(new Label(2, 0, "***号码"));
sheet.addCell(new Label(3, 0, "出生日"));
sheet.addCell(new Label(4, 0, "邮箱" ));
sheet.addCell(new Label(5, 0, "手机号"));
sheet.addCell(new Label(6, 0, "邮箱"));
}
Label label =new Label(j,i,array[j]);
//将定义好的单元格添加到工作表中
// System.out.println(label);
sheet.addCell(label);
}
i++;
}
jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been exceeded
解决方法:
int i=0;
int maxRowCount=60000;//不能够超过excel的最大容量
String [] array = new String[8];//用于存储每一行的结果
WritableSheet sheet =book.createSheet("第"+m+"页", m);
while((tempString =reader.readLine())!=null){
if(0!=i && i % maxRowCount == 0)
{
m++;
sheet= book.createSheet("第"+m+"页",m);
i=0;
}
sheet = book.getSheet(m);
sheet.setColumnView(0, 8); // 第1列
sheet.setColumnView(1, 15); // 第2列
sheet.setColumnView(2, 25);
sheet.setColumnView(3, 15);
sheet.setColumnView(4, 28);
sheet.setColumnView(5, 12);
sheet.setColumnView(6, 28);
System.out.println(tempString);
String []str=tempString.split("----");
array[0]=str[2];
System.out.println(array[0]);
array[1]=str[1];
array[2]=str[3];
array[3]=str[4];
array[4]=str[0];
array[5]=str[5];
array[6]=str[6];
for(int j=0;j<array.length;j++){
//在Label对象的构造子中指明单元格的位置是第j列第i行(i,j)以及单元格内容为Str[j]
if(i==0){
sheet.addCell(new Label(0, 0, "姓名"));
sheet.addCell(new Label(1, 0, "性别"));
sheet.addCell(new Label(2, 0, "***号码"));
sheet.addCell(new Label(3, 0, "出生日"));
sheet.addCell(new Label(4, 0, "邮箱" ));
sheet.addCell(new Label(5, 0, "手机号"));
sheet.addCell(new Label(6, 0, "邮箱"));
}
Label label =new Label(j,i,array[j]);
//将定义好的单元格添加到工作表中
// System.out.println(label);
sheet.addCell(label);
}
i++;
}
相关文章推荐
- HTTP跨域调用-传入URL就直接返回回来数据
- tree型的json数据按照json的某个字段对子节点进行排序
- 连接Oracle时报错ORA-12541: TNS: 无监听程序
- MyBatis的几种批量操作
- Android EditText 修改提示字体的大小
- 页面重绘和回流以及优化
- Seek the Name, Seek the Fame
- 【ecos】编码规范
- Yii2 redis 使用
- JScrollPane中添加JPanel不出现滚动条
- 文件上传保存没有Nginx最好放Tomcat里面
- 支配值数目
- iOS应用程序生命周期(前后台切换,应用的各种状态)详解
- maven 的 pom.xml 文件报错:ArtifactTransferException: Failure to transfer
- 实时监听textarea并限制最大字符数
- ADT+SDK+JDK+elipse的理解
- python udpserver decorator 修饰类
- JavaWeb学习——Ajax提交URL中文参数乱码问题
- 虚表(C++)virtual table
- Linux 文件权限简单说明