Package org.apache.poi.xssf.usermodel

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


      Package pkg = Package.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


            // Aqua background
            CellStyle style = wb.createCellStyle();
            style.setFillBackgroundColor(HSSFColor.AQUA.index);
            style.setFillPattern(CellStyle.BIG_SPOTS);
            Cell cell = row.createCell((short) 1);
            cell.setCellValue(new XSSFRichTextString("X"));
            cell.setCellStyle(style);

            // Orange "foreground", foreground being the fill foreground not the font color.
            style = wb.createCellStyle();
            style.setFillForegroundColor(HSSFColor.ORANGE.index);
            style.setFillPattern(CellStyle.SOLID_FOREGROUND);
            cell = row.createCell((short) 2);
            cell.setCellValue(new XSSFRichTextString("X"));
            cell.setCellStyle(style);

            // Write the output to a file
            FileOutputStream fileOut = new FileOutputStream("fill_colors.xlsx");
            wb.write(fileOut);
View Full Code Here

        throws SAXException {
      // Process the last contents as required.
      // Do now, as characters() may be called more than once
      if(nextIsString) {
        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

        Workbook wb = new XSSFWorkbook();
        Sheet sheet = wb.createSheet("new sheet");

        Row row = sheet.createRow((short) 1);
        Cell cell = row.createCell((short) 1);
        cell.setCellValue(new XSSFRichTextString("This is a test of merging"));

        sheet.addMergedRegion(new Region(1,(short)1,1,(short)2));

        // Write the output to a file
        FileOutputStream fileOut = new FileOutputStream("merging_cells.xlsx");
View Full Code Here

            final int event = sheetStreamReader.next();
            if (event == XMLStreamConstants.START_ELEMENT && "v".equals(sheetStreamReader.getLocalName())) {
                result = sheetStreamReader.getElementText();
                if ("s".equals(cellType)) {
                    final int idx = Integer.parseInt(result);
                    result = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx)).toString();
                }
            } else if (event == XMLStreamConstants.START_ELEMENT && "t".equals(sheetStreamReader.getLocalName())) {
                result = sheetStreamReader.getElementText();
            } else if (event == XMLStreamConstants.END_ELEMENT && "c".equals(sheetStreamReader.getLocalName())) {
                break;
View Full Code Here

      String[] rowvalue = datas.get(i);
      XSSFRow nextrow = sheet.createRow(sheet.getLastRowNum() + 1);// 创建一行
      for (int j = 0; j < rowvalue.length; j++) {
        XSSFCell cell = nextrow
            .createCell(j, XSSFCell.CELL_TYPE_STRING);
        cell.setCellValue(new XSSFRichTextString(rowvalue[j]));
        if (rowvalue[j].equals("Fail")) {
          cell.setCellStyle(styleRed);
        } else if (rowvalue[j].equals("Pass")) {
          cell.setCellStyle(styleGreen);
        } else {
View Full Code Here

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

            final int event = sheetStreamReader.next();
            if (event == XMLStreamConstants.START_ELEMENT && "v".equals(sheetStreamReader.getLocalName())) {
                result = sheetStreamReader.getElementText();
                if ("s".equals(cellType)) {
                    final int idx = Integer.parseInt(result);
                    result = new XSSFRichTextString(sharedStringsTable.getEntryAt(idx)).toString();
                }
            } else if (event == XMLStreamConstants.START_ELEMENT && "t".equals(sheetStreamReader.getLocalName())) {
                result = sheetStreamReader.getElementText();
            } else if (event == XMLStreamConstants.END_ELEMENT && "c".equals(sheetStreamReader.getLocalName())) {
                break;
View Full Code Here

        throws SAXException {
      // Process the last contents as required.
      // Do now, as characters() may be called more than once
      if(nextIsString) {
        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

      Package pkg = Package.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

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.