public String getWorksheetName() { Workbook currentWorkbook = workbooks.get(workbook).getWorkbook(); return currentWorkbook.getSheetName(worksheetIndex); }
public String getWorksheetName() { Workbook currentWorkbook = workbooks.get(workbook).getWorkbook(); return currentWorkbook.getSheetName(worksheetIndex); }
public List<SelectItem> getWorksheets() { if (workbook == null || workbooks == null) { return Collections.emptyList(); } XlsWorkbookSourceCodeModule currentSheet = workbooks.get(workbook); if (currentSheet == null) { return Collections.emptyList(); } Workbook workbook = currentSheet.getWorkbook(); List<SelectItem> items = new ArrayList<SelectItem>(workbook.getNumberOfSheets()); for (int i = 0; i < workbook.getNumberOfSheets(); ++i) { items.add(new SelectItem(i, workbook.getSheetName(i))); } return items; }
public List<SelectItem> getWorksheets() { if (workbook == null || workbooks == null) { return Collections.emptyList(); } XlsWorkbookSourceCodeModule currentSheet = workbooks.get(workbook); if (currentSheet == null) { return Collections.emptyList(); } Workbook workbook = currentSheet.getWorkbook(); List<SelectItem> items = new ArrayList<SelectItem>(workbook.getNumberOfSheets()); for (int i = 0; i < workbook.getNumberOfSheets(); ++i) { items.add(new SelectItem(i, workbook.getSheetName(i))); } Collections.sort(items, new Comparator<SelectItem>() { @Override public int compare(SelectItem item1, SelectItem item2) { return item1.getLabel().compareToIgnoreCase(item2.getLabel()); } }); return items; }
public List<SelectItem> getWorksheets() { if (workbook == null || workbooks == null) { return Collections.emptyList(); } XlsWorkbookSourceCodeModule currentSheet = workbooks.get(workbook); if (currentSheet == null) { return Collections.emptyList(); } Workbook workbook = currentSheet.getWorkbook(); List<SelectItem> items = new ArrayList<SelectItem>(workbook.getNumberOfSheets()); for (int i = 0; i < workbook.getNumberOfSheets(); ++i) { items.add(new SelectItem(i, workbook.getSheetName(i))); } Collections.sort(items, new Comparator<SelectItem>() { @Override public int compare(SelectItem item1, SelectItem item2) { return item1.getLabel().compareToIgnoreCase(item2.getLabel()); } }); return items; }
public void saveAs(String fileName) throws IOException { for (XlsWorkbookListener wl : listeners) { wl.beforeSave(this); } OutputStream fileOut = new DeferredCreateFileOutputStream(fileName); getWorkbook().write(fileOut); fileOut.close(); for (XlsWorkbookListener wl : listeners) { wl.afterSave(this); } }
protected XlsSheetSourceCodeModule getDestinationSheet() { XlsSheetSourceCodeModule sourceCodeModule; XlsWorkbookSourceCodeModule module = workbooks.get(workbook); if (newWorksheet) { Sheet sheet = module.getWorkbook().createSheet(getNewWorksheetName()); sourceCodeModule = new XlsSheetSourceCodeModule(sheet, getNewWorksheetName(), module); } else { Sheet sheet = module.getWorkbook().getSheetAt(getWorksheetIndex()); sourceCodeModule = new XlsSheetSourceCodeModule(sheet, module.getWorkbook().getSheetName( getWorksheetIndex()), module); } return sourceCodeModule; }
private void initWorkbookColors() { if (!(getWorkbook() instanceof HSSFWorkbook)) { return; } Workbook workbook = getWorkbook(); int numStyles = workbook.getNumCellStyles(); for (int i = 0; i < numStyles; i++) { CellStyle cellStyle = workbook.getCellStyleAt(i); wbColors.add(cellStyle.getFillForegroundColor()); wbColors.add(cellStyle.getFillBackgroundColor()); wbColors.add(cellStyle.getTopBorderColor()); wbColors.add(cellStyle.getBottomBorderColor()); wbColors.add(cellStyle.getLeftBorderColor()); wbColors.add(cellStyle.getRightBorderColor()); } int numFonts = workbook.getNumberOfFontsAsInt(); for (int i = 0; i < numFonts; i++) { Font font = workbook.getFontAt(i); wbColors.add(font.getColor()); } }
protected XlsSheetSourceCodeModule getDestinationSheet() { XlsSheetSourceCodeModule sourceCodeModule; XlsWorkbookSourceCodeModule module = workbooks.get(workbook); if (newWorksheet) { Sheet sheet = module.getWorkbook().createSheet(getNewWorksheetName()); sourceCodeModule = new XlsSheetSourceCodeModule(new SimpleSheetLoader(sheet), module); } else { Sheet sheet = module.getWorkbook().getSheetAt(getWorksheetIndex()); sourceCodeModule = new XlsSheetSourceCodeModule(new SimpleSheetLoader(sheet), module); } return sourceCodeModule; }
protected XlsSheetSourceCodeModule getDestinationSheet() { XlsSheetSourceCodeModule sourceCodeModule; XlsWorkbookSourceCodeModule module = workbooks.get(workbook); if (newWorksheet) { Sheet sheet = module.getWorkbook().createSheet(getNewWorksheetName()); sourceCodeModule = new XlsSheetSourceCodeModule(new SimpleSheetLoader(sheet), module); } else { Sheet sheet = module.getWorkbook().getSheetAt(getWorksheetIndex()); sourceCodeModule = new XlsSheetSourceCodeModule(new SimpleSheetLoader(sheet), module); } return sourceCodeModule; }
private void setCellStyle(Cell cell, CellStyle cellStyle) { CellStyle newStyle = style2style.get(cellStyle); if (newStyle != null) { cellStyle = newStyle; } try { cell.setCellStyle(cellStyle); } catch (Exception e) { CellStyle style = findWorkbookCellStyle(cellStyle); if (style != null) { style2style.put(cellStyle, style); } else { Workbook workbook = gridModel.getSheetSource().getWorkbookSource().getWorkbook(); style = PoiExcelHelper.createCellStyle(workbook); try { style.cloneStyleFrom(cellStyle); } catch (IllegalArgumentException ex) { // FIXME: remove try.. catch } style2style.put(cellStyle, style); } cell.setCellStyle(style); } }
private CellStyle findWorkbookCellStyle(CellStyle cellStyle) { Workbook workbook = gridModel.getSheetSource().getWorkbookSource().getWorkbook(); int numCellStyles = workbook.getNumCellStyles(); for (int i = 0; i < numCellStyles; i++) { CellStyle cellStyleAt = workbook.getCellStyleAt((short) i); if (equalsStyle(cellStyleAt, cellStyle)) { return cellStyleAt; } } return null; }
public boolean beforeSaveAction() { String editorId = FacesUtils.getRequestParameter( org.openl.rules.tableeditor.util.Constants.REQUEST_PARAM_EDITOR_ID); Map<?, ?> editorModelMap = (Map<?, ?>) FacesUtils.getSessionParam( org.openl.rules.tableeditor.util.Constants.TABLE_EDITOR_MODEL_NAME); TableEditorModel editorModel = (TableEditorModel) editorModelMap.get(editorId); Workbook workbook = editorModel.getSheetSource().getWorkbookSource().getWorkbook(); if (workbook instanceof XSSFWorkbook) { XSSFOptimizer.removeUnusedStyles((XSSFWorkbook) workbook); } if (WebStudioUtils.getWebStudio().isUpdateSystemProperties()) { return EditHelper.updateSystemProperties(table, editorModel, WebStudioUtils.getWebStudio().getSystemConfigManager().getStringProperty("user.mode")); } return true; }
/** * Initializes default cell style. * * @return cell style */ protected CellStyle getDefaultCellStyle() { if (defaultCellStyle == null) { Workbook workbook = gridModel.getSheetSource().getWorkbookSource().getWorkbook(); CellStyle cellStyle = PoiExcelHelper.createCellStyle(workbook); cellStyle.setBorderBottom(BorderStyle.THIN); cellStyle.setBorderTop(BorderStyle.THIN); cellStyle.setBorderLeft(BorderStyle.THIN); cellStyle.setBorderRight(BorderStyle.THIN); defaultCellStyle = cellStyle; } return defaultCellStyle; }
public boolean beforeSaveAction() { String editorId = FacesUtils.getRequestParameter( org.openl.rules.tableeditor.util.Constants.REQUEST_PARAM_EDITOR_ID); Map<?, ?> editorModelMap = (Map<?, ?>) FacesUtils.getSessionParam( org.openl.rules.tableeditor.util.Constants.TABLE_EDITOR_MODEL_NAME); TableEditorModel editorModel = (TableEditorModel) editorModelMap.get(editorId); Workbook workbook = editorModel.getSheetSource().getWorkbookSource().getWorkbook(); if (workbook instanceof XSSFWorkbook) { XSSFOptimizer.removeUnusedStyles((XSSFWorkbook) workbook); } if (WebStudioUtils.getWebStudio().isUpdateSystemProperties()) { return EditHelper.updateSystemProperties(table, editorModel, WebStudioUtils.getWebStudio().getSystemConfigManager().getStringProperty("user.mode")); } return true; }
protected CellStyle getDefaultDateCellStyle() { if (defaultDateCellStyle == null) { Workbook workbook = gridModel.getSheetSource().getWorkbookSource().getWorkbook(); CellStyle cellStyle = PoiExcelHelper.createCellStyle(workbook); cellStyle.setBorderBottom(BorderStyle.THIN); cellStyle.setBorderTop(BorderStyle.THIN); cellStyle.setBorderLeft(BorderStyle.THIN); cellStyle.setBorderRight(BorderStyle.THIN); cellStyle.setDataFormat((short) BuiltinFormats.getBuiltinFormat(FormatConstants.DEFAULT_XLS_DATE_FORMAT)); defaultDateCellStyle = cellStyle; } return defaultDateCellStyle; }
public XlsCellStyle getCellStyle(JSONObject style) { if (style != null) { Workbook workbook = gridModel.getSheetSource() .getWorkbookSource().getWorkbook(); } else { Workbook workbook = gridModel.getSheetSource() .getWorkbookSource().getWorkbook(); CellStyle cellStyle = PoiExcelHelper.createCellStyle(workbook);
public XlsCellStyle getCellStyle(JSONObject style) { if (style != null) { Workbook workbook = gridModel.getSheetSource() .getWorkbookSource().getWorkbook(); } else { Workbook workbook = gridModel.getSheetSource() .getWorkbookSource().getWorkbook(); CellStyle cellStyle = PoiExcelHelper.createCellStyle(workbook);