本文整理汇总了Java中org.apache.poi.ss.usermodel.CellStyle.setBorderLeft方法的典型用法代码示例。如果您正苦于以下问题:Java CellStyle.setBorderLeft方法的具体用法?Java CellStyle.setBorderLeft怎么用?Java CellStyle.setBorderLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.CellStyle
的用法示例。
在下文中一共展示了CellStyle.setBorderLeft方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultDataCellStyle
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
/**
* Returns the default data cell style. Obtained from:
* http://svn.apache.org/repos/asf/poi
* /trunk/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java
*
* @param wb the wb
* @return the cell style
*/
protected CellStyle defaultDataCellStyle(final Workbook wb) {
CellStyle style;
style = wb.createCellStyle();
style.setAlignment(HorizontalAlignment.CENTER);
style.setWrapText(true);
style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(BorderStyle.THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setDataFormat(doubleDataFormat);
return style;
}
示例2: createStyles
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
/**
* 创建表格样式
* @param wb 工作薄对象
* @return 样式列表
*/
private Map<String, CellStyle> createStyles(Workbook wb) {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
CellStyle style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
Font titleFont = wb.createFont();
titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
style.setFont(titleFont);
styles.put("title", style);
style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
Font dataFont = wb.createFont();
dataFont.setFontName("Arial");
dataFont.setFontHeightInPoints((short) 10);
style.setFont(dataFont);
styles.put("data", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_LEFT);
styles.put("data1", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_CENTER);
styles.put("data2", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_RIGHT);
styles.put("data3", style);
style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data"));
// style.setWrapText(true);
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
Font headerFont = wb.createFont();
headerFont.setFontName("Arial");
headerFont.setFontHeightInPoints((short) 10);
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD);
headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont);
styles.put("header", style);
return styles;
}
示例3: createBorderedStyle
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
private static CellStyle createBorderedStyle(Workbook wb) {
CellStyle style = wb.createCellStyle();
style.setBorderRight(CellStyle.BORDER_THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
return style;
}
示例4: createStyles
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
/**
* excel 样式
*
* @return
*/
public Map<String, CellStyle> createStyles(Workbook workbook) {
Map<String, CellStyle> styles = new HashMap();
CellStyle style = workbook.createCellStyle();
style.setAlignment((short) 2);
style.setVerticalAlignment((short) 1);
Font titleFont = workbook.createFont();
titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16);
titleFont.setBoldweight((short) 700);
style.setFont(titleFont);
styles.put("title", style);
style = workbook.createCellStyle();
style.setVerticalAlignment((short) 1);
style.setBorderRight((short) 1);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft((short) 1);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop((short) 1);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom((short) 1);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
Font dataFont = workbook.createFont();
dataFont.setFontName("Arial");
dataFont.setFontHeightInPoints((short) 10);
style.setFont(dataFont);
styles.put("data", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 1);
styles.put("data1", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 2);
styles.put("data2", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 3);
styles.put("data3", style);
style = workbook.createCellStyle();
style.cloneStyleFrom((CellStyle) styles.get("data"));
style.setAlignment((short) 2);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern((short) 1);
Font headerFont = workbook.createFont();
headerFont.setFontName("Arial");
headerFont.setFontHeightInPoints((short) 10);
headerFont.setBoldweight((short) 700);
headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont);
styles.put("header", style);
return styles;
}
示例5: setCommonStyle
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
/**
* 设置通用的对齐居中、边框等
*
* @param style 样式
*/
private void setCommonStyle(CellStyle style) {
// 设置单元格居中对齐、自动换行
style.setAlignment(CellStyle.ALIGN_CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER);
style.setWrapText(true);
//设置单元格字体
if (!buildInFontMap.containsKey(FONT_KEY)) {
Font font = workbook.createFont();
//通用字体
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontName("宋体");
font.setFontHeight((short) 200);
buildInFontMap.put(FONT_KEY, font);
}
style.setFont(buildInFontMap.get(FONT_KEY));
// 设置单元格边框为细线条
style.setBorderLeft(CellStyle.BORDER_THIN);
style.setBorderBottom(CellStyle.BORDER_THIN);
style.setBorderRight(CellStyle.BORDER_THIN);
style.setBorderTop(CellStyle.BORDER_THIN);
}
示例6: createBorderCellStyle
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
public CellStyle createBorderCellStyle(Workbook workbook, boolean showBorder) {
CellStyle style = workbook.createCellStyle();
if (showBorder) {
style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.BLACK.getIndex());
style.setBorderTop(BorderStyle.THIN);
style.setTopBorderColor(IndexedColors.BLACK.getIndex());
}
return style;
}
示例7: createSheet
import org.apache.poi.ss.usermodel.CellStyle; //导入方法依赖的package包/类
/**
* Creates an excel sheet in the provided workbook using provided parameters.
*
* @param input the data to put in the sheet-
* @param sheetName the name to user for the sheet.
* @param wb the workbook to create the sheet in.
*/
private void createSheet( List<MessageResourceEntry> input,
String sheetName,
Workbook wb)
{
// create a new sheet
String name = StringUtils.isBlank(sheetName) ? this.defaultSheetName : sheetName;
LOG.info("Create sheet with name " + name);
Sheet sheet = wb.createSheet(name);
sheet.setZoom(this.zoom, 100);
Map<Locale, Integer> langs = getLanguageInformation(input);
createHeader(sheet, langs);
CellStyle keyStyle = sheet.getWorkbook().createCellStyle();
keyStyle.setAlignment(CellStyle.ALIGN_LEFT);
keyStyle.setBorderBottom(CellStyle.BORDER_THIN);
keyStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
Font f = sheet.getWorkbook().createFont();
f.setBoldweight(Font.BOLDWEIGHT_NORMAL);
keyStyle.setFont(f);
CellStyle valueStyle = sheet.getWorkbook().createCellStyle();
valueStyle.setAlignment(CellStyle.ALIGN_LEFT);
valueStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
valueStyle.setBorderBottom(CellStyle.BORDER_THIN);
valueStyle.setBorderRight(CellStyle.BORDER_THIN);
valueStyle.setBorderTop(CellStyle.BORDER_THIN);
valueStyle.setBorderLeft(CellStyle.BORDER_THIN);
valueStyle.setFont(f);
valueStyle.setWrapText(true);
CellStyle emptyStyle = sheet.getWorkbook().createCellStyle();
emptyStyle.setAlignment(CellStyle.ALIGN_LEFT);
emptyStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
emptyStyle.setBorderBottom(CellStyle.BORDER_THIN);
emptyStyle.setBorderRight(CellStyle.BORDER_THIN);
emptyStyle.setBorderTop(CellStyle.BORDER_THIN);
emptyStyle.setBorderLeft(CellStyle.BORDER_THIN);
emptyStyle.setFont(f);
emptyStyle.setFillForegroundColor(IndexedColors.LAVENDER.getIndex());
emptyStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
emptyStyle.setWrapText(true);
LOG.info("Write data to sheet " + name);
int rowIndex = this.languageHeaderRow + 1;
for (MessageResourceEntry entry : input)
{
Row row = sheet.createRow(rowIndex);
createContentRow(entry, row, langs, keyStyle, valueStyle, emptyStyle);
rowIndex++;
}
sizeColumns(sheet, langs);
sheet.createFreezePane(this.firstLanguageColumn, this.languageHeaderRow + 1, this.firstLanguageColumn, this.languageHeaderRow + 1);
}