use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.
the class ExportDashboardDialog method exportTableList.
/**
* export dashboard table list
* @return boolean sucess
*/
public boolean exportTableList() throws Exception {
WritableWorkbook wwb = null;
WritableSheet ws = null;
String fileName = saveExcelPath.getText() + saveExcelName.getText() + ".xls";
try {
WritableCellFormat normalCellStyle = getNormalCell();
WorkbookSettings workbookSettings = new WorkbookSettings();
workbookSettings.setEncoding(fileCharsetCombo.getText());
wwb = Workbook.createWorkbook(new File(fileName), workbookSettings);
for (int i = 0; i < exportTableList.size(); i++) {
ws = wwb.createSheet(sheetNames[i], i);
Table table = exportTableList.get(i);
int rowIndex = 0;
//title
for (int j = 0; j < table.getColumnCount(); j++) {
String cellString = table.getColumn(j).getText();
ws.addCell(new jxl.write.Label(j, rowIndex, cellString, normalCellStyle));
ws.setColumnView(j, 30);
}
rowIndex++;
//row
for (int j = 0; j < table.getItemCount(); j++) {
TableItem tableItem = table.getItem(j);
for (int k = 0; k < table.getColumnCount(); k++) {
String cellString = tableItem.getText(k);
ws.addCell(new jxl.write.Label(k, rowIndex, cellString, normalCellStyle));
}
rowIndex++;
}
}
wwb.write();
return true;
} catch (Exception e) {
LOGGER.error(e.getMessage());
throw e;
} finally {
if (wwb != null) {
try {
wwb.close();
} catch (Exception ex) {
LOGGER.error("close excel stream error", ex);
}
}
}
}
use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.
the class ImportResultDialog method getNormolCell.
public static WritableCellFormat getNormolCell() {
// FIXME move this logic 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) {
e.printStackTrace();
}
return format;
}
use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.
the class ExportToXlsHandler method writeHeader.
/**
* Write the sheet header
*
* @param sheet
* @param columnNameList
* @throws RowsExceededException
* @throws WriteException
*/
private void writeHeader(WritableSheet sheet, List<String> columnNameList) throws RowsExceededException, WriteException {
// FIXME move this logic to core module
WritableFont wf = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD, false);
WritableCellFormat wcf = new WritableCellFormat(wf);
for (int columnIndex = 0; columnIndex < columnNameList.size(); columnIndex++) {
String columnName = columnNameList.get(columnIndex);
Label label = new Label(columnIndex, 0, columnName, wcf);
sheet.addCell(label);
label = null;
}
wcf = null;
wf = null;
}
use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.
the class ExportHostStatusDialog method saveTableData.
private void saveTableData(String columnName, String content, String sheetName, int sheetIndex) throws RowsExceededException, WriteException {
WritableCellFormat normalCellStyle = getNormalCell();
WritableSheet ws = wwb.createSheet(sheetName, sheetIndex);
ws.addCell(new jxl.write.Label(0, 0, columnName, normalCellStyle));
ws.setColumnView(0, 30);
ws.addCell(new jxl.write.Label(0, 1, content, normalCellStyle));
}
use of jxl.write.WritableCellFormat in project cubrid-manager by CUBRID.
the class ExportHostStatusDialog method saveTableData.
private void saveTableData(Table table, 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 < table.getColumnCount(); j++) {
String cellString = table.getColumn(j).getText();
ws.addCell(new jxl.write.Label(j, rowIndex, cellString, normalCellStyle));
ws.setColumnView(j, 30);
}
rowIndex++;
//row
for (int j = 0; j < table.getItemCount(); j++) {
TableItem tableItem = table.getItem(j);
for (int k = 0; k < table.getColumnCount(); k++) {
String cellString = tableItem.getText(k);
ws.addCell(new jxl.write.Label(k, rowIndex, cellString, normalCellStyle));
}
rowIndex++;
}
}
Aggregations