Search in sources :

Example 6 with CellView

use of jxl.CellView in project OpenClinica by OpenClinica.

the class ExportExcelStudySubjectAuditLogServlet method autoSizeColumns.

private void autoSizeColumns(WritableSheet sheet) {
    for (int x = 0; x < 6; x++) {
        CellView cell = sheet.getColumnView(x);
        cell.setAutosize(true);
        sheet.setColumnView(x, cell);
    }
}
Also used : CellView(jxl.CellView)

Example 7 with CellView

use of jxl.CellView in project aws-doc-sdk-examples by awsdocs.

the class WriteExcel method createLabel.

// Create headings in the Excel spreadsheet.
private void createLabel(WritableSheet sheet) throws WriteException {
    // Create a Times font.
    WritableFont times10pt = new WritableFont(WritableFont.TIMES, 10);
    // Define the cell format.
    times = new WritableCellFormat(times10pt);
    // Automatically wrap the cells.
    times.setWrap(true);
    // Create a bold font with underlining.
    WritableFont times10ptBoldUnderline = new WritableFont(WritableFont.TIMES, 10, WritableFont.BOLD, false, UnderlineStyle.SINGLE);
    timesBoldUnderline = new WritableCellFormat(times10ptBoldUnderline);
    // Automatically wrap the cells.
    timesBoldUnderline.setWrap(true);
    CellView cv = new CellView();
    cv.setFormat(times);
    cv.setFormat(timesBoldUnderline);
    cv.setAutosize(true);
    // Write a few headers.
    addCaption(sheet, 0, 0, "Writer");
    addCaption(sheet, 1, 0, "Date");
    addCaption(sheet, 2, 0, "Guide");
    addCaption(sheet, 3, 0, "Description");
    addCaption(sheet, 4, 0, "Status");
}
Also used : WritableFont(jxl.write.WritableFont) WritableCellFormat(jxl.write.WritableCellFormat) CellView(jxl.CellView)

Example 8 with CellView

use of jxl.CellView in project network-monitor by caarmen.

the class ExcelExport method writeFooter.

@Override
void writeFooter() throws IOException {
    Log.v(TAG, "writeFooter");
    try {
        for (int i = 0; i < mColumnCount; i++) resizeColumn(i);
        // Set the heading row height to 4 lines tall.  Using autoSize doesn't seem to work (the resulting file has only one row of characters in the header row).
        // Not sure how to dynamically calculate the optimal height of the header row, so we just assume the largest column heading will be four lines tall.
        CellView headerRowView = mSheet.getRowView(0);
        headerRowView.setSize(headerRowView.getSize() * 4);
        mSheet.setRowView(0, headerRowView);
        mWorkbook.write();
        mWorkbook.close();
    } catch (JXLException e) {
        Log.e(TAG, "writeHeader Could not close file", e);
    }
}
Also used : JXLException(jxl.JXLException) CellView(jxl.CellView)

Aggregations

CellView (jxl.CellView)8 WritableCellFormat (jxl.write.WritableCellFormat)5 WritableFont (jxl.write.WritableFont)5 JXLException (jxl.JXLException)1