欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

poi之控制台生成xls 博客分类: java JavaJ#Apache 

程序员文章站 2024-03-16 08:13:28
...
package com.cw.common;

import org.apache.poi.hssf.usermodel.*;
import java.io.FileOutputStream;
 
public class PoiTest {

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

		FileOutputStream fos = new FileOutputStream("e:\\a.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();
	}
}

相关标签: Java J# Apache