/** * Default constructor */ public SheetSettings(Sheet s) { sheet = s; // for internal use, when accessing ranges orientation = DEFAULT_ORIENTATION; pageOrder = DEFAULT_ORDER; paperSize = DEFAULT_PAPER_SIZE; sheetProtected = false; hidden = false; selected = false; headerMargin = DEFAULT_HEADER_MARGIN; footerMargin = DEFAULT_FOOTER_MARGIN; horizontalPrintResolution = DEFAULT_PRINT_RESOLUTION; verticalPrintResolution = DEFAULT_PRINT_RESOLUTION; leftMargin = DEFAULT_WIDTH_MARGIN; rightMargin = DEFAULT_WIDTH_MARGIN; topMargin = DEFAULT_HEIGHT_MARGIN; bottomMargin = DEFAULT_HEIGHT_MARGIN; fitToPages = false; showGridLines = true; printGridLines = false; printHeaders = false; pageBreakPreviewMode = false; displayZeroValues = true; defaultColumnWidth = DEFAULT_DEFAULT_COLUMN_WIDTH; defaultRowHeight = DEFAULT_DEFAULT_ROW_HEIGHT; zoomFactor = DEFAULT_ZOOM_FACTOR; pageBreakPreviewMagnification = DEFAULT_PAGE_BREAK_PREVIEW_MAGNIFICATION; normalMagnification = DEFAULT_NORMAL_MAGNIFICATION; horizontalFreeze = 0; verticalFreeze = 0; copies = 1; header = new HeaderFooter(); footer = new HeaderFooter(); automaticFormulaCalculation = true; recalculateFormulasBeforeSave = true; }
/** * Copy constructor. Called when copying sheets * @param copy the settings to copy */ public SheetSettings(SheetSettings copy, Sheet s) { Assert.verify(copy != null); sheet = s; // for internal use when accessing ranges orientation = copy.orientation; pageOrder = copy.pageOrder; paperSize = copy.paperSize; sheetProtected = copy.sheetProtected; hidden = copy.hidden; selected = false; // don't copy the selected flag headerMargin = copy.headerMargin; footerMargin = copy.footerMargin; scaleFactor = copy.scaleFactor; pageStart = copy.pageStart; fitWidth = copy.fitWidth; fitHeight = copy.fitHeight; horizontalPrintResolution = copy.horizontalPrintResolution; verticalPrintResolution = copy.verticalPrintResolution; leftMargin = copy.leftMargin; rightMargin = copy.rightMargin; topMargin = copy.topMargin; bottomMargin = copy.bottomMargin; fitToPages = copy.fitToPages; password = copy.password; passwordHash = copy.passwordHash; defaultColumnWidth = copy.defaultColumnWidth; defaultRowHeight = copy.defaultRowHeight; zoomFactor = copy.zoomFactor; pageBreakPreviewMagnification = copy.pageBreakPreviewMagnification; normalMagnification = copy.normalMagnification; showGridLines = copy.showGridLines; displayZeroValues = copy.displayZeroValues; pageBreakPreviewMode = copy.pageBreakPreviewMode; horizontalFreeze = copy.horizontalFreeze; verticalFreeze = copy.verticalFreeze; horizontalCentre = copy.horizontalCentre; verticalCentre = copy.verticalCentre; copies = copy.copies; header = new HeaderFooter(copy.header); footer = new HeaderFooter(copy.footer); automaticFormulaCalculation = copy.automaticFormulaCalculation; recalculateFormulasBeforeSave = copy.recalculateFormulasBeforeSave; if (copy.printArea != null) { printArea = new SheetRangeImpl (sheet, copy.getPrintArea().getTopLeft().getColumn(), copy.getPrintArea().getTopLeft().getRow(), copy.getPrintArea().getBottomRight().getColumn(), copy.getPrintArea().getBottomRight().getRow()); } if (copy.printTitlesRow != null) { printTitlesRow = new SheetRangeImpl (sheet, copy.getPrintTitlesRow().getTopLeft().getColumn(), copy.getPrintTitlesRow().getTopLeft().getRow(), copy.getPrintTitlesRow().getBottomRight().getColumn(), copy.getPrintTitlesRow().getBottomRight().getRow()); } if (copy.printTitlesCol != null) { printTitlesCol = new SheetRangeImpl (sheet, copy.getPrintTitlesCol().getTopLeft().getColumn(), copy.getPrintTitlesCol().getTopLeft().getRow(), copy.getPrintTitlesCol().getBottomRight().getColumn(), copy.getPrintTitlesCol().getBottomRight().getRow()); } }
/** * Sets the header * * @param h the header */ public void setHeader(HeaderFooter h) { header = h; }
/** * Sets the footer * * @param f the footer */ public void setFooter(HeaderFooter f) { footer = f; }
/** * Adds cells to the specified sheet which test the various border * styles * * @param s */ private void writeBordersSheet(WritableSheet s) { s.getSettings().setProtected(true); s.setColumnView(1, 15); s.setColumnView(2, 15); s.setColumnView(4, 15); WritableCellFormat thickLeft = new WritableCellFormat(); thickLeft.setBorder(Border.LEFT, BorderLineStyle.THICK); Label lr = new Label(1, 0, "Thick left", thickLeft); s.addCell(lr); WritableCellFormat dashedRight = new WritableCellFormat(); dashedRight.setBorder(Border.RIGHT, BorderLineStyle.DASHED); lr = new Label(2, 0, "Dashed right", dashedRight); s.addCell(lr); WritableCellFormat doubleTop = new WritableCellFormat(); doubleTop.setBorder(Border.TOP, BorderLineStyle.DOUBLE); lr = new Label(1, 2, "Double top", doubleTop); s.addCell(lr); WritableCellFormat hairBottom = new WritableCellFormat(); hairBottom.setBorder(Border.BOTTOM, BorderLineStyle.HAIR); lr = new Label(2, 2, "Hair bottom", hairBottom); s.addCell(lr); WritableCellFormat allThin = new WritableCellFormat(); allThin.setBorder(Border.ALL, BorderLineStyle.THIN); lr = new Label(4, 2, "All thin", allThin); s.addCell(lr); WritableCellFormat twoBorders = new WritableCellFormat(); twoBorders.setBorder(Border.TOP, BorderLineStyle.THICK); twoBorders.setBorder(Border.LEFT, BorderLineStyle.THICK); lr = new Label(6, 2, "Two borders", twoBorders); s.addCell(lr); // Create a cell in the middle of nowhere (out of the grow region) lr = new Label(20, 20, "Dislocated cell - after a page break"); s.addCell(lr); // Set the orientation and the margins s.getSettings().setPaperSize(PaperSize.A3); s.getSettings().setOrientation(PageOrientation.LANDSCAPE); s.getSettings().setPageOrder(PageOrder.DOWN_THEN_RIGHT); s.getSettings().setHeaderMargin(2); s.getSettings().setFooterMargin(2); s.getSettings().setTopMargin(3); s.getSettings().setBottomMargin(3); // Add a header and footera HeaderFooter header = new HeaderFooter(); header.getCentre().append("Page Header"); s.getSettings().setHeader(header); HeaderFooter footer = new HeaderFooter(); footer.getRight().append("page "); footer.getRight().appendPageNumber(); s.getSettings().setFooter(footer); // Add a page break and insert a couple of rows s.addRowPageBreak(18); s.insertRow(17); s.insertRow(17); s.removeRow(17); // Add a page break off the screen s.addRowPageBreak(30); // Add a hidden column lr = new Label(10, 1, "Hidden column"); s.addCell(lr); lr = new Label(3, 8, "Hidden row"); s.addCell(lr); s.setRowView(8, true); WritableCellFormat allThickRed = new WritableCellFormat(); allThickRed.setBorder(Border.ALL, BorderLineStyle.THICK, Colour.RED); lr = new Label(1, 5, "All thick red", allThickRed); s.addCell(lr); WritableCellFormat topBottomBlue = new WritableCellFormat(); topBottomBlue.setBorder(Border.TOP, BorderLineStyle.THIN, Colour.BLUE); topBottomBlue.setBorder(Border.BOTTOM, BorderLineStyle.THIN, Colour.BLUE); lr = new Label(4, 5, "Top and bottom blue", topBottomBlue); s.addCell(lr); }