jxl.format.Border Java Examples

The following examples show how to use jxl.format.Border. 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: DownloadFileService.java    From pacbot with Apache License 2.0 8 votes vote down vote up
/**
 * Format writable sheet.
 *
 * @param writablesheet the writable sheet
 * @param columns the columns
 * @throws WriteException the write exception
 */
private void formatWritableSheet(WritableSheet writablesheet,List<String>columns) throws WriteException {
    WritableFont cellFonts = new WritableFont(WritableFont.createFont("Calibri"), ELEVEN, WritableFont.BOLD, false,
            UnderlineStyle.NO_UNDERLINE, jxl.format.Colour.BLACK);
    WritableCellFormat cellFormats = new WritableCellFormat(cellFonts);
    cellFormats.setBorder(Border.ALL, BorderLineStyle.THIN);
    cellFormats.setBackground(Colour.WHITE);
    int labelIndex = 0;
    for (String clm : columns) {
        writablesheet.addCell(new Label(labelIndex, 0, clm.replaceAll("_", ""), cellFormats));
        CellView cell = writablesheet.getColumnView(labelIndex);
        cell.setAutosize(true);
        writablesheet.setColumnView(labelIndex, cell);
        labelIndex++;
    }
}
 
Example #2
Source File: JxlWCellFormatImpl.java    From xlsbeans with Apache License 2.0 6 votes vote down vote up
public WBorderLineStyle getBorder(WBorder border) {
  BorderLineStyle borderLineStyle = null;
  if (WBorder.ALL.equals(border)) {
    borderLineStyle = format.getBorder(Border.ALL);
  } else if (WBorder.BOTTOM.equals(border)) {
    borderLineStyle = format.getBorder(Border.BOTTOM);
  } else if (WBorder.LEFT.equals(border)) {
    borderLineStyle = format.getBorder(Border.LEFT);
  } else if (WBorder.NONE.equals(border)) {
    borderLineStyle = format.getBorder(Border.NONE);
  } else if (WBorder.RIGHT.equals(border)) {
    borderLineStyle = format.getBorder(Border.RIGHT);
  } else if (WBorder.TOP.equals(border)) {
    borderLineStyle = format.getBorder(Border.TOP);
  }
  if (borderLineStyle == null) {
    throw new IllegalArgumentException("Not support border style.");
  }
  return new WBorderLineStyle(borderLineStyle.getValue(), borderLineStyle.getDescription());
}
 
Example #3
Source File: JxlWCellFormatImpl.java    From xlsbeans with Apache License 2.0 6 votes vote down vote up
public WBorderLineStyle getBorder(WBorder border) {
  BorderLineStyle borderLineStyle = null;
  if (WBorder.ALL.equals(border)) {
    borderLineStyle = format.getBorder(Border.ALL);
  } else if (WBorder.BOTTOM.equals(border)) {
    borderLineStyle = format.getBorder(Border.BOTTOM);
  } else if (WBorder.LEFT.equals(border)) {
    borderLineStyle = format.getBorder(Border.LEFT);
  } else if (WBorder.NONE.equals(border)) {
    borderLineStyle = format.getBorder(Border.NONE);
  } else if (WBorder.RIGHT.equals(border)) {
    borderLineStyle = format.getBorder(Border.RIGHT);
  } else if (WBorder.TOP.equals(border)) {
    borderLineStyle = format.getBorder(Border.TOP);
  }
  if (borderLineStyle == null) {
    throw new IllegalArgumentException("Not support border style.");
  }
  return new WBorderLineStyle(borderLineStyle.getValue(), borderLineStyle.getDescription());
}
 
Example #4
Source File: DownloadFileService.java    From pacbot with Apache License 2.0 5 votes vote down vote up
/**
 * Adds the writable sheet cells.
 *
 * @param writablesheet the writablesheet
 * @param issueDetails the issue details
 * @param columns the columns
 * @throws WriteException the write exception
 */
private void addWritableSheetCells(WritableSheet writablesheet, JsonArray issueDetails,List<String>columns) throws WriteException {
    WritableFont cellFont = new WritableFont(WritableFont.createFont("Calibri"), TWELVE);
    cellFont.setColour(Colour.BLACK);
    WritableCellFormat cellFormat = new WritableCellFormat(cellFont);
    cellFormat.setBackground(Colour.WHITE);
    cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.GRAY_25);
    for (int columnIndex = 0; columnIndex < issueDetails.size(); columnIndex++) {
        JsonObject issueDetail = issueDetails.get(columnIndex).getAsJsonObject();
        addCell(writablesheet, issueDetail, cellFormat, columnIndex,columns);
    }
}
 
Example #5
Source File: TableOutputter.java    From morf with Apache License 2.0 5 votes vote down vote up
/**
 * @return the format to use for bold cells
 * @throws WriteException if the format could not be created
 */
private WritableCellFormat getBoldFormat() throws WriteException {
  WritableFont boldFont = new WritableFont(WritableFont.ARIAL, 8, WritableFont.BOLD);
  WritableCellFormat boldHeading = new WritableCellFormat(boldFont);
  boldHeading.setBorder(Border.BOTTOM, BorderLineStyle.MEDIUM);
  boldHeading.setVerticalAlignment(VerticalAlignment.CENTRE);
  boldHeading.setBackground(Colour.GRAY_25);


  WritableCellFormat boldFormat = new WritableCellFormat(boldFont);
  boldFormat.setVerticalAlignment(VerticalAlignment.TOP);
  return boldFormat;
}