zoukankan      html  css  js  c++  java
  • jxl操作excel样式设置

    1. WritableFont headFont = new WritableFont(WritableFont.TIMES, 14,WritableFont.BOLD);   
    2. //设置标题,字号14,加粗  
    3.   
    4.     
    5. <P>WritableFont countents = new WritableFont(WritableFont.TIMES,12); // 设置单元格内容,字号12  
    6. WritableCellFormat cell = new WritableCellFormat(contentFont);  
    7.   
    8. cell.setAlignment(jxl.format.Alignment.CENTRE);// 单元格内容水平居中  
    9. cell.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);// 单元格内容垂直居中  
    10.   
    11. cell.setBorder(Border.ALL, BorderLineStyle.THIN,jxl.format.Colour.BLACK); // 边框  
    12. // Border.ALL:上下左右都设置边框; BorderLineStyle.THIN: 细边框; jxl.format.Colour.BLACK: 黑颜色   
    13.   
    14. cell.setWrap(true);//是否换行   
    15.    
    16.    
    17.   
    18.   
    19. WritableSheet sheet = book.createSheet("公文检索", 0); //创建一个新sheet  
    20. sheet.setColumnView(0, 80); //第1列宽  
    21. sheet.setColumnView(1, 80); //第2列宽  
    22.    
    23.   
    24. sheet.setRowView(i+1, 400);//某行的行高,一般用在循环中  
    25.   
    26. //合并单元格  
    27. sheet.mergeCells(3,0,4,0);//(列,行,列,行)  
    28.    
    29.   
    30. //设置页边距(0.1d=0.26cm)  
    31. sheet.getSettings().setBottomMargin(0.7d);  
    32. sheet.getSettings().setTopMargin(0.7d);  
    33. sheet.getSettings().setLeftMargin(0.75d);  
    34. sheet.getSettings().setRightMargin(0.75d);  
    35.   
    36.   
    37. //设置打印方向为 横向,不设置为纵向  
    38.   
    39. sheet.setPageSetup(PageOrientation.LANDSCAPE.LANDSCAPE,PaperSize.A4,0.5d,0.5d);  
    40.    
    41.   
    42. //设置页码,3个参数位置分别对应:左边、中间、右边  
    43.  sheet.setFooter("", "&P", "");  
    44.   
    45. //设置冻结单元格,下拉时第一列固定  
    46. sheet.getSettings().setVerticalFreeze(1);   
    47.    
    48.   
    49. //设置是否显示行数列数编号  
    50. sheet.getSettings().setPrintHeaders(true);  

    注:转载自https://xqqing79.iteye.com/blog/1454326

  • 相关阅读:
    Delphi编译器属性(特别修饰符Ref,Unsafe,Volatile,Weak)
    .netcore dapr微服务入门
    Net WebApi一个简单的Token验证
    发布订阅和观察者模式
    NET Core创建Windows服务
    jquery.barrager.js弹幕实现
    跨平台中的RN、Flutter,服务端GraphQL、Serverless,Node和Electron
    分布式系统与高并发高可用
    11 个 Linux 命令
    接口幂等性
  • 原文地址:https://www.cnblogs.com/zhangxiaozhen/p/11299481.html
Copyright © 2011-2022 走看看