POI-单元格是设置不同值

前言

本篇文章主要是为说明,单元格可以设置不同的值。

实例

  
public static void main(String[] args) throws Exception
{
  //定义工作簿
  Workbook wb = new HSSFWorkbook();
  //定义sheet
  Sheet sheet = wb.createSheet("my sheet");
  //定义第一行
  Row row = sheet.createRow(0);
  
  //设置第一列
  row.createCell(0).setCellValue(new Date());
  //设置第二列
  row.createCell(1).setCellValue(1);
  //设置第三列
  row.createCell(2).setCellValue(true);
  //设置第四列
  row.createCell(3).setCellValue(HSSFCell.CELL_TYPE_NUMERIC);
  //设置第五列
  row.createCell(4).setCellValue(false);
  
  FileOutputStream fileout = new FileOutputStream("f:\\POI\\设置任意值.xls");
  wb.write(fileout);
  fileout.close();
  
}

猜你喜欢

转载自blog.csdn.net/a4171175/article/details/80032205
今日推荐