use of jxl.write.WriteException in project cubrid-manager by CUBRID.
the class ExportTableDefinitionLayoutType method getNormalLeftAlignCellStyle.
/**
* GetNormalLeftAlignCellStyle
*
* @return WritableCellFormat
*/
public static WritableCellFormat getNormalLeftAlignCellStyle() {
WritableFont font = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat format = new WritableCellFormat(font);
try {
format.setAlignment(jxl.format.Alignment.LEFT);
format.setVerticalAlignment(jxl.format.VerticalAlignment.TOP);
format.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
format.setWrap(true);
} catch (WriteException e) {
LOGGER.error("", e);
}
return format;
}
use of jxl.write.WriteException in project cubrid-manager by CUBRID.
the class ExportTableDefinitionLayoutType method getBoldCenterAlignCellStyle.
/**
* GetNormalCell
*
* @return WritableCellFormat
*/
public static WritableCellFormat getBoldCenterAlignCellStyle() {
WritableFont font = new WritableFont(WritableFont.ARIAL, 10);
WritableCellFormat format = new WritableCellFormat(font);
try {
font.setBoldStyle(WritableFont.BOLD);
format.setAlignment(jxl.format.Alignment.CENTRE);
format.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
format.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
format.setBackground(jxl.format.Colour.GREY_25_PERCENT);
format.setWrap(true);
} catch (WriteException e) {
LOGGER.error("", e);
}
return format;
}
use of jxl.write.WriteException in project cubrid-manager by CUBRID.
the class RunSQLEventHandler method getNormalCell.
/**
* Return the normal cell format.
*
* @return WritableCellFormat
*/
public static WritableCellFormat getNormalCell() {
// FIXME logic code move to core module
WritableFont font = new WritableFont(WritableFont.TIMES, 12);
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) {
LOGGER.error(e.getMessage(), e);
}
return format;
}
use of jxl.write.WriteException in project cubrid-manager by CUBRID.
the class Export method exportXls.
/**
* export all data in Query Editor result table cache as xls
*
* @param monitor IProgressMonitor
* @throws IOException if failed
* @throws FileNotFoundException if failed
* @throws UnsupportedEncodingException if failed
* @throws RowsExceededException if failed
* @throws NumberFormatException if failed
* @throws WriteException if failed
*
*/
private void exportXls(final IProgressMonitor monitor) throws IOException, FileNotFoundException, UnsupportedEncodingException, RowsExceededException, NumberFormatException, WriteException {
// FIXME move this logic to core module
workbook = null;
try {
if (fileCharset == null || fileCharset.trim().length() == 0) {
workbook = Workbook.createWorkbook(file);
} else {
WorkbookSettings workbookSettings = new WorkbookSettings();
workbookSettings.setEncoding(fileCharset);
workbook = Workbook.createWorkbook(file, workbookSettings);
}
int totalSheetNum = 0;
// 65536: limit xls row number except the column row
final int rowLimit = ImportFileConstants.XLS_ROW_LIMIT - 1;
// 256: limit xls column number..
final int columnLimit = ImportFileConstants.XLS_COLUMN_LIMIT;
for (int k = 0; k < resultDataList.size(); k++) {
List<ColumnInfo> columnList = resultColsList.get(k);
List<Map<String, String>> dataList = resultDataList.get(k);
WritableSheet sheet = workbook.createSheet("Sheet " + (k + 1), totalSheetNum++);
int colCount = columnList.size();
int itemCount = dataList.size();
if (colCount > columnLimit) {
if (!CommonUITool.openConfirmBox(Messages.columnCountOver)) {
return;
}
colCount = columnLimit;
}
//export columns
exportColumnsForXls(sheet, k, columnLimit);
int sheetNum = 0;
for (int i = 0, xlsRecordNum = 1; i < itemCount; i++) {
if (!CommonUITool.isAvailableMemory(ExportTableDataTask.REMAINING_MEMORY_SIZE)) {
throw new OutOfMemoryError();
}
int start = 0;
for (int j = start; j < colCount; j++) {
String colType = columnList.get(j).getType();
String colIndex = columnList.get(j).getIndex();
String value = dataList.get(i).get(colIndex);
int colNumber = j - start;
FieldHandlerUtils.setValue2XlsCell(sheet, colNumber, xlsRecordNum, colType, value);
}
xlsRecordNum++;
if (((i + 1) % rowLimit) == 0 && (i + 1) < itemCount) {
sheetNum++;
sheet = workbook.createSheet("Sheet " + (k + 1) + "_" + sheetNum, totalSheetNum++);
exportColumnsForXls(sheet, k, columnLimit);
xlsRecordNum = 1;
}
exportedCount++;
monitor.subTask(Messages.bind(com.cubrid.common.ui.cubrid.table.Messages.msgExportDataRow, exportedCount));
}
}
} finally {
try {
if (workbook != null) {
workbook.write();
}
} finally {
try {
if (workbook != null) {
workbook.close();
}
} catch (WriteException e) {
LOGGER.error("", e);
} catch (IOException e) {
LOGGER.error("", e);
}
}
}
}
use of jxl.write.WriteException 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;
}
Aggregations