Java Code Examples for org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED

The following examples show how to use org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StyleManagerHUtils.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Converts a BIRT border style into a POI border style (short constant defined in CellStyle).
 * @param birtBorder
 * The BIRT border style.
 * @param width
 * The width of the border as understood by BIRT.
 * @return
 * One of the CellStyle BORDER constants.
 */
private short poiBorderStyleFromBirt( String birtBorder, String width ) {
	if( "none".equals(birtBorder) ) {
		return CellStyle.BORDER_NONE;
	}
	DimensionType dim = DimensionType.parserUnit( width );
	double pxWidth = 3.0;
	if( ( dim != null ) && ( "px".equals(dim.getUnits()) ) ){
		pxWidth = dim.getMeasure();
	}
	if( "solid".equals(birtBorder) ) {
		if( pxWidth < 2.9 ) {
			return CellStyle.BORDER_THIN;
		} else if( pxWidth < 3.1 ) {
			return CellStyle.BORDER_MEDIUM;
		} else {
			return CellStyle.BORDER_THICK;
		}
	} else if( "dashed".equals(birtBorder) ) {
		if( pxWidth < 2.9 ) {
			return CellStyle.BORDER_DASHED;
		} else {
			return CellStyle.BORDER_MEDIUM_DASHED;
		}
	} else if( "dotted".equals(birtBorder) ) {
		return CellStyle.BORDER_DOTTED;
	} else if( "double".equals(birtBorder) ) {
		return CellStyle.BORDER_DOUBLE;
	} else if( "none".equals(birtBorder) ) {
		return CellStyle.BORDER_NONE;
	}

	log.debug( "Border style \"", birtBorder, "\" is not recognised" );
	return CellStyle.BORDER_NONE;
}
 
Example 2
Source File: Borders1ReportTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void assertSingleBorder( Sheet sheet, int row, String border, short expected, short actual ) {
	if( ( expected == CellStyle.BORDER_DOTTED ) 
			&& ( actual == CellStyle.BORDER_HAIR ) 
			&& ( sheet instanceof XSSFSheet )) {
		// Hopefully a temporary fudge to work around what is believe to be a bug in POI
		return ;
	}
	if( expected != actual ) {
		System.out.println( "Row " + row + ", border \"" + border + "\": " + actual + " != " + expected );
	}
	assertEquals( "Row " + row + ", border \"" + border + "\": ", expected, actual );
}
 
Example 3
Source File: XssfBorderLineStyleResolver.java    From xlsbeans with Apache License 2.0 4 votes vote down vote up
public static WBorderLineStyle resolve(short cellStyle) {
  WBorderLineStyle style = null;
  switch (cellStyle) {
    case CellStyle.BORDER_NONE:
      style = WBorderLineStyle.NONE;
      break;
    case CellStyle.BORDER_THIN:
      style = WBorderLineStyle.THIN;
      break;
    case CellStyle.BORDER_MEDIUM:
      style = WBorderLineStyle.MEDIUM;
      break;
    case CellStyle.BORDER_DASHED:
      style = WBorderLineStyle.DASHED;
      break;
    case CellStyle.BORDER_DOTTED:
      style = WBorderLineStyle.DOTTED;
      break;
    case CellStyle.BORDER_THICK:
      style = WBorderLineStyle.THICK;
      break;
    case CellStyle.BORDER_DOUBLE:
      style = WBorderLineStyle.DOUBLE;
      break;
    case CellStyle.BORDER_HAIR:
      style = WBorderLineStyle.HAIR;
      break;
    case CellStyle.BORDER_MEDIUM_DASHED:
      style = WBorderLineStyle.MEDIUM_DASHED;
      break;
    case CellStyle.BORDER_DASH_DOT:
      style = WBorderLineStyle.DASH_DOT;
      break;
    case CellStyle.BORDER_MEDIUM_DASH_DOT:
      style = WBorderLineStyle.MEDIUM_DASH_DOT;
      break;
    case CellStyle.BORDER_MEDIUM_DASH_DOT_DOT:
      style = WBorderLineStyle.MEDIUM_DASH_DOT_DOT;
      break;
    case CellStyle.BORDER_SLANTED_DASH_DOT:
      style = WBorderLineStyle.SLANTED_DASH_DOT;
      break;
    default:
      style = WBorderLineStyle.NONE;
      break;
  }
  return style;
}
 
Example 4
Source File: XssfBorderLineStyleResolver.java    From xlsbeans with Apache License 2.0 4 votes vote down vote up
public static WBorderLineStyle resolve(short cellStyle) {
  WBorderLineStyle style = null;
  switch (cellStyle) {
    case CellStyle.BORDER_NONE:
      style = WBorderLineStyle.NONE;
      break;
    case CellStyle.BORDER_THIN:
      style = WBorderLineStyle.THIN;
      break;
    case CellStyle.BORDER_MEDIUM:
      style = WBorderLineStyle.MEDIUM;
      break;
    case CellStyle.BORDER_DASHED:
      style = WBorderLineStyle.DASHED;
      break;
    case CellStyle.BORDER_DOTTED:
      style = WBorderLineStyle.DOTTED;
      break;
    case CellStyle.BORDER_THICK:
      style = WBorderLineStyle.THICK;
      break;
    case CellStyle.BORDER_DOUBLE:
      style = WBorderLineStyle.DOUBLE;
      break;
    case CellStyle.BORDER_HAIR:
      style = WBorderLineStyle.HAIR;
      break;
    case CellStyle.BORDER_MEDIUM_DASHED:
      style = WBorderLineStyle.MEDIUM_DASHED;
      break;
    case CellStyle.BORDER_DASH_DOT:
      style = WBorderLineStyle.DASH_DOT;
      break;
    case CellStyle.BORDER_MEDIUM_DASH_DOT:
      style = WBorderLineStyle.MEDIUM_DASH_DOT;
      break;
    case CellStyle.BORDER_MEDIUM_DASH_DOT_DOT:
      style = WBorderLineStyle.MEDIUM_DASH_DOT_DOT;
      break;
    case CellStyle.BORDER_SLANTED_DASH_DOT:
      style = WBorderLineStyle.SLANTED_DASH_DOT;
      break;
    default:
      style = WBorderLineStyle.NONE;
      break;
  }
  return style;
}