workbook = new XSSFWorkbook ( ) ;
XSSFSheet sheet = workbook. createSheet ( "data" ) ;
XSSFRow row = sheet. createRow ( 0 ) ;
XSSFCell cell = row. createCell ( 0 ) ;
XSSFCellStyle cellStyle = workbook. createCellStyle ( ) ;
. . . . . . . ( 具体的格式操作)
cell. setCellStyle ( cellStyle) ;
sheet. setColumnWidth ( 0 , 2000 ) ;
sheet. setDefaultRowHeight ( ( short ) 1000 ) ;
XSSFFont font = workbook. createFont ( ) ;
font. setFontName ( "等线" ) ;
font. setColor ( new XSSFColor ( new Color ( 0 , 176 , 80 ) ) ) ;
cellStyle. setFont ( font) ;
cellStyle. setFillForegroundColor ( new XSSFColor ( new Color ( 255 , 242 , 204 ) , null ) ) ;
cellStyle. setFillPattern ( FillPatternType . SOLID_FOREGROUND) ;
cellStyle. setAlignment ( HorizontalAlignment . CENTER) ;
cellStyle. setVerticalAlignment ( VerticalAlignment . CENTER) ;
FileOutputStream out = new FileOutputStream ( new File ( "/xxx/xxx.xlsm" ) ) ;
workbook. write ( out) ;
out. close ( ) ;