Search in sources :

Example 21 with WritableCellFormat

use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.

the class ExportErrorDataProgress method run.

/* (non-Javadoc)
	 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
	 */
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    // FIXME logic code move to core module
    WritableWorkbook wwb = null;
    try {
        WorkbookSettings workbookSettings = new WorkbookSettings();
        workbookSettings.setEncoding(charset);
        wwb = Workbook.createWorkbook(new File(filePath), workbookSettings);
        int index = 0;
        for (Entry<String, List<SqlRunnerFailed>> entry : failedListMap.entrySet()) {
            WritableSheet ws = wwb.createSheet(entry.getKey(), index++);
            WritableCellFormat normalCellStyle = getNormalCell();
            WritableCellFormat titleCellStyle = getTitleCell();
            jxl.write.Label header = new jxl.write.Label(0, 0, Messages.failedSQLlineNumber, titleCellStyle);
            ws.addCell(header);
            jxl.write.Label header1 = new jxl.write.Label(1, 0, Messages.failedSQL, titleCellStyle);
            ws.addCell(header1);
            jxl.write.Label header2 = new jxl.write.Label(2, 0, Messages.failedErrorMessage, titleCellStyle);
            ws.addCell(header2);
            ws.setColumnView(1, 100);
            ws.setColumnView(2, 80);
            for (int j = 0; j < entry.getValue().size(); j++) {
                SqlRunnerFailed failedInfo = entry.getValue().get(j);
                int row = j + 1;
                jxl.write.Number lineNmuber = new jxl.write.Number(0, row, failedInfo.getLineIndex(), normalCellStyle);
                ws.addCell(lineNmuber);
                jxl.write.Label sql = new jxl.write.Label(1, row, failedInfo.getSql(), normalCellStyle);
                ws.addCell(sql);
                jxl.write.Label errMessage = new jxl.write.Label(2, row, failedInfo.getErrorMessage(), normalCellStyle);
                ws.addCell(errMessage);
            }
        }
        wwb.write();
        success = true;
    } catch (Exception e) {
        LOGGER.error("write excel error", e);
        errMsg = e.getMessage();
    } finally {
        if (wwb != null) {
            try {
                wwb.close();
            } catch (Exception e) {
                LOGGER.error("close excel error", e);
            }
        }
    }
}
Also used : WorkbookSettings(jxl.WorkbookSettings) WritableSheet(jxl.write.WritableSheet) WritableCellFormat(jxl.write.WritableCellFormat) InvocationTargetException(java.lang.reflect.InvocationTargetException) WriteException(jxl.write.WriteException) WritableWorkbook(jxl.write.WritableWorkbook) SqlRunnerFailed(com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed) List(java.util.List) File(java.io.File)

Example 22 with WritableCellFormat

use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.

the class RunSQLProcessManager method createaWritableSheet.

/**
	 * create excel sheet
	 * @param wwb
	 * @param fileName
	 * @param index
	 * @return
	 */
public WritableSheet createaWritableSheet(WritableWorkbook wwb, String fileName, int index) {
    // FIXME logic code move to core module
    WritableSheet ws = null;
    try {
        ws = wwb.createSheet(fileName, index);
        WritableCellFormat normalCellStyle = getNormalCell();
        jxl.write.Label header = new jxl.write.Label(0, 0, Messages.failedSQLlineNumber, normalCellStyle);
        ws.addCell(header);
        jxl.write.Label header1 = new jxl.write.Label(1, 0, Messages.failedSQL, normalCellStyle);
        ws.addCell(header1);
        jxl.write.Label header2 = new jxl.write.Label(2, 0, Messages.failedErrorMessage, normalCellStyle);
        ws.addCell(header2);
        ws.setColumnView(1, 100);
        ws.setColumnView(2, 80);
    } catch (Exception e) {
        ws = null;
        LOGGER.error("create WritableSheet error", e);
    }
    return ws;
}
Also used : WritableSheet(jxl.write.WritableSheet) WritableCellFormat(jxl.write.WritableCellFormat) WriteException(jxl.write.WriteException)

Example 23 with WritableCellFormat

use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.

the class ExportHostStatusDialog method getNormalCell.

/**
	 * getNormalCell
	 * 
	 * @return WritableCellFormat
	 */
public static WritableCellFormat getNormalCell() {
    WritableFont font = new WritableFont(WritableFont.TIMES, 11);
    WritableCellFormat format = new WritableCellFormat(font);
    try {
        format.setAlignment(jxl.format.Alignment.LEFT);
        format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
        format.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
        format.setWrap(true);
    } catch (WriteException e) {
        e.printStackTrace();
    }
    return format;
}
Also used : WriteException(jxl.write.WriteException) WritableFont(jxl.write.WritableFont) WritableCellFormat(jxl.write.WritableCellFormat)

Example 24 with WritableCellFormat

use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.

the class ExportHostStatusDialog method saveDBInfoData.

private void saveDBInfoData(Table dbInfoTable, String sheetName, int sheetIndex) throws RowsExceededException, WriteException {
    WritableCellFormat normalCellStyle = getNormalCell();
    WritableSheet ws = wwb.createSheet(sheetName, sheetIndex);
    int rowIndex = 0;
    //title
    for (int j = 0; j < dbInfoTable.getColumnCount(); j++) {
        String cellString = dbInfoTable.getColumn(j).getText();
        ws.addCell(new jxl.write.Label(j, rowIndex, cellString, normalCellStyle));
        ws.setColumnView(j, 30);
    }
    rowIndex++;
    //row
    for (int j = 0; j < dbInfoTable.getItemCount(); j++) {
        TableItem tableItem = dbInfoTable.getItem(j);
        for (int k = 0; k < dbInfoTable.getColumnCount(); k++) {
            String cellString = tableItem.getText(k);
            if (k == 1) {
                if ((Boolean) tableItem.getData("isChecked")) {
                    cellString = "Y";
                } else {
                    cellString = "N";
                }
            }
            ws.addCell(new jxl.write.Label(k, rowIndex, cellString, normalCellStyle));
        }
        rowIndex++;
    }
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) WritableSheet(jxl.write.WritableSheet) WritableCellFormat(jxl.write.WritableCellFormat)

Aggregations

WritableCellFormat (jxl.write.WritableCellFormat)24 WritableFont (jxl.write.WritableFont)17 WriteException (jxl.write.WriteException)17 WritableSheet (jxl.write.WritableSheet)10 WorkbookSettings (jxl.WorkbookSettings)6 WritableWorkbook (jxl.write.WritableWorkbook)6 Label (jxl.write.Label)3 TableItem (org.eclipse.swt.widgets.TableItem)3 File (java.io.File)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 List (java.util.List)2 SqlRunnerFailed (com.cubrid.common.ui.common.sqlrunner.model.SqlRunnerFailed)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 CUBRIDResultSetMetaDataProxy (com.cubrid.jdbc.proxy.driver.CUBRIDResultSetMetaDataProxy)1 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SQLException (java.sql.SQLException)1