本文整理汇总了Java中org.apache.poi.ss.usermodel.BorderStyle类的典型用法代码示例。如果您正苦于以下问题:Java BorderStyle类的具体用法?Java BorderStyle怎么用?Java BorderStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BorderStyle类属于org.apache.poi.ss.usermodel包,在下文中一共展示了BorderStyle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultDataCellStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的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: createBackgroundColorXSSFCellStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
/**
* @param wb
* @param color
* @param foreGround
* @return
*/
public static XSSFCellStyle createBackgroundColorXSSFCellStyle(XSSFWorkbook wb,XSSFColor color,short foreGround){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setFillForegroundColor(color);
cellStyle.setFillPattern(foreGround);
return cellStyle;
}
示例3: createBorderCellStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的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;
}
示例4: setPen
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
public void setPen(JRPen pen)
{
if (
borderStyle[TOP] == BorderStyle.NONE
&& borderStyle[LEFT] == BorderStyle.NONE
&& borderStyle[BOTTOM] == BorderStyle.NONE
&& borderStyle[RIGHT] == BorderStyle.NONE
)
{
BorderStyle style = JRXlsExporter.getBorderStyle(pen);
short colour = JRXlsExporter.this.getWorkbookColor(pen.getLineColor()).getIndex();
borderStyle[TOP] = style;
borderStyle[BOTTOM] = style;
borderStyle[LEFT] = style;
borderStyle[RIGHT] = style;
borderColour[TOP] = colour;
borderColour[BOTTOM] = colour;
borderColour[LEFT] = colour;
borderColour[RIGHT] = colour;
}
hash = computeHash();
}
示例5: setPen
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
public void setPen(JRPen pen) {
if (
borderStyle[TOP] == BorderStyle.NONE
&& borderStyle[LEFT] == BorderStyle.NONE
&& borderStyle[BOTTOM] == BorderStyle.NONE
&& borderStyle[RIGHT] == BorderStyle.NONE
) {
BorderStyle style = JRXlsMetadataExporter.getBorderStyle(pen);
short colour = JRXlsMetadataExporter.this.getWorkbookColor(pen.getLineColor()).getIndex();
borderStyle[TOP] = style;
borderStyle[BOTTOM] = style;
borderStyle[LEFT] = style;
borderStyle[RIGHT] = style;
borderColour[TOP] = colour;
borderColour[BOTTOM] = colour;
borderColour[LEFT] = colour;
borderColour[RIGHT] = colour;
}
hash = computeHash();
}
示例6: startExport
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
@Override public void startExport(List<? extends IExportColumn<?>> columnList) throws Exception {
if(m_started)
throw new IllegalArgumentException("The writer was already started");
m_started = true;
m_columnList = columnList;
Workbook wb = m_workbook = createWorkbook();
Font defaultFont = wb.createFont();
defaultFont.setFontHeightInPoints((short) 10);
defaultFont.setFontName("Arial");
CellStyle dcs = m_defaultCellStyle = wb.createCellStyle();
dcs.setFont(defaultFont);
// FIXME Date format must be locale dependent?
CellStyle dates = m_dateStyle = wb.createCellStyle();
dates.setDataFormat(wb.createDataFormat().getFormat("d-m-yyyy"));
dates.setFont(defaultFont);
CellStyle curs = m_currencyStyle = wb.createCellStyle();
curs.setDataFormat(wb.createDataFormat().getFormat("#,##0.00"));
curs.setFont(defaultFont);
CellStyle nums = m_numberStyle = wb.createCellStyle();
nums.setDataFormat(wb.createDataFormat().getFormat("#0"));
nums.setFont(defaultFont);
Font headerFont = wb.createFont();
headerFont.setFontHeightInPoints((short) 10);
headerFont.setColor((short) 0xc);
headerFont.setBold(true);
headerFont.setFontName("Arial");
CellStyle hds = m_headerStyle = wb.createCellStyle();
hds.setBorderBottom(BorderStyle.THIN);
hds.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
hds.setFont(headerFont);
createNewSheet(columnList);
}
示例7: createCellStyleForColumnHeading
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
public static HSSFCellStyle createCellStyleForColumnHeading(HSSFWorkbook workBook) {
HSSFCellStyle cellStyle = workBook.createCellStyle();
HSSFFont fontObj = workBook.createFont();
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setWrapText(true);
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setFillBackgroundColor(Short.valueOf("22").shortValue());
cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);
cellStyle.setFillForegroundColor(Short.valueOf("22").shortValue());
cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
fontObj.setFontName("Calibri");
fontObj.setFontHeightInPoints(Short.valueOf("12").shortValue());
fontObj.setBold(true);
fontObj.setColor(Short.valueOf("8").shortValue());
cellStyle.setFont(fontObj);
return cellStyle;
}
示例8: getCellStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
/**
* 普通单元格样式
*
* @param workbook
* @return
* @author 阳自然
*/
private static CellStyle getCellStyle(Workbook workbook) {
// 创建格式 普通格式
CellStyle cellStyle = workbook.createCellStyle();
cellStyle.setFont(getFont(workbook, null));
// 单元格边框
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
// 垂直居中对齐
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return cellStyle;
}
示例9: testBorder
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
@Test
public void testBorder ()
{
final ExcelStyle e = new ExcelStyle ();
assertNull (e.getBorderTop ());
assertNull (e.getBorderRight ());
assertNull (e.getBorderBottom ());
assertNull (e.getBorderLeft ());
CommonsTestHelper.testGetClone (e);
for (final BorderStyle eBorder : BorderStyle.values ())
{
assertSame (e, e.setBorder (eBorder));
assertEquals (eBorder, e.getBorderTop ());
assertEquals (eBorder, e.getBorderRight ());
assertEquals (eBorder, e.getBorderBottom ());
assertEquals (eBorder, e.getBorderLeft ());
CommonsTestHelper.testGetClone (e);
}
}
示例10: createCenterXSSFCellStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
public static XSSFCellStyle createCenterXSSFCellStyle(XSSFWorkbook wb){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
return cellStyle;
}
示例11: initialize
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
@Override
public void initialize(Workbook workbook) {
this.borderStyle = workbook.createCellStyle();
this.borderStyle.setBorderBottom(BorderStyle.THIN);
this.borderStyle.setBorderTop(BorderStyle.THIN);
this.borderStyle.setBorderRight(BorderStyle.THIN);
this.borderStyle.setBorderLeft(BorderStyle.THIN);
}
示例12: getBorderStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
private BorderStyle getBorderStyle(Border border){
if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.solid)){
return BorderStyle.THIN;
}else if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.dashed)){
return BorderStyle.DASHED;
}else if(border.getStyle().equals(com.bstek.ureport.definition.BorderStyle.doublesolid)){
return BorderStyle.DOUBLE;
}
return null;
}
示例13: createTitleXSSFCellStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
public static XSSFCellStyle createTitleXSSFCellStyle(XSSFWorkbook wb){
String message="XSSFWorkbook must not be null!";
Objects.requireNonNull(wb, () -> message);
XSSFCellStyle cellStyle=wb.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
cellStyle.setBorderBottom(BorderStyle.THIN);
cellStyle.setBorderLeft(BorderStyle.THIN);
cellStyle.setBorderTop(BorderStyle.THIN);
cellStyle.setBorderRight(BorderStyle.THIN);
cellStyle.setFillForegroundColor(new XSSFColor( new Color(75, 172, 198)));
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
return cellStyle;
}
示例14: setBorders
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
/**
* Sets the borders.
*
* @param headerCellStyle
* the header cell style
* @param left
* the left
* @param right
* the right
* @param top
* the top
* @param bottom
* the bottom
* @param color
* the color
* @return the XSSF cell style
*/
public static XSSFCellStyle setBorders(final XSSFCellStyle headerCellStyle, final Boolean left, final Boolean right,
final Boolean top, final Boolean bottom, final Color color) {
if (bottom) {
headerCellStyle.setBorderBottom(BorderStyle.THIN);
headerCellStyle.setBorderColor(BorderSide.BOTTOM, new XSSFColor(color));
}
if (top) {
headerCellStyle.setBorderTop(BorderStyle.THIN);
headerCellStyle.setBorderColor(BorderSide.TOP, new XSSFColor(color));
}
if (left) {
headerCellStyle.setBorderLeft(BorderStyle.THIN);
headerCellStyle.setBorderColor(BorderSide.LEFT, new XSSFColor(color));
}
if (right) {
headerCellStyle.setBorderRight(BorderStyle.THIN);
headerCellStyle.setBorderColor(BorderSide.RIGHT, new XSSFColor(color));
}
return headerCellStyle;
}
示例15: getBorderStyle
import org.apache.poi.ss.usermodel.BorderStyle; //导入依赖的package包/类
/**
*
*/
protected static BorderStyle getBorderStyle(JRPen pen) {
float lineWidth = pen.getLineWidth().floatValue();
if (lineWidth > 0f) {
switch (pen.getLineStyleValue()) {
case DOUBLE : {
return BorderStyle.DOUBLE;
}
case DOTTED : {
return BorderStyle.DOTTED;
}
case DASHED : {
if (lineWidth >= 1f) {
return BorderStyle.MEDIUM_DASHED;
}
return BorderStyle.DASHED;
}
case SOLID :
default : {
if (lineWidth >= 2f) {
return BorderStyle.THICK;
}
else if (lineWidth >= 1f) {
return BorderStyle.MEDIUM;
} else if (lineWidth >= 0.5f) {
return BorderStyle.THIN;
}
return BorderStyle.HAIR;
}
}
}
return BorderStyle.NONE;
}