在web项目中 用poi操作excel action中的代码怎么写 求poi操作excel的源代码 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import junit.framework.Assert;import org.apache.poi.ss.usermodel.Cell;import org.apache.poi.ss.usermodel.Row;import org.apache.poi.ss.usermodel.Sheet;import org.apache.poi.ss.usermodel.Workbook;import org.apache.poi.ss.util.CellReference;import org.apache.poi.xssf.streaming.SXSSFWorkbook;public class Excel { public static void main(String[] args) { Workbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory, Sheet sh = wb.createSheet(); Sheet sh1 = wb.createSheet(); for (int rownum = 0; rownum < 1000; rownum++) { Row row = sh.createRow(rownum); Row row1 = sh1.createRow(rownum); for (int cellnum = 0; cellnum < 10; cellnum++) { Cell cell = row.createCell(cellnum); Cell cell1 = row1.createCell(cellnum); String address = new CellReference(cell).formatAsString(); cell.setCellValue(address); String address1 = new CellReference(cell1).formatAsString(); cell1.setCellValue(address1); } } // Rows with rownum < 900 are flushed and not accessible for (int rownum = 0; rownum < 900; rownum++) { Assert.assertNull(sh.getRow(rownum)); Assert.assertNull(sh1.getRow(rownum)); } // ther last 100 rows are still in memory for (int rownum = 900; rownum < 1000; rownum++) { Assert.assertNotNull(sh.getRow(rownum)); Assert.assertNotNull(sh1.getRow(rownum)); } try { FileOutputStream out = new FileOutputStream("D:/test1.xlsx"); wb.write(out); out.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }} 请问struts2与struts1.X的区别大么? spring整合,!!!都是我不确定的位置 怎么免费注册二级域名?在线等 初学ajax的郁闷....小问题啊!散分啊!O(∩_∩)O~ 大学学了什么!!! 请问如何用JavaScript实现点一个图片然后这个图片变成另一个图片? jsp页面空白 怎样配置glassfish 怎么用java实现验证码(完整版) 在jsp页面里怎样在当前目录生成文件并往里写数据? JSP+JS按钮属性问题 js 里的setTimeout 怎么没用的
import java.io.FileOutputStream;
import java.io.IOException;import junit.framework.Assert;import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;public class Excel { public static void main(String[] args) {
Workbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory,
Sheet sh = wb.createSheet();
Sheet sh1 = wb.createSheet();
for (int rownum = 0; rownum < 1000; rownum++) {
Row row = sh.createRow(rownum);
Row row1 = sh1.createRow(rownum);
for (int cellnum = 0; cellnum < 10; cellnum++) {
Cell cell = row.createCell(cellnum);
Cell cell1 = row1.createCell(cellnum);
String address = new CellReference(cell).formatAsString();
cell.setCellValue(address);
String address1 = new CellReference(cell1).formatAsString();
cell1.setCellValue(address1);
} } // Rows with rownum < 900 are flushed and not accessible
for (int rownum = 0; rownum < 900; rownum++) {
Assert.assertNull(sh.getRow(rownum));
Assert.assertNull(sh1.getRow(rownum));
} // ther last 100 rows are still in memory
for (int rownum = 900; rownum < 1000; rownum++) {
Assert.assertNotNull(sh.getRow(rownum));
Assert.assertNotNull(sh1.getRow(rownum));
} try {
FileOutputStream out = new FileOutputStream("D:/test1.xlsx");
wb.write(out);
out.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}