Package org.jboss.seam.excel.css

Examples of org.jboss.seam.excel.css.CSSParser


   @SuppressWarnings("unchecked")
   public void export(String dataTableId, String type)
   {
      excelWorkbook = ExcelFactory.instance().getExcelWorkbook(type);

      CSSParser parser = new CSSParser();

      // Gets the datatable
      UIData dataTable = (UIData) FacesContext.getCurrentInstance().getViewRoot().findComponent(dataTableId);
      if (dataTable == null)
      {
         throw new ExcelWorkbookException(Interpolator.instance().interpolate("Could not find data table with id #0", dataTableId));
      }

      // Inits the workbook and worksheet
      UIWorkbook uiWorkbook = new UIWorkbook();
      excelWorkbook.createWorkbook(uiWorkbook);
      UIWorksheet uiWorksheet = new UIWorksheet();
      uiWorkbook.getChildren().add(uiWorksheet);
      uiWorksheet.setStyle(CSSParser.getStyle(dataTable));
      uiWorksheet.setStyleClass(CSSParser.getStyleClass(dataTable));
      excelWorkbook.createOrSelectWorksheet(uiWorksheet);

      // Saves the datatable var
      String dataTableVar = dataTable.getVar();
      Object oldValue = FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(dataTableVar);

      // Processes the columns
      List<javax.faces.component.UIColumn> columns = ExcelComponent.getChildrenOfType(dataTable.getChildren(), javax.faces.component.UIColumn.class);
      columnWidths = parseColumnWidths(uiWorksheet);
      int col = 0;
      for (javax.faces.component.UIColumn column : columns)
      {
         ColumnStyle columnStyle = new ColumnStyle(parser.getCascadedStyleMap(column));
         boolean cssExport = columnStyle.export == null || columnStyle.export;
         if (column.isRendered() && cssExport)
         {
            uiWorksheet.getChildren().add(column);
            Iterator iterator = UIWorksheet.unwrapIterator(dataTable.getValue());
View Full Code Here


    * @return The map of column number -> column width
    */
   private Map<Integer, Integer> parseColumnWidths(UIWorksheet worksheet)
   {
      Map<Integer, Integer> columnWidths = new HashMap<Integer, Integer>();
      CSSParser parser = new CSSParser();

      StyleMap styleMap = parser.getCascadedStyleMap(worksheet);
      for (Map.Entry<String, Object> entry : styleMap.entrySet())
      {
         String key = entry.getKey();
         if (key.startsWith(CSSNames.COLUMN_WIDTHS))
         {
View Full Code Here

TOP

Related Classes of org.jboss.seam.excel.css.CSSParser

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.