Package org.apache.poi.hssf.usermodel

Examples of org.apache.poi.hssf.usermodel.HSSFRichTextString


        worksheet.setColumnWidth((short) 1, (short)(30 * 256));
        worksheet.setColumnWidth((short) 4, (short)(20 * 256));

        HSSFRow row = worksheet.createRow((short)0);

        HSSFRichTextString value = new HSSFRichTextString("Customers");
        value.applyFont(font);
        row.createCell((short)0).setCellValue(value);

        row = worksheet.createRow((short)1);
        row.createCell((short)0).setCellValue(new HSSFRichTextString("Customer Account Details"));

        worksheet.createRow((short)2);

        row = worksheet.createRow((short)3);

        HSSFCellStyle style = wb.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        value = new HSSFRichTextString("Name");
        value.applyFont(font);
        HSSFCell cell = row.createCell((short)0);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Email");
        value.applyFont(font);
        cell = row.createCell((short)1);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Age");
        value.applyFont(font);
        cell = row.createCell((short)2);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Holdings");
        value.applyFont(font);
        cell = row.createCell((short)3);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Investments");
        value.applyFont(font);
        cell = row.createCell((short)4);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        int rowIndex = 4;

        List customers = getCustomerService().getCustomers();
        for (int i = 0; i < customers.size(); i++) {
            Customer customer = (Customer) customers.get(i);

            row = worksheet.createRow((short) rowIndex++);

            row.createCell((short) 0).setCellValue(new HSSFRichTextString(customer.getName()));
            row.createCell((short) 1).setCellValue(new HSSFRichTextString(customer.getEmail()));

            if (customer.getAge() != null) {
                row.createCell((short) 2).setCellValue(customer.getAge().intValue());
            }

            if (customer.getHoldings() != null) {
                row.createCell((short) 3).setCellValue(customer.getHoldings().doubleValue());
            }

            row.createCell((short) 4).setCellValue(new HSSFRichTextString(customer.getInvestments()));
        }

        return wb;
    }
View Full Code Here


            cell.setCellValue((Calendar) value);
        } else if (value instanceof Boolean) {
            cell.setCellValue((Boolean) value);
        } else {
            cell.setCellValue(
                new HSSFRichTextString(ObjectUtils.toString(value)));
        }
    }
View Full Code Here

        worksheet.setColumnWidth(1, (30 * 256));
        worksheet.setColumnWidth(4, (20 * 256));

        HSSFRow row = worksheet.createRow(0);

        HSSFRichTextString value = new HSSFRichTextString("Customers");
        value.applyFont(font);
        row.createCell(0).setCellValue(value);

        row = worksheet.createRow(1);
        row.createCell(0).setCellValue(new HSSFRichTextString("Customer Account Details"));

        worksheet.createRow(2);

        row = worksheet.createRow(3);

        HSSFCellStyle style = wb.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        font = wb.createFont();
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        value = new HSSFRichTextString("Name");
        value.applyFont(font);
        HSSFCell cell = row.createCell(0);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Email");
        value.applyFont(font);
        cell = row.createCell(1);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Age");
        value.applyFont(font);
        cell = row.createCell(2);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Holdings");
        value.applyFont(font);
        cell = row.createCell(3);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        value = new HSSFRichTextString("Investments");
        value.applyFont(font);
        cell = row.createCell(4);
        cell.setCellValue(value);
        cell.setCellStyle(style);

        int rowIndex = 4;

        List<Customer> customers = customerService.getCustomers();
        for (int i = 0; i < customers.size(); i++) {
            Customer customer = (Customer) customers.get(i);

            row = worksheet.createRow(rowIndex++);

            row.createCell(0).setCellValue(new HSSFRichTextString(customer.getName()));
            row.createCell(1).setCellValue(new HSSFRichTextString(customer.getEmail()));

            if (customer.getAge() != null) {
                row.createCell(2).setCellValue(customer.getAge().intValue());
            }

            if (customer.getHoldings() != null) {
                row.createCell(3).setCellValue(customer.getHoldings().doubleValue());
            }

            row.createCell(4).setCellValue(new HSSFRichTextString(customer.getInvestments()));
        }

        return wb;
    }
View Full Code Here

        XSSFSheet sh = wb.createSheet();
        XSSFComment comment = sh.createDrawingPatriarch().createCellComment(new XSSFClientAnchor());

        //passing HSSFRichTextString is incorrect
        try {
            comment.setString(new HSSFRichTextString(TEST_RICHTEXTSTRING));
            fail("expected exception");
        } catch (IllegalArgumentException e){
            assertEquals("Only XSSFRichTextString argument is supported", e.getMessage());
        }
View Full Code Here

          c.setCellValue("");
        }
        break;
      case TEXT:
        if (cell.getValue() != null) {
          HSSFRichTextString value = new HSSFRichTextString(cell.getValue().toString());
          c.setCellValue(value);
        } else {
          c.setCellType(org.apache.poi.ss.usermodel.Cell.CELL_TYPE_STRING);
          c.setCellValue("");
        }
View Full Code Here

    public TextObjectRecord( RecordInputStream in )
    {
        super( in );
        if (str == null)
          str = new HSSFRichTextString("");
    }
View Full Code Here


    public int serialize( int offset, byte[] data )
    {
        // Temporarily blank out str so that record size is calculated without the continue records.
        HSSFRichTextString temp = str;
        str = new HSSFRichTextString("");
        int bytesWritten1 = super.serialize( offset, data );
        str = temp;

        int pos = offset + bytesWritten1;
        if ( str.getString().equals( "" ) == false )
View Full Code Here

            }
            else
            {
            s = in.readUnicodeLEString(getTextLength());
        }
        str = new HSSFRichTextString( s );
    }
View Full Code Here

        XSSFSheet sh = wb.createSheet();
        XSSFComment comment = sh.createDrawingPatriarch().createCellComment(new XSSFClientAnchor());

        //passing HSSFRichTextString is incorrect
        try {
            comment.setString(new HSSFRichTextString(TEST_RICHTEXTSTRING));
            fail("expected exception");
        } catch (IllegalArgumentException e){
            assertEquals("Only XSSFRichTextString argument is supported", e.getMessage());
        }
View Full Code Here

    void clearNumber(HSSFSheet sheet, int row){
        String numberFound = getNumber(sheet,row);
        if(numberFound.length()>0){
            int field = getColumn("number");
            if(field!=-1){
               sheet.getRow(row).getCell(field).setCellValue(new HSSFRichTextString(""));
            }
            CountsAreDirty = true;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.hssf.usermodel.HSSFRichTextString

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.