ApachePoiUtils

 

生成Excel报表

package top.zzzwww.utils;
?
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
?
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
?
public class ApachePoiUtil2 {
   public static void main(String[] args) throws Exception {
       OutputStream os = new FileOutputStream("F:\\test.xls");
       Workbook wb = new HSSFWorkbook();
       ApachePoiUtil2 test = new ApachePoiUtil2();
       test.createFile(os, wb);
  }
?
   private void createFile(OutputStream os,Workbook wb) throws IOException{
       int i = 0;
       int j = 0;
       double
       = 0.00;
       double ref_amt = 0.00;
       String[] refundLogs = new String[2];
       String str1 = "20110812|34234234242432|345.00|323   .00";
       String str2 = "20110504|45656464535345|231.34|231.34";
       refundLogs[0] = str1;
       refundLogs[1] = str2;
       // 创建工作表指定工作表名称
       Sheet sheet = wb.createSheet("T建行退款文件");
       // 创建行,0表示第一行
       Row row = sheet.createRow(0);
       for(i=1;i<=3;i++){
           sheet.createRow(i);
      }
?
       for(i=0;i<4;i++)
           row.createCell(i);
?
       // 合并单元格
       sheet.addMergedRegion(new CellRangeAddress(0, 3, 0, 3));
       //CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol)
       //参数:起始行号,终止行号, 起始列号,终止列号
       // 设置字体
       Font font = wb.createFont();
       // 设置字体名称
       font.
上一篇:WebApls-Bom


下一篇:如何使用Kubeadm设置高可用性Kubernetes集群