XSL文件Sheet1页第2行第1列设置特定的填充色、字体和字色

POIFSFileSystem fs =  new  POIFSFileSystem( new  FileInputStream(
             fileName));
     HSSFWorkbook resourceFile =  new  HSSFWorkbook(fs);
     HSSFSheet shOrg = resourceFile.getSheet( "Sheet1" );
     if  (shOrg ==  null ) {
         return ;
     }
     HSSFRow curRow = shOrg.getRow( 1 );  //取XSL文件Sheet1页上第2行
     HSSFCell curCell = curRow.getCell( 0 );  //第1列
     HSSFCellStyle cellStyle = resourceFile.createCellStyle();
     
     cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);   //填充单元格
     cellStyle.setFillForegroundColor(HSSFColor.DARK_RED.index);     //填暗红色
     Font font = resourceFile.createFont();
     font.setFontHeightInPoints(( short ) 24 );  //字体大小
     font.setFontName( "楷体" );
     font.setBoldweight(Font.BOLDWEIGHT_BOLD);  //粗体
     font.setColor(HSSFColor.GREEN.index);     //绿字
     cellStyle.setFont(font);
     curCell.setCellStyle(cellStyle);
 
     // 另存文件
     String outputFileName =  "resource1.xls" ;
     FileOutputStream stream;
     stream =  new  FileOutputStream( new  File(outputFileName));
     resourceFile.write(stream);
     stream.close();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值