Chinaunix首页 | 论坛 | 博客
  • 博客访问: 178287
  • 博文数量: 89
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 828
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-08 10:44
文章分类
文章存档

2014年(9)

2013年(80)

我的朋友

分类: Java

2013-12-05 17:46:00

// 使用Java POI
// 把要两个JAR文件放到lib/ext下
// code run against the jakarta-poi-1.5.0-FINAL-20020506.jar.
//                  and commons-logging-1.0.jar
例子程序: 
import org.apache.poi.hssf.usermodel.*;
import java.io.FileOutputStream;


// code run against the jakarta-poi-1.5.0-FINAL-20020506.jar.
//                  and commons-logging-1.0.jar
public class PoiTest {


static public void main(String[] args) throws Exception {


 FileOutputStream fos = new FileOutputStream("d://foo.xls");
 HSSFWorkbook wb = new HSSFWorkbook();
 HSSFSheet s = wb.createSheet();
 wb.setSheetName(0, "Matrix");
 for(short i=0; i<50; i++) {
  HSSFRow row = s.createRow(i);
  for(short j=0; j<50; j++) {
   HSSFCell cell = row.createCell(j);
   cell.setCellValue(""+i+","+j);
  }
 }
 wb.write(fos);
 fos.close();
}

阅读(729) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~