Package org.apache.poi.ss.usermodel

Examples of org.apache.poi.ss.usermodel.Workbook.createCellStyle()


    public void testCellFormatting() throws Exception {
      Workbook workbook = new XSSFWorkbook();
      Sheet sheet = workbook.createSheet();
      CreationHelper creationHelper = workbook.getCreationHelper();
     
      CellStyle cs = workbook.createCellStyle();
      assertNotNull(cs);
     
      assertNotNull(creationHelper);
      assertNotNull(creationHelper.createDataFormat());
     
View Full Code Here


       // Apply the font
       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

        Row row = sheet.createRow(2);
        Cell cell = row.createCell(2);
        cell.setCellValue("Use \n with word wrap on to create a new line");

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

        //increase row height to accomodate two lines of text
        row.setHeightInPoints((2*sheet.getDefaultRowHeightInPoints()));
 
View Full Code Here

        short colNum = 0;

        row = sheet.createRow(rowNum++);
        cell = row.createCell(colNum);
        cell.setCellValue(11111.25);
        style = wb.createCellStyle();
        style.setDataFormat(format.getFormat("0.0"));
        cell.setCellStyle(style);

        row = sheet.createRow(rowNum++);
        cell = row.createCell(colNum);
View Full Code Here

        cell.setCellStyle(style);

        row = sheet.createRow(rowNum++);
        cell = row.createCell(colNum);
        cell.setCellValue(11111.25);
        style = wb.createCellStyle();
        style.setDataFormat(format.getFormat("#,##0.0000"));
        cell.setCellStyle(style);

        FileOutputStream fileOut = new FileOutputStream("ooxml_dataFormat.xlsx");
        wb.write(fileOut);
View Full Code Here

        short colNum = 0;

        row = sheet.createRow(rowNum++);
        cell = row.createCell(colNum);
        cell.setCellValue(11111.25);
        style = wb.createCellStyle();
        style.setDataFormat(format.getFormat("0.0"));
        cell.setCellStyle(style);

        row = sheet.createRow(rowNum++);
        cell = row.createCell(colNum);
View Full Code Here

        cell.setCellStyle(style);

        row = sheet.createRow(rowNum++);
        cell = row.createCell(colNum);
        cell.setCellValue(11111.25);
        style = wb.createCellStyle();
        style.setDataFormat(format.getFormat("#,##0.0000"));
        cell.setCellStyle(style);

        FileOutputStream fileOut = new FileOutputStream("ooxml_dataFormat.xlsx");
        wb.write(fileOut);
View Full Code Here

          //4.2 text
          row.createCell(1).setCellValue("Text");
       
          //4.3 date cell
          CreationHelper createHelper = wb.getCreationHelper();
          CellStyle cellStyle = wb.createCellStyle();
          cellStyle.setDataFormat(createHelper.createDataFormat().getFormat("m/d/yy h:mm"));
          Cell cell = row.createCell(2);
          cell.setCellValue(new Date());
          cell.setCellStyle(cellStyle);
 
View Full Code Here

    this.bold = bold;
  }

  public void apachePOI(Cell cell) {
    Workbook wb = WayIO.workbookOf(cell);
    CellStyle style = wb.createCellStyle();
    style.setAlignment(align.apachePOI());

    if (bold) {
      Font font = wb.createFont();
      font.setBoldweight(Font.BOLDWEIGHT_BOLD);
View Full Code Here

    public void testCellFormatting() {
      Workbook workbook = new XSSFWorkbook();
      Sheet sheet = workbook.createSheet();
      CreationHelper creationHelper = workbook.getCreationHelper();
     
      CellStyle cs = workbook.createCellStyle();
      assertNotNull(cs);
     
      assertNotNull(creationHelper);
      assertNotNull(creationHelper.createDataFormat());
     
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.