五万行数据没问题,10万我都导过,你可以用逗号分隔,别用什么poi,再命名为excel就可以了。
我给你个办法,是要导出excel吗?别使用poi,使用xml来描述excel即可,就像流文件一样,多少都不会流出,给你个思路,你自己扩展,希望你能看明白。
/**
* @author J.W
* 2011-06-08
*/
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Test {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
try {
DataOutputStream rafs = new DataOutputStream(
new BufferedOutputStream(new FileOutputStream(new File(
"d://test.xml"))));
sb.append("");
sb.append("\n");
sb.append("");
sb.append("\n");
sb.append("
sb.append(" xmlns:o=\"urn:schemas-microsoft-com:office:office\"");
sb.append("\n");
sb.append(" xmlns:x=\"urn:schemas-microsoft-com:office:excel\"");
sb.append("\n");
sb.append(" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"");
sb.append("\n");
sb.append(" xmlns:html=\"http://www.w3.org/TR/REC-html40\">");
sb.append("\n");
sb.append("
sb.append(" \n");
sb.append("
int sheetcount = 0;
int recordcount = 20;
int currentRecord = 0;
int total = 100;
int col = 20;
sb.append("
sb.append("\n");
sb.append(" + "\" ss:ExpandedRowCount=\"" + total
");
+ "\" x:FullColumns=\"1\" x:FullRows=\"1\">");
sb.append("\n");
for (int i = 0; i < total; i++) {
if ((currentRecord == recordcount
|| currentRecord > recordcount || currentRecord == 0)
&& i != 0) {// 一个sheet写满
currentRecord = 0;
rafs.write(sb.toString().getBytes());
sb.setLength(0);
sb.append("
sb.append("
sb.append("\n");
sb.append("
sb.append("\n");
sb.append("
sb.append("\n");
sb.append("
sb.append("\n");
sb.append("
sb.append("
sb.append("\n");
sb.append(" + "\" ss:ExpandedRowCount=\"" + recordcount
");
+ "\" x:FullColumns=\"1\" x:FullRows=\"1\">");
sb.append("\n");
}
sb.append("
for (int j = 0; j < col; j++) {
System.out.println(i);
sb.append("
sb.append("\n");
}
sb.append("
if (i % 5000 == 0) {
rafs.write(sb.toString().getBytes());
rafs.flush();
sb.setLength(0);
}
sb.append("\n");
currentRecord++;
}
rafs.write(sb.toString().getBytes());
sb.setLength(0);
sb.append("
sb.append("
sb.append("\n");
sb.append("
sb.append("\n");
sb.append("
sb.append("\n");
sb.append("
sb.append("\n");
sb.append("
sb.append("
sb.append("\n");
rafs.write(sb.toString().getBytes());
rafs.flush();
rafs.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
可以直接执行,只是给你个思路。