// 使用Java POI
// 把要两个JAR文件放到lib/ext下
// code run against the jakarta-poi-1.5.0-FINAL-20020506.jar.
// and commons-logging-1.0.jar
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
// code run against the jakarta-poi-1.5.0-FINAL-20020506.jar.
// and commons-logging-1.0.jar
public class aa {
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();
}
}