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);
}
}
}
}
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;
}
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;
}
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++;
}
}
Aggregations