Package jxl

Examples of jxl.SheetSettings


    }
    else
    {
      sheet.setPageSetup(po);
    }
    SheetSettings sheets = sheet.getSettings();
   
    if (jasperPrint.getTopMargin() != null)
    {
      sheets.setTopMargin(LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getTopMargin()));
    }

    if (jasperPrint.getLeftMargin() != null)
    {
      sheets.setLeftMargin(LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getLeftMargin()));
    }
   
    if (jasperPrint.getRightMargin() != null)
    {
      sheets.setRightMargin(LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getRightMargin()));
    }

    if (jasperPrint.getBottomMargin() != null)
    {
      sheets.setBottomMargin(LengthUtil.inchNoRound(isIgnorePageMargins ? 0 : jasperPrint.getBottomMargin()));
    }

    sheets.setHeaderMargin(0.0);
    sheets.setFooterMargin(0.0);

    String fitWidth = JRProperties.getProperty(jasperPrint, PROPERTY_FIT_WIDTH);
    if(fitWidth != null && fitWidth.length() > 0)
    {
      sheets.setFitWidth(Integer.valueOf(fitWidth));
      sheets.setFitToPages(true);
    }
   
    String fitHeight = JRProperties.getProperty(jasperPrint, PROPERTY_FIT_HEIGHT);
    if(fitHeight != null && fitHeight.length() > 0)
    {
      sheets.setFitHeight(Integer.valueOf(fitHeight));
      sheets.setFitToPages(true);
    }

    if(password != null)
    {
      sheets.setPassword(password);
      sheets.setProtected(true);
    }
   
    if(sheetHeaderLeft != null)
    {
      sheets.getHeader().getLeft().append(sheetHeaderLeft);
    }
   
    if(sheetHeaderCenter != null)
    {
      sheets.getHeader().getCentre().append(sheetHeaderCenter);
    }
   
    if(sheetHeaderRight != null)
    {
      sheets.getHeader().getRight().append(sheetHeaderRight);
    }
   
    if(sheetFooterLeft != null)
    {
      sheets.getFooter().getLeft().append(sheetFooterLeft);
    }
   
    if(sheetFooterCenter != null)
    {
      sheets.getFooter().getCentre().append(sheetFooterCenter);
    }
   
    if(sheetFooterRight != null)
    {
      sheets.getFooter().getRight().append(sheetFooterRight);
    }
   
  }
View Full Code Here


 
  /* import sheet format */
  private void importSheetFormat(SheetImpl zkSheet, jxl.Sheet sheet){
    final jxl.read.biff.SheetImpl jsheet = (jxl.read.biff.SheetImpl) sheet;
    /* Default row height and column width */
    SheetSettings  settings = sheet.getSettings();
    /*
     * the default column width, in characters
     * Excel 8.43, JExcelApi int value 8
     */
    final int colWidthInChar = settings.getDefaultColumnWidth();
    // the default row height, in 1/20ths of a point
    final int rowHeightInPt = settings.getDefaultRowHeight()/20;
    zkSheet.setDefaultColumnWidth(ExcelFormatHelper.charToPx(colWidthInChar));
    zkSheet.setDefaultRowHeight(ExcelFormatHelper.ptToPx(rowHeightInPt));
   
    /*
     * cv.getSize() Gets the width of the column in characters multiplied by 256,
     * or the height of the row in 1/20ths of a point
     */
    /* row height */
    final RowRecord[] rinfos = jsheet.getRowProperties();
    final int rowsz = rinfos.length;
    for(int j =0; j < rowsz; j++){
      final RowRecord rinfo = rinfos[j];
      if (!ZssWorkbookParser.isDefaultHeight(rinfo)) {
        final int rowHeight = rinfo.getRowHeight()/20;
        final int ri = rinfo.getRowNumber();
        zkSheet.setRowHeight(ri, ExcelFormatHelper.ptToPx(rowHeight));
      }
    }
    /* column width */
    final ColumnInfoRecord[] cinfos = jsheet.getColumnInfos();
    final int colsz = cinfos.length;
    for(int j=0; j < colsz; j++){
      final ColumnInfoRecord cinfo = cinfos[j];
      final int sci = cinfo.getStartColumn();
      final int eci = cinfo.getEndColumn();
      final int colWidth = cinfo.getWidth()/256;
      if(colWidth != colWidthInChar) {
        for (int k = sci; k <= eci; ++k) {
          zkSheet.setColumnWidth(k, ExcelFormatHelper.charToPx(colWidth));
        }
      }
    }
    /* Freeze panes */
    int hFreeze = settings.getHorizontalFreeze();
    int vFreeze = settings.getVerticalFreeze();
    //in jxl, 0 means no freeze, but in zkSheet, -1 means no freeze
    zkSheet.setRowFreeze(vFreeze-1);
    zkSheet.setColumnFreeze(hFreeze-1);

  }
View Full Code Here

  }
 
  /* export sheet format */
  private void exportSheetFormat(WritableSheet workSheet, Sheet zkSheet) throws RowsExceededException{
   
    SheetSettings setting = workSheet.getSettings();
    /* Freeze panes*/
    int vFreeze = zkSheet.getRowFreeze();
    int hFreeze = zkSheet.getColumnFreeze();
    //in jxl, 0 means no freeze, but in zkSheet, -1 means no freeze
    setting.setVerticalFreeze(vFreeze+1);
    setting.setHorizontalFreeze(hFreeze+1);
   
    //the default column width, in characters
    // the default row height, in 1/20ths of a point
    int defaultColWidthPx = zkSheet.getDefaultColumnWidth();
    setting.setDefaultColumnWidth(ExcelFormatHelper.pxToChar(defaultColWidthPx));
    int defaultRowHeightPx = zkSheet.getDefaultRowHeight();
    setting.setDefaultRowHeight(ExcelFormatHelper.pxToPt(defaultRowHeightPx)*20);
   
    for(int i =0, l =zkSheet.getRowSize(); i<l; i++){
      int height = zkSheet.getRowHeight(i);
      if(defaultRowHeightPx != height)
        workSheet.setRowView(i, ExcelFormatHelper.pxToPt(height)*20 );
View Full Code Here

    * @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()));
         }
      }
   }
View Full Code Here

    * @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()));
         }
      }
   }
View Full Code Here

TOP

Related Classes of jxl.SheetSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.