Skip to content

Commit

Permalink
Enhanced print out options of the excel emitter (#1656) (#1657)
Browse files Browse the repository at this point in the history
* Enhanced print out options of the excel emitter (#1656)
  • Loading branch information
speckyspooky committed Apr 29, 2024
1 parent 0790fe6 commit 76ba948
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Introduction to use the specialist user properties of the PdfEmitter.

## Reason
The PdfEmitter provides a set of specialist user properties to optimize the excel output according of the reporting based requirements.
The PdfEmitter provides a set of specialist user properties to optimize the pdf output according of the reporting based requirements.

Each of the user properties starts with the master prefix "PdfEmitter".

Expand Down Expand Up @@ -42,7 +42,7 @@ The following list get an overview of all supported user properties, the content
Content define the pdf conformance of the created pdf document, e.g. PDF.A1A
Location report
Data type string
Values conformance values: PDF.Standard, PDF.X1A2001, PDF.X32002, PDF.A1A, PDF.A1B
Values PDF.Standard, PDF.X1A2001, PDF.X32002, PDF.A1A, PDF.A1B
Default PDF.Standard
Reference see PdfEmitter.IccColorType, PdfEmitter.IccProfileFile, PdfEmitter.PDFA.AddDocumentTitle, PdfEmitter.PDFA.FallbackFont

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,30 @@ public abstract class ExcelEmitter implements IContentEmitter {
/** property: ExcelEmitter.ForceRecalculation */
public static final String FORCE_RECALCULATION = "ExcelEmitter.ForceRecalculation";

/** property: ExcelEmitter.PrintGridlines */
public static final String PRINTGRIDLINES_PROP = "ExcelEmitter.PrintGridlines";

/** property: ExcelEmitter.PrintRowColHeadings */
public static final String PRINTROWCOLHEADINGS_PROP = "ExcelEmitter.PrintRowColHeadings";

/** property: ExcelEmitter.PrintFitToPage */
public static final String PRINTFITTOPAGE_PROP = "ExcelEmitter.PrintFitToPage";

/** property: ExcelEmitter.DisplaySheetZoom */
public static final String DISPLAY_SHEET_ZOOM = "ExcelEmitter.DisplaySheetZoom";

/** property: minimum zoom value of excel sheet */
public static final short poiExcelDisplaySheetZoomScaleMin = 10;

/** property: maximum zoom value of excel sheet */
public static final short poiExcelDisplaySheetZoomScaleMax = 400;

/** property: minimum scale of the excel print out */
public static final short poiExcelPrintScaleMin = 10;

/** property: maximum scale of the excel print out */
public static final short poiExcelPrintScaleMax = 400;

/**
* Logger.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The following list get an overview of all supported user properties, the content
false, disabled debug log
Default false


**ExcelEmitter.RemoveBlankRows**

Content handling of blank rows
Expand Down Expand Up @@ -96,7 +97,7 @@ The following list get an overview of all supported user properties, the content
Content define the number format of a numeric value for excel
Location text-element of cell
Data type string
Values custom format which should be used to display the value on excel, e.g. "#,#00.00"
Values custom format which should be used to display the value on excel, e.g. "#,#00.00"
the format use the form of the excel-defined forms (language version: en)
Default empty (null)

Expand All @@ -123,7 +124,7 @@ The following list get an overview of all supported user properties, the content
Location report, table
Data type boolean
Values true, a summary row is inserted below the detailed data being summarized and a new outline level is established on that row
false, a summary row is inserted above the detailed data being summarized and a new outline levelis established on that row.
false, a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.
Default false

**ExcelEmitter.FreezePanes**
Expand Down Expand Up @@ -263,3 +264,38 @@ The following list get an overview of all supported user properties, the content
Values true, activate the recalculation option
false, no recalculation
Default false

**ExcelEmitter.PrintGridlines**

Content activate the print out of the grind lines
Location page, table, list
Data type boolean
Values true, activate grid line print out
false, without grid line print out
Default false

**ExcelEmitter.PrintRowColHeadings**

Content activate the print out of the row and column heading labels
Location page, table, list
Data type boolean
Values true, activate print out of the row and column heading labels
false, without print out of the row and column heading labels
Default false

**ExcelEmitter.PrintFitToPage**

Content the page will be fit to center of the print out
Location page, table, list
Data type boolean
Values true, fit the page to center
false, no fitting of the page
Default false

**ExcelEmitter.DisplaySheetZoom**

Content define the used scaling for the sheet zoom
Location page, table, list
Data type number, integer
Values the zoom value must be -1 (= off) or between 10 and 400
Default -1
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* Copyright (c) 2011, 2012, 2013 James Talbut.
* jim-emitters@spudsoft.co.uk
*
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* James Talbut - Initial implementation.
************************************************************************************/
Expand Down Expand Up @@ -130,6 +130,22 @@ public void endList(HandlerState state, IListContent list) throws BirtException
if (!EmitterServices.booleanOption(state.getRenderOptions(), list, ExcelEmitter.DISPLAYZEROS_PROP, true)) {
state.currentSheet.setDisplayZeros(false);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), list, ExcelEmitter.PRINTGRIDLINES_PROP, false)) {
state.currentSheet.setPrintGridlines(true);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), list, ExcelEmitter.PRINTROWCOLHEADINGS_PROP,
false)) {
state.currentSheet.setPrintRowAndColumnHeadings(true);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), list, ExcelEmitter.PRINTFITTOPAGE_PROP, false)) {
state.currentSheet.setFitToPage(true);
}
int displayZoom = EmitterServices.integerOption(state.getRenderOptions(), list,
ExcelEmitter.DISPLAY_SHEET_ZOOM, -1);
if ((displayZoom >= ExcelEmitter.poiExcelDisplaySheetZoomScaleMin)
&& (displayZoom <= ExcelEmitter.poiExcelDisplaySheetZoomScaleMax)) {
state.currentSheet.setZoom(displayZoom);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void endTable(HandlerState state, ITableContent table) throws BirtExcepti
if (calcWidth > 1.0) {
state.currentSheet.autoSizeColumn(col, true);
calcWidth = state.currentSheet.getColumnWidth(col) * 1.15; // offset to handle width differences of apache poi
int maxColumnWidth = 255 * 256; // The maximum column width for an individual cell is 255
int maxColumnWidth = 255 * 256; // The maximum column width for an individual cell is 255
// characters
if (calcWidth > maxColumnWidth) {
calcWidth = maxColumnWidth;
Expand Down Expand Up @@ -202,6 +202,24 @@ public void endTable(HandlerState state, ITableContent table) throws BirtExcepti
if (!EmitterServices.booleanOption(state.getRenderOptions(), table, ExcelEmitter.DISPLAYZEROS_PROP, true)) {
state.currentSheet.setDisplayZeros(false);
}
if (!EmitterServices.booleanOption(state.getRenderOptions(), table, ExcelEmitter.DISPLAYROWCOLHEADINGS_PROP,
true)) {
state.currentSheet.setDisplayRowColHeadings(false);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), table, ExcelEmitter.PRINTGRIDLINES_PROP, false)) {
state.currentSheet.setPrintGridlines(true);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), table, ExcelEmitter.PRINTROWCOLHEADINGS_PROP, false)) {
state.currentSheet.setPrintRowAndColumnHeadings(true);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), table, ExcelEmitter.PRINTFITTOPAGE_PROP, false)) {
state.currentSheet.setFitToPage(true);
}
int displayZoom = EmitterServices.integerOption(state.getRenderOptions(), table,
ExcelEmitter.DISPLAY_SHEET_ZOOM, -1);
if ((displayZoom >= ExcelEmitter.poiExcelDisplaySheetZoomScaleMin) && (displayZoom <= ExcelEmitter.poiExcelDisplaySheetZoomScaleMax)) {
state.currentSheet.setZoom(displayZoom);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@
*/
public class PageHandler extends AbstractHandler {

private final static short poiExcelPrintScaleMin = 10;
private final static short poiExcelPrintScaleMax = 400;

/**
* Constructor
*
Expand Down Expand Up @@ -176,6 +173,22 @@ public void startPage(HandlerState state, IPageContent page) throws BirtExceptio
if (!EmitterServices.booleanOption(state.getRenderOptions(), page, ExcelEmitter.DISPLAYZEROS_PROP, true)) {
state.currentSheet.setDisplayZeros(false);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), page, ExcelEmitter.PRINTGRIDLINES_PROP, false)) {
state.currentSheet.setPrintGridlines(true);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), page, ExcelEmitter.PRINTROWCOLHEADINGS_PROP,
false)) {
state.currentSheet.setPrintRowAndColumnHeadings(true);
}
if (EmitterServices.booleanOption(state.getRenderOptions(), page, ExcelEmitter.PRINTFITTOPAGE_PROP, false)) {
state.currentSheet.setFitToPage(true);
}
int displayZoom = EmitterServices.integerOption(state.getRenderOptions(), page,
ExcelEmitter.DISPLAY_SHEET_ZOOM, -1);
if ((displayZoom >= ExcelEmitter.poiExcelDisplaySheetZoomScaleMin)
&& (displayZoom <= ExcelEmitter.poiExcelDisplaySheetZoomScaleMax)) {
state.currentSheet.setZoom(displayZoom);
}
int pagesHigh = EmitterServices.integerOption(state.getRenderOptions(), page, ExcelEmitter.PRINT_PAGES_HIGH,
-1);
if ((pagesHigh > 0) && (pagesHigh < Short.MAX_VALUE)) {
Expand All @@ -189,7 +202,7 @@ public void startPage(HandlerState state, IPageContent page) throws BirtExceptio
state.currentSheet.setAutobreaks(true);
}
int printScale = EmitterServices.integerOption(state.getRenderOptions(), page, ExcelEmitter.PRINT_SCALE, -1);
if ((printScale >= poiExcelPrintScaleMin) && (printScale <= poiExcelPrintScaleMax)) {
if ((printScale >= ExcelEmitter.poiExcelPrintScaleMin) && (printScale <= ExcelEmitter.poiExcelPrintScaleMax)) {
state.currentSheet.getPrintSetup().setScale((short) printScale);
}

Expand Down

0 comments on commit 76ba948

Please sign in to comment.