本篇文章主要介绍了"输出到Excel excel写入笔记",主要涉及到输出到Excel方面的内容,对于软件工程感兴趣的同学可以参考一下:
excel写入笔记import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hss...
excel写入笔记
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Sheet;
public class Demo3 {
static String FILENAMEPATH = "E:\\data.xls";
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
HSSFWorkbook exb = new HSSFWorkbook();//定义一个新的工作簿
Sheet sheet = exb.createSheet("第一个shell页"); //创建一个
Row row = sheet.createRow(0); //创建一个行
Cell cell = row.createCell(0); //创建一个列
cell.setCellValue(new Date()); //给单元格设值
//写入值
row.createCell(1).setCellValue(1);
row.createCell(2).setCellValue("第一个字符串");
row.createCell(3).setCellValue(true);
row.createCell(4).setCellValue(HSSFCell.CELL_TYPE_NUMERIC);
row.createCell(5).setCellValue(false);
//row.createCell(1).setCellValue(2);
FileOutputStream fileOut = new FileOutputStream(FILENAMEPATH); //打开文件
exb.write(fileOut); //写入文件
fileOut.close(); // 关闭文件
System.out.println("操作成功");
}
}
以上就介绍了输出到Excel excel写入笔记,包括了输出到Excel方面的内容,希望对软件工程有兴趣的朋友有所帮助。
本文网址链接:http://www.codes51.com/article/detail_4501669.html