Examples of CellStyle


Examples of org.apache.poi.ss.usermodel.CellStyle

    @Test
    public void bug51037() throws Exception {
       XSSFWorkbook wb = new XSSFWorkbook();
       XSSFSheet s = wb.createSheet();
      
       CellStyle defaultStyle = wb.getCellStyleAt((short)0);
       assertEquals(0, defaultStyle.getIndex());
      
       CellStyle blueStyle = wb.createCellStyle();
       blueStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
       blueStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(1, blueStyle.getIndex());

       CellStyle pinkStyle = wb.createCellStyle();
       pinkStyle.setFillForegroundColor(IndexedColors.PINK.getIndex());
       pinkStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(2, pinkStyle.getIndex());

       // Starts empty
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       CTCols cols = s.getCTWorksheet().getColsArray(0);
       assertEquals(0, cols.sizeOfColArray());
      
       // Add some rows and columns
       XSSFRow r1 = s.createRow(0);
       XSSFRow r2 = s.createRow(1);
       r1.createCell(0);
       r1.createCell(2);
       r2.createCell(0);
       r2.createCell(3);
      
       // Check no style is there
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(0, cols.sizeOfColArray());
      
       assertEquals(defaultStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(defaultStyle, s.getColumnStyle(3));
      
      
       // Apply the styles
       s.setDefaultColumnStyle(0, pinkStyle);
       s.setDefaultColumnStyle(3, blueStyle);
      
       // Check
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
      
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(2, cols.sizeOfColArray());
      
       assertEquals(1, cols.getColArray(0).getMin());
       assertEquals(1, cols.getColArray(0).getMax());
       assertEquals(pinkStyle.getIndex(), cols.getColArray(0).getStyle());
      
       assertEquals(4, cols.getColArray(1).getMin());
       assertEquals(4, cols.getColArray(1).getMax());
       assertEquals(blueStyle.getIndex(), cols.getColArray(1).getStyle());
      
      
       // Save, re-load and re-check
       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
       s = wb.getSheetAt(0);
       defaultStyle = wb.getCellStyleAt(defaultStyle.getIndex());
       blueStyle = wb.getCellStyleAt(blueStyle.getIndex());
       pinkStyle = wb.getCellStyleAt(pinkStyle.getIndex());
      
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
       wb.close();
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

       // Check all the colours
       for(int sn=0; sn<wb.getNumberOfSheets(); sn++) {
          Sheet s = wb.getSheetAt(sn);
          for(Row r : s) {
             for(Cell c : r) {
                CellStyle cs = c.getCellStyle();
                if(cs != null) {
                   cs.getFillForegroundColor();
                }
             }
          }
       }
      
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

       richTextString.applyFont(font3);
       richTextString.applyFont(0, 3, font1);
       cell.setCellValue(richTextString);

       // To enable newlines you need set a cell styles with wrap=true
       CellStyle cs = wb.createCellStyle();
       cs.setWrapText(true);
       cell.setCellStyle(cs);

       // Check the text has the
       assertEquals(text, cell.getStringCellValue());
      
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

     */
    public void test51037() throws Exception {
       XSSFWorkbook wb = new XSSFWorkbook();
       XSSFSheet s = wb.createSheet();
      
       CellStyle defaultStyle = wb.getCellStyleAt((short)0);
       assertEquals(0, defaultStyle.getIndex());
      
       CellStyle blueStyle = wb.createCellStyle();
       blueStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
       blueStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(1, blueStyle.getIndex());

       CellStyle pinkStyle = wb.createCellStyle();
       pinkStyle.setFillForegroundColor(IndexedColors.PINK.getIndex());
       pinkStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(2, pinkStyle.getIndex());

       // Starts empty
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       CTCols cols = s.getCTWorksheet().getColsArray(0);
       assertEquals(0, cols.sizeOfColArray());
      
       // Add some rows and columns
       XSSFRow r1 = s.createRow(0);
       XSSFRow r2 = s.createRow(1);
       r1.createCell(0);
       r1.createCell(2);
       r2.createCell(0);
       r2.createCell(3);
      
       // Check no style is there
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(0, cols.sizeOfColArray());
      
       assertEquals(defaultStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(defaultStyle, s.getColumnStyle(3));
      
      
       // Apply the styles
       s.setDefaultColumnStyle(0, pinkStyle);
       s.setDefaultColumnStyle(3, blueStyle);
      
       // Check
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
      
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(2, cols.sizeOfColArray());
      
       assertEquals(1, cols.getColArray(0).getMin());
       assertEquals(1, cols.getColArray(0).getMax());
       assertEquals(pinkStyle.getIndex(), cols.getColArray(0).getStyle());
      
       assertEquals(4, cols.getColArray(1).getMin());
       assertEquals(4, cols.getColArray(1).getMax());
       assertEquals(blueStyle.getIndex(), cols.getColArray(1).getStyle());
      
      
       // Save, re-load and re-check
       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
       s = wb.getSheetAt(0);
       defaultStyle = wb.getCellStyleAt(defaultStyle.getIndex());
       blueStyle = wb.getCellStyleAt(blueStyle.getIndex());
       pinkStyle = wb.getCellStyleAt(pinkStyle.getIndex());
      
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
    }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

       // Check all the colours
       for(int sn=0; sn<wb.getNumberOfSheets(); sn++) {
          Sheet s = wb.getSheetAt(sn);
          for(Row r : s) {
             for(Cell c : r) {
                CellStyle cs = c.getCellStyle();
                if(cs != null) {
                   cs.getFillForegroundColor();
                }
             }
          }
       }
      
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

       richTextString.applyFont(font3);
       richTextString.applyFont(0, 3, font1);
       cell.setCellValue(richTextString);

       // To enable newlines you need set a cell styles with wrap=true
       CellStyle cs = wb.createCellStyle();
       cs.setWrapText(true);
       cell.setCellStyle(cs);

       // Check the text has the
       assertEquals(text, cell.getStringCellValue());
      
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

    @Test
    public void bug51037() throws Exception {
       XSSFWorkbook wb = new XSSFWorkbook();
       XSSFSheet s = wb.createSheet();
      
       CellStyle defaultStyle = wb.getCellStyleAt((short)0);
       assertEquals(0, defaultStyle.getIndex());
      
       CellStyle blueStyle = wb.createCellStyle();
       blueStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
       blueStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(1, blueStyle.getIndex());

       CellStyle pinkStyle = wb.createCellStyle();
       pinkStyle.setFillForegroundColor(IndexedColors.PINK.getIndex());
       pinkStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
       assertEquals(2, pinkStyle.getIndex());

       // Starts empty
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       CTCols cols = s.getCTWorksheet().getColsArray(0);
       assertEquals(0, cols.sizeOfColArray());
      
       // Add some rows and columns
       XSSFRow r1 = s.createRow(0);
       XSSFRow r2 = s.createRow(1);
       r1.createCell(0);
       r1.createCell(2);
       r2.createCell(0);
       r2.createCell(3);
      
       // Check no style is there
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(0, cols.sizeOfColArray());
      
       assertEquals(defaultStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(defaultStyle, s.getColumnStyle(3));
      
      
       // Apply the styles
       s.setDefaultColumnStyle(0, pinkStyle);
       s.setDefaultColumnStyle(3, blueStyle);
      
       // Check
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
      
       assertEquals(1, s.getCTWorksheet().sizeOfColsArray());
       assertEquals(2, cols.sizeOfColArray());
      
       assertEquals(1, cols.getColArray(0).getMin());
       assertEquals(1, cols.getColArray(0).getMax());
       assertEquals(pinkStyle.getIndex(), cols.getColArray(0).getStyle());
      
       assertEquals(4, cols.getColArray(1).getMin());
       assertEquals(4, cols.getColArray(1).getMax());
       assertEquals(blueStyle.getIndex(), cols.getColArray(1).getStyle());
      
      
       // Save, re-load and re-check
       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
       s = wb.getSheetAt(0);
       defaultStyle = wb.getCellStyleAt(defaultStyle.getIndex());
       blueStyle = wb.getCellStyleAt(blueStyle.getIndex());
       pinkStyle = wb.getCellStyleAt(pinkStyle.getIndex());
      
       assertEquals(pinkStyle, s.getColumnStyle(0));
       assertEquals(defaultStyle, s.getColumnStyle(2));
       assertEquals(blueStyle, s.getColumnStyle(3));
    }
View Full Code Here

Examples of org.apache.poi.ss.usermodel.CellStyle

       // Check the current ones
       assertEquals(0, normal.getCellStyle().getRotation());
       assertEquals(0xff, rotated.getCellStyle().getRotation());
      
       // Add a new style, also rotated
       CellStyle cs = wb.createCellStyle();
       cs.setRotation((short)0xff);
       Cell nc = r.createCell(2);
       nc.setCellValue("New Rotated Text");
       nc.setCellStyle(cs);
       assertEquals(0xff, nc.getCellStyle().getRotation());
      
View Full Code Here

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

    * @throws WriteException if the creation failed
    */
   public WritableCellFormat createCellFormat(UICell uiCell) throws WriteException
   {
      WritableCellFormat cellFormat = null;
      CellStyle cellStyle = new CellStyle(parser.getCascadedStyleMap(uiCell));

      CellType cellType = cellStyle.forceType != null ? CellType.valueOf(cellStyle.forceType) : uiCell.getDataType();
      switch (cellType)
      {
      case text:
View Full Code Here

Examples of org.nocrala.tools.texttablefmt.CellStyle

                List<String> fixed_ex = new ZNode(ZNODE_FIXED).getChildren();
                for(String name: fixed_ex) {
                    ZooKeeperInfo.Exchange.Builder builder = ZooKeeperInfo.Exchange.newBuilder();
                    TextFormat.merge(new String(new ZNode(ZNODE_FIXED + "/" + name).getContent()), builder);
                    tab.addCell("{queue,topic}:" + name);
                    tab.addCell("Fixed", new CellStyle(HorizontalAlign.center));
                    tab.addCell(builder.build().getHost());
                }
               
                List<String> drop_ex = new ZNode(ZNODE_DROP).getChildren();
                for(String name : drop_ex) {
                    ZooKeeperInfo.DropConfig.Builder drop_builder = ZooKeeperInfo.DropConfig.newBuilder();
                    TextFormat.merge(new String(new ZNode(ZNODE_DROP + "/" + name).getContent()), drop_builder);
                    tab.addCell(name);
                    tab.addCell("Drop Polocy", new CellStyle(HorizontalAlign.center));
                    tab.addCell(drop_builder.build().getPolicy() == DropConfig.Policy.NEWEST ? "newest": "oldest");
                }
               
                List<String> limit_ex = new ZNode(ZNODE_LIMIT).getChildren();
                for(String name : limit_ex) {
                    ZooKeeperInfo.TotalLimit.Builder limit_builder = ZooKeeperInfo.TotalLimit.newBuilder();
                    TextFormat.merge(new String(new ZNode(ZNODE_LIMIT + "/" + name).getContent()), limit_builder);
                    tab.addCell(name);
                    tab.addCell("Maximum limit", new CellStyle(HorizontalAlign.center));
                    ZooKeeperInfo.TotalLimit limit = limit_builder.build();
                    tab.addCell(String.format("%d bytes / %d messages", limit.getSizeBytes(), limit.getCount()));
                }

                List<String> alert_limit_ex = new ZNode(ZNODE_ALERT_LIMIT).getChildren();
                for(String name : alert_limit_ex) {
                    ZooKeeperInfo.AlertConfig.Builder alert_limit_builder = ZooKeeperInfo.AlertConfig.newBuilder();
                    TextFormat.merge(new ZNode(ZNODE_ALERT_LIMIT + "/" + name).getContentString(), alert_limit_builder);
                    ZooKeeperInfo.AlertConfig alertConfig = alert_limit_builder.build();
                    tab.addCell(name);
                    tab.addCell("Alert limit", new CellStyle(HorizontalAlign.center));
                    tab.addCell(String.format("%d messages to %s", alertConfig.getCount(), alertConfig.getReceiver()));
                }

                myConsole.logResponse("%d configured exchanges%n", fixed_ex.size() + drop_ex.size() + limit_ex.size());
                if(fixed_ex.size() + drop_ex.size() + limit_ex.size() > 0)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.