Package org.apache.poi.xssf.usermodel

Examples of org.apache.poi.xssf.usermodel.XSSFRichTextString


                        thisStr = '"' + value.toString() + '"';
                        break;

                    case INLINESTR:
                        // TODO: have seen an example of this, so it's untested.
                        XSSFRichTextString rtsi = new XSSFRichTextString(value.toString());
                        thisStr = '"' + rtsi.toString() + '"';
                        break;

                    case SSTINDEX:
                        String sstIndex = value.toString();
                        try {
                            int idx = Integer.parseInt(sstIndex);
                            XSSFRichTextString rtss = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx));
                            thisStr = '"' + rtss.toString() + '"';
                        }
                        catch (NumberFormatException ex) {
                            output.println("Failed to parse SST index '" + sstIndex + "': " + ex.toString());
                        }
                        break;
View Full Code Here


            logger.warn("Error-cell occurred: {}", _value);
            return _value.toString();
        case FORMULA:
            return _value.toString();
        case INLINESTR:
            XSSFRichTextString rtsi = new XSSFRichTextString(_value.toString());
            return rtsi.toString();
        case SSTINDEX:
            String sstIndex = _value.toString();
            int idx = Integer.parseInt(sstIndex);
            XSSFRichTextString rtss = new XSSFRichTextString(_sharedStringTable.getEntryAt(idx));
            return rtss.toString();
        case NUMBER:
            final String numberString = _value.toString();
            if (_formatString != null) {
                DataFormatter formatter = getDataFormatter();
                if (HSSFDateUtil.isADateFormat(_formatIndex, _formatString)) {
View Full Code Here

      OPCPackage pkg = OPCPackage.open(f.toString());
     
      XSSFReader r = new XSSFReader(pkg);
     
      assertEquals(11, r.getSharedStringsTable().getItems().size());
      assertEquals("Test spreadsheet", new XSSFRichTextString(r.getSharedStringsTable().getEntryAt(0)).toString());
    }
View Full Code Here

    // Change on comment on sheet 1, and add another into
    //  sheet 2
    Row r5 = sheet1.getRow(4);
    Comment cc5 = r5.getCell(2).getCellComment();
    cc5.setAuthor("Apache POI");
    cc5.setString(new XSSFRichTextString("Hello!"));
   
    Row r2s2 = sheet2.createRow(2);
    Cell c1r2s2 = r2s2.createCell(1);
    assertNull(c1r2s2.getCellComment());
   
    Comment cc2 = sheet2.createComment();
    cc2.setAuthor("Also POI");
    cc2.setString(new XSSFRichTextString("A new comment"));
    c1r2s2.setCellComment(cc2);
   
   
    // Save, and re-load the file
        workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
View Full Code Here

    public void endElement(String uri, String localName, String name) throws SAXException {
      // Process the last contents as required.
      // Do now, as characters() may be called more than once
      if (nextIsString && !"".equals(lastContents)) {
        int idx = Integer.parseInt(lastContents);
        lastContents = new XSSFRichTextString(sst.getEntryAt(idx)).toString();
      }

      // v => contents of a cell
      // Output after we've seen the string contents
      if (name.equals("v")) {
View Full Code Here

    CreationHelper ch = hssfWorkbook.getCreationHelper();
    ExcelTextExtractor te = new ExcelTextExtractor(metaData, colorProducer, ch, ff);

    Object compute = te.compute((RenderBox) second);
    assertTrue(compute instanceof RichTextString);
    XSSFRichTextString rt = (XSSFRichTextString) compute;
    assertEquals(4, rt.numFormattingRuns());
  }
View Full Code Here

    FastExcelTextExtractor te = new FastExcelTextExtractor(colorProducer, ff, ch);

    Element element = report.getReportHeader().getElement(0);
    Object compute = te.compute(element, runtime);
    assertTrue(compute instanceof RichTextString);
    XSSFRichTextString rt = (XSSFRichTextString) compute;
    assertEquals(4, rt.numFormattingRuns());
  }
View Full Code Here

    // Change on comment on sheet 1, and add another into
    //  sheet 2
    Row r5 = sheet1.getRow(4);
    Comment cc5 = r5.getCell(2).getCellComment();
    cc5.setAuthor("Apache POI");
    cc5.setString(new XSSFRichTextString("Hello!"));

    Row r2s2 = sheet2.createRow(2);
    Cell c1r2s2 = r2s2.createCell(1);
    assertNull(c1r2s2.getCellComment());

    Comment cc2 = sheet2.createComment();
    cc2.setAuthor("Also POI");
    cc2.setString(new XSSFRichTextString("A new comment"));
    c1r2s2.setCellComment(cc2);


    // Save, and re-load the file
    workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
View Full Code Here

        // 根据SST的索引值的到单元格的真正要存储的字符串
        // 这时characters()方法可能会被调用多次
        if (nextIsString) {
            try {
                int idx = Integer.parseInt(contents);
                contents = new XSSFRichTextString(sharedTable.getEntryAt(idx)).toString();
            } catch (Exception e) {
            }
        }
       
View Full Code Here

        assertEquals(7, sst.getCount());
        assertEquals(3, sst.getUniqueCount());

        //OK. the sst table is filled, check the contents
        assertEquals(3, sst.getItems().size());
        assertEquals("Hello, World!", new XSSFRichTextString(sst.getEntryAt(0)).toString());
        assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(1)).toString());
        assertEquals("Second string", new XSSFRichTextString(sst.getEntryAt(2)).toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.usermodel.XSSFRichTextString

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.