Examples of HSSFRichTextString


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<Customer> customers = customerService.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

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

            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

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

        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){
            ;
        }
View Full Code Here

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

    if (field_6_textLength > 0) {
      text = readRawString(in, field_6_textLength);
    } else {
      text = "";
    }
    _text = new HSSFRichTextString(text);

    if (field_7_formattingDataLength > 0) {
      processFontRuns(in, _text, field_7_formattingDataLength);
    }
  }
View Full Code Here

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

    public void testStore()
    {
        TextObjectRecord record = new TextObjectRecord();


        HSSFRichTextString str = new HSSFRichTextString("AB");
        str.applyFont(0, 2, (short)0x0018);
        str.applyFont(2, 2, (short)0x0320);

        record.setHorizontalTextAlignment(TextObjectRecord.HORIZONTAL_TEXT_ALIGNMENT_CENTERED);
        record.setVerticalTextAlignment(TextObjectRecord.VERTICAL_TEXT_ALIGNMENT_JUSTIFY);
        record.setTextLocked(true);
        record.setTextOrientation(TextObjectRecord.TEXT_ORIENTATION_ROT_RIGHT);
View Full Code Here

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

         
            SimpleFeatureType ft = (SimpleFeatureType) fc.getSchema();
            HSSFCell cell;
           
            cell = header.createCell(0);
            cell.setCellValue(new HSSFRichTextString("FID"));
            for ( int i = 0; i < ft.getAttributeCount(); i++ ) {
                AttributeDescriptor ad = ft.getDescriptor(i);
               
                cell = header.createCell(i+1);
                cell.setCellValue(new HSSFRichTextString(ad.getLocalName()));
            }
           
            // write out the features
            FeatureIterator<SimpleFeature> i = fc.features();
            int r = 0; // row index
            try {
              HSSFRow row;
                while( i.hasNext() ) {
                  r++; //start at 1, since header is at 0
                    SimpleFeature f = i.next();
                    row = sheet.createRow((short) r);
                    cell = row.createCell(0);
                    cell.setCellValue(new HSSFRichTextString(f.getID()));
                    for ( int j = 0; j < f.getAttributeCount(); j++ ) {
                        Object att = f.getAttribute( j );
                        if ( att != null ) {
                          cell = row.createCell(j+1);
                          if(att instanceof Number) {
                                cell.setCellValue(((Number) att).doubleValue());
                          } else if(att instanceof Date) {
                              cell.setCellValue((Date) att);
                          } else if(att instanceof Calendar) {
                              cell.setCellValue((Calendar) att);
                          } else if(att instanceof Boolean) {
                              cell.setCellValue((Boolean) att);
                          } else {
                                // ok, it seems we have no better way than dump it as a string
                                String stringVal = att.toString();

                                // if string length > excel cell limit, truncate it and warn the
                                // user, otherwise excel workbook will be corrupted
                                if (stringVal.length() > EXCELL_CELL_CHAR_LIMIT) {
                                    stringVal = STRING_LENGTH_WARNING + " "
                                            + stringVal.substring(0, EXCELL_CELL_CHAR_LIMIT
                                                    - STRING_LENGTH_WARNING.length() - 1);
                                }
                                cell.setCellValue(new HSSFRichTextString(stringVal));
                          }
                        }
                    }   
                }
            } finally {
View Full Code Here

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

        DrawingRecord d2 = new DrawingRecord();
        d2.setData( HexRead.readFromString( msoDrawingRecord2 ) );

        TextObjectRecord r2 = new TextObjectRecord();
        r2.setStr(new HSSFRichTextString("Aggregated"));
        NoteRecord n2 = new NoteRecord();

        List<Record> recordStream = new ArrayList<Record>();
        recordStream.add(InternalSheet.createBOF());
        recordStream.add( d1 );
View Full Code Here

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

        assertEquals(TextObjectRecord.TEXT_ORIENTATION_NONE, record.getTextOrientation());
        assertEquals("Hello, World!", record.getStr().getString());
    }

    public void testWrite() {
        HSSFRichTextString str = new HSSFRichTextString("Hello, World!");

        TextObjectRecord record = new TextObjectRecord();
        record.setStr(str);
        record.setHorizontalTextAlignment( TextObjectRecord.HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED );
        record.setVerticalTextAlignment( TextObjectRecord.VERTICAL_TEXT_ALIGNMENT_TOP );
View Full Code Here

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

    /**
     * Zero {@link ContinueRecord}s follow a {@link TextObjectRecord} if the text is empty
     */
    public void testWriteEmpty() {
        HSSFRichTextString str = new HSSFRichTextString("");

        TextObjectRecord record = new TextObjectRecord();
        record.setStr(str);

        byte [] ser = record.serialize();
View Full Code Here

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

        for (int i = 0; i < length.length; i++) {
            StringBuffer buff = new StringBuffer(length[i]);
            for (int j = 0; j < length[i]; j++) {
                buff.append("x");
            }
            HSSFRichTextString str = new HSSFRichTextString(buff.toString());

            TextObjectRecord obj = new TextObjectRecord();
            obj.setStr(str);

            byte [] data = obj.serialize();
            RecordInputStream is = new RecordInputStream(new ByteArrayInputStream(data));
            is.nextRecord();
            TextObjectRecord record = new TextObjectRecord(is);
            str = record.getStr();

            assertEquals(buff.length(), str.length());
            assertEquals(buff.toString(), str.getString());
        }
    }
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.