* @param worksheet The worksheet to apply the settings to
* @param uiWorksheet The settings to set
*/
protected void applyWorksheetSettings(WritableSheet worksheet, UIWorksheet uiWorksheet)
{
SheetSettings settings = worksheet.getSettings();
if (uiWorksheet.getAutomaticFormulaCalculation() != null)
{
settings.setAutomaticFormulaCalculation(uiWorksheet.getAutomaticFormulaCalculation());
}
if (uiWorksheet.getBottomMargin() != null)
{
settings.setBottomMargin(uiWorksheet.getBottomMargin());
}
if (uiWorksheet.getCopies() != null)
{
settings.setCopies(uiWorksheet.getCopies());
}
if (uiWorksheet.getDefaultColumnWidth() != null)
{
settings.setDefaultColumnWidth(uiWorksheet.getDefaultColumnWidth());
}
if (uiWorksheet.getDefaultRowHeight() != null)
{
settings.setDefaultRowHeight(uiWorksheet.getDefaultRowHeight());
}
if (uiWorksheet.getDisplayZeroValues() != null)
{
settings.setDisplayZeroValues(uiWorksheet.getDisplayZeroValues());
}
if (uiWorksheet.getFitHeight() != null)
{
settings.setFitHeight(uiWorksheet.getFitHeight());
}
if (uiWorksheet.getFitToPages() != null)
{
settings.setFitToPages(uiWorksheet.getFitToPages());
}
if (uiWorksheet.getFitWidth() != null)
{
settings.setFitWidth(uiWorksheet.getFitWidth());
}
if (uiWorksheet.getFooterMargin() != null)
{
settings.setFooterMargin(uiWorksheet.getFooterMargin());
}
if (uiWorksheet.getHeaderMargin() != null)
{
settings.setHeaderMargin(uiWorksheet.getHeaderMargin());
}
if (uiWorksheet.getHidden() != null)
{
settings.setHidden(uiWorksheet.getHidden());
}
if (uiWorksheet.getHorizontalCentre() != null)
{
settings.setHorizontalCentre(uiWorksheet.getHorizontalCentre());
}
if (uiWorksheet.getHorizontalFreeze() != null)
{
settings.setHorizontalFreeze(uiWorksheet.getHorizontalFreeze());
}
if (uiWorksheet.getHorizontalPrintResolution() != null)
{
settings.setHorizontalPrintResolution(uiWorksheet.getHorizontalPrintResolution());
}
if (uiWorksheet.getLeftMargin() != null)
{
settings.setLeftMargin(uiWorksheet.getLeftMargin());
}
if (uiWorksheet.getNormalMagnification() != null)
{
settings.setNormalMagnification(uiWorksheet.getNormalMagnification());
}
if (uiWorksheet.getOrientation() != null)
{
settings.setOrientation(JXLFactory.createPageOrientation(uiWorksheet.getOrientation()));
}
if (uiWorksheet.getPageBreakPreviewMagnification() != null)
{
settings.setPageBreakPreviewMagnification(uiWorksheet.getPageBreakPreviewMagnification());
}
if (uiWorksheet.getPageBreakPreviewMode() != null)
{
settings.setPageBreakPreviewMode(uiWorksheet.getPageBreakPreviewMode());
}
if (uiWorksheet.getPageStart() != null)
{
settings.setPageStart(uiWorksheet.getPageStart());
}
if (uiWorksheet.getPaperSize() != null)
{
settings.setPaperSize(JXLFactory.createPaperSize(uiWorksheet.getPaperSize()));
}
if (uiWorksheet.getPassword() != null)
{
settings.setPassword(uiWorksheet.getPassword());
}
if (uiWorksheet.getPasswordHash() != null)
{
settings.setPasswordHash(uiWorksheet.getPasswordHash());
}
if (uiWorksheet.getPrintGridLines() != null)
{
settings.setPrintGridLines(uiWorksheet.getPrintGridLines());
}
if (uiWorksheet.getPrintHeaders() != null)
{
settings.setPrintHeaders(uiWorksheet.getPrintHeaders());
}
if (uiWorksheet.getSheetProtected() != null)
{
settings.setProtected(uiWorksheet.getSheetProtected());
}
if (uiWorksheet.getRecalculateFormulasBeforeSave() != null)
{
settings.setRecalculateFormulasBeforeSave(uiWorksheet.getRecalculateFormulasBeforeSave());
}
if (uiWorksheet.getRightMargin() != null)
{
settings.setRightMargin(uiWorksheet.getRightMargin());
}
if (uiWorksheet.getScaleFactor() != null)
{
settings.setScaleFactor(uiWorksheet.getScaleFactor());
}
if (uiWorksheet.getSelected() != null)
{
settings.setSelected(uiWorksheet.getSelected());
}
if (uiWorksheet.getShowGridLines() != null)
{
settings.setShowGridLines(uiWorksheet.getShowGridLines());
}
if (uiWorksheet.getTopMargin() != null)
{
settings.setTopMargin(uiWorksheet.getTopMargin());
}
if (uiWorksheet.getVerticalCentre() != null)
{
settings.setVerticalCentre(uiWorksheet.getVerticalCentre());
}
if (uiWorksheet.getVerticalFreeze() != null)
{
settings.setVerticalFreeze(uiWorksheet.getVerticalFreeze());
}
if (uiWorksheet.getVerticalPrintResolution() != null)
{
settings.setVerticalPrintResolution(uiWorksheet.getVerticalPrintResolution());
}
if (uiWorksheet.getZoomFactor() != null)
{
settings.setZoomFactor(uiWorksheet.getZoomFactor());
}
// Iterates through the worksheet uiWorksheet child elements (print areas,
// print titles and headers/footers)
for (UIComponent child : uiWorksheet.getChildren())
{
if (child.getClass() == UIPrintArea.class)
{
UIPrintArea printArea = (UIPrintArea) child;
settings.setPrintArea(printArea.getFirstColumn(), printArea.getFirstRow(), printArea.getLastColumn(), printArea.getLastRow());
}
else if (child.getClass() == UIPrintTitles.class)
{
UIPrintTitles printTitles = (UIPrintTitles) child;
settings.setPrintTitles(printTitles.getFirstCol(), printTitles.getFirstRow(), printTitles.getLastCol(), printTitles.getLastRow());
}
else if (child.getClass() == UIHeader.class)
{
UIHeader uiHeader = (UIHeader) child;
settings.setHeader(JXLFactory.createHeaderFooter(uiHeader, settings.getHeader()));
}
else if (child.getClass() == UIFooter.class)
{
UIFooter uiFooter = (UIFooter) child;
settings.setFooter(JXLFactory.createHeaderFooter(uiFooter, settings.getFooter()));
}
}
}