package UIB.UIB03.ZBS; import jxl.format.Alignment; import jxl.format.Border; import jxl.format.BorderLineStyle; import jxl.format.Colour; import jxl.format.VerticalAlignment; import jxl.write.WritableCellFormat; import jxl.write.WritableFont; /** * * @desc EXCEL风格设置 * @author meiguiping * @date 2010 5:52:50 PM */ public class ExcelStyleSeter { /** * 普通风格设置 */ public static WritableCellFormat getCommStyle() throws Exception { WritableFont wf = new WritableFont(WritableFont.createFont("宋体") , 8);//设置字体大小 // wf.setColour(Colour.RED);//设置颜色 WritableCellFormat wcf = new WritableCellFormat(wf); wcf.setBorder(Border.ALL, BorderLineStyle.THIN);//设置边框 wcf.setAlignment(Alignment.CENTRE); wcf.setVerticalAlignment(VerticalAlignment.CENTRE); // wcf.setWrap(true);//自动换行 return wcf; } /** * 表头风格设置 */ public static WritableCellFormat getHeaderStyle() throws Exception { // WritableFont wf = new WritableFont(WritableFont.TIMES , 9);//设置字体大小 WritableFont wf = new WritableFont(WritableFont.createFont("宋体") , 9);//设置字体大小 // wf.setColour(Colour.RED);//设置颜色 WritableCellFormat wcf = new WritableCellFormat(wf); wcf.setBorder(Border.ALL, BorderLineStyle.THIN);//设置边框 // wcf.setWrap(true);//自动换行 return wcf; } /** * @desc 成分名称 * @return * @throws Exception */ public static WritableCellFormat getChemNametyle() throws Exception { WritableFont wf = new WritableFont(WritableFont.createFont("宋体") , 8);//设置字体大小 // wf.setColour(Colour.BLUE);//设置颜色 WritableCellFormat wcf = new WritableCellFormat(wf); wcf.setBorder(Border.ALL, BorderLineStyle.THIN);//设置边框 wcf.setShrinkToFit(true);//缩小字体填充 wcf.setAlignment(Alignment.CENTRE); wcf.setVerticalAlignment(VerticalAlignment.CENTRE); // wcf.setWrap(true);//自动换行 return wcf; } /** * @desc 成分值风格 * @return * @throws Exception */ public static WritableCellFormat getChemValuetyle() throws Exception { WritableFont wf = new WritableFont(WritableFont.createFont("宋体") , 7);//设置字体大小 // wf.setColour(Colour.BLUE);//设置颜色 WritableCellFormat wcf = new WritableCellFormat(wf); wcf.setBorder(Border.ALL, BorderLineStyle.THIN);//设置边框 wcf.setAlignment(Alignment.CENTRE); wcf.setVerticalAlignment(VerticalAlignment.CENTRE); // wcf.setWrap(true);//自动换行 return wcf; } /** * @desc 材质值风格 * @return * @throws Exception */ public static WritableCellFormat getQltyValueStyle() throws Exception { WritableFont wf = new WritableFont(WritableFont.createFont("宋体") , 7);//设置字体大小 // wf.setColour(Colour.BLUE);//设置颜色 WritableCellFormat wcf = new WritableCellFormat(wf); wcf.setBorder(Border.ALL, BorderLineStyle.THIN);//设置边框 wcf.setAlignment(Alignment.CENTRE); wcf.setVerticalAlignment(VerticalAlignment.CENTRE); // wcf.setWrap(true);//自动换行 return wcf; } /** * @desc 材质项目名称风格设置 * @return * @throws Exception */ public static WritableCellFormat getQltyNameStyle() throws Exception { WritableFont wf = new WritableFont(WritableFont.createFont("黑体") ,7);//设置字体大小及样式 // wf.setColour(Colour.BLUE);//设置颜色 WritableCellFormat wcf = new WritableCellFormat(wf); wcf.setBorder(Border.ALL, BorderLineStyle.THIN);//设置边框 wcf.setAlignment(Alignment.CENTRE); wcf.setVerticalAlignment(VerticalAlignment.CENTRE); wcf.setWrap(true);//自动换行 return wcf; } }