Package org.jboss.seam.excel

Examples of org.jboss.seam.excel.ExcelWorkbook


   @Override
   public void encodeBegin(javax.faces.context.FacesContext facesContext) throws java.io.IOException
   {
      // Get workbook
      ExcelWorkbook excelWorkbook = getWorkbook(getParent());

      if (excelWorkbook == null)
      {
         throw new ExcelWorkbookException("Could not find excel workbook");
      }

      // Create new worksheet (or select an existing one) and apply settings (if
      // any)
      excelWorkbook.createOrSelectWorksheet(this);

      WorksheetItem headerItem = (WorksheetItem) getFacet(HEADER_FACET_NAME);
      if (headerItem != null)
      {
         int colspan = getChildrenOfType(getChildren(), UIColumn.class).size();
         excelWorkbook.addWorksheetHeader(headerItem, colspan);
      }

      // Add worksheet level items
      List<WorksheetItem> items = getItems(getChildren());
      for (WorksheetItem item : items)
      {
         excelWorkbook.addItem(item);
      }

      // Execute worksheet level commands
      List<Command> commands = getCommands(getChildren());
      for (Command command : commands)
      {
         excelWorkbook.executeCommand(command);
      }
   }
View Full Code Here


   }

   @Override
   public void encodeEnd(javax.faces.context.FacesContext facesContext) throws java.io.IOException
   {
      ExcelWorkbook excelWorkbook = getWorkbook(getParent());
      if (excelWorkbook == null)
      {
         throw new ExcelWorkbookException("Could not find excel workbook");
      }

      WorksheetItem footerItem = (WorksheetItem) getFacet(FOOTER_FACET_NAME);
      if (footerItem != null)
      {
         int colspan = getChildrenOfType(getChildren(), UIColumn.class).size();
         excelWorkbook.addWorksheetFooter(footerItem, colspan);
      }
   }
View Full Code Here

   @SuppressWarnings("unchecked")
   @Override
   public void encodeBegin(FacesContext facesContext) throws IOException
   {
      // Get workbook and worksheet
      ExcelWorkbook excelWorkbook = getWorkbook(getParent());

      if (excelWorkbook == null)
      {
         throw new ExcelWorkbookException("Could not find excel workbook");
      }

      // Column width etc.
      excelWorkbook.applyColumnSettings(this);

      UIWorksheet sheet = (UIWorksheet) getParentByClass(getParent(), UIWorksheet.class);
      if (sheet == null)
      {
         throw new ExcelWorkbookException("Could not find worksheet");
      }

      // Add header items (if any)
      WorksheetItem headerItem = (WorksheetItem) getFacet(HEADER_FACET_NAME);
      if (headerItem != null)
      {
         excelWorkbook.addItem(headerItem);
      }

      // Execute commands (if any)
      List<Command> commands = getCommands(getChildren());
      for (Command command : commands)
      {
         excelWorkbook.executeCommand(command);
      }

       // Get UiCell template this column's data cells and iterate over sheet data
      for (WorksheetItem item : getItems(getChildren()))
      {
         Object oldValue = null;
         Iterator iterator = null;
         // Store away the old value for the sheet binding var (if there is one)
         if (sheet.getVar() != null) {
            oldValue = FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(sheet.getVar());
            iterator = sheet.getDataIterator();
         } else {
            // No var, no iteration...
            iterator = new ArrayList().iterator();
         }
         while (iterator.hasNext())
         {
            // Store the bound data in the request map and add the cell
            FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(sheet.getVar(), iterator.next());
            excelWorkbook.addItem(item);
         }

         //  No iteration, nothing to restore
         if (sheet.getVar() == null) {
            continue;
         }
         // Restore the previously modified request map (if there was a var)
         if (oldValue == null)
         {
            FacesContext.getCurrentInstance().getExternalContext().getRequestMap().remove(sheet.getVar());
         }
         else
         {
            FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(sheet.getVar(), oldValue);
         }
      }

      // Add footer items (if any)
      WorksheetItem footerItem = (WorksheetItem) getFacet(FOOTER_FACET_NAME);
      if (footerItem != null)
      {
         excelWorkbook.addItem(footerItem);
      }
     
     
      // Move column pointer to next column
      excelWorkbook.nextColumn();

   }
View Full Code Here

TOP

Related Classes of org.jboss.seam.excel.ExcelWorkbook

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.