jxl操作excel样式设置

WritableFont headFont = new WritableFont(WritableFont.TIMES, 14,WritableFont.BOLD);  
//设置标题,字号14,加粗 


   
WritableFont countents = new WritableFont(WritableFont.TIMES,12); // 设置单元格内容,字号12 
WritableCellFormat cell = new WritableCellFormat(contentFont); 


cell.setAlignment(jxl.format.Alignment.CENTRE);// 单元格内容水平居中 
cell.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);// 单元格内容垂直居中 


cell.setBorder(Border.ALL, BorderLineStyle.THIN,jxl.format.Colour.BLACK); // 边框 
// Border.ALL:上下左右都设置边框; BorderLineStyle.THIN: 细边框; jxl.format.Colour.BLACK: 黑颜色  


cell.setWrap(true);//是否换行  
  
  




WritableSheet sheet = book.createSheet("公文检索", 0); //创建一个新sheet 
sheet.setColumnView(0, 80); //第1列宽 
sheet.setColumnView(1, 80); //第2列宽 
  


sheet.setRowView(i+1, 400);//某行的行高,一般用在循环中 


//合并单元格 
sheet.mergeCells(3,0,4,0);//(列,行,列,行) 
  


//设置页边距(0.1d=0.26cm) 
sheet.getSettings().setBottomMargin(0.7d); 
sheet.getSettings().setTopMargin(0.7d); 
sheet.getSettings().setLeftMargin(0.75d); 
sheet.getSettings().setRightMargin(0.75d); 




//设置打印方向为 横向,不设置为纵向 


sheet.setPageSetup(PageOrientation.LANDSCAPE.LANDSCAPE,PaperSize.A4,0.5d,0.5d); 
  


//设置页码,3个参数位置分别对应:左边、中间、右边 
 sheet.setFooter("", "&P", ""); 


//设置冻结单元格,下拉时第一列固定 
sheet.getSettings().setVerticalFreeze(1);  
  


//设置是否显示行数列数编号 
sheet.getSettings().setPrintHeaders(true);




转载于:https://my.oschina.net/liuhuiweb/blog/199024

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值