Search in sources :

Example 1 with CTRst

use of org.xlsx4j.sml.CTRst in project com.revolsys.open by revolsys.

the class XlsxRecordWriter method addCellInlineString.

private void addCellInlineString(final List<Cell> cells, String value) {
    if (value == null) {
        value = "";
    }
    final CTXstringWhitespace cellContext = smlObjectFactory.createCTXstringWhitespace();
    cellContext.setValue(value);
    final CTRst cellString = new CTRst();
    cellString.setT(cellContext);
    final Cell cell = smlObjectFactory.createCell();
    cell.setT(STCellType.INLINE_STR);
    cell.setIs(cellString);
    cells.add(cell);
}
Also used : CTRst(org.xlsx4j.sml.CTRst) Cell(org.xlsx4j.sml.Cell) CTXstringWhitespace(org.xlsx4j.sml.CTXstringWhitespace)

Example 2 with CTRst

use of org.xlsx4j.sml.CTRst in project Aspose.Cells-for-Java by aspose-cells.

the class Xlsx4jNewSpreadSheet method createCell.

/**
 *    // Note: if you are trying to add characters, not a number,
 *    // the easiest approach is to use inline strings (as opposed to the shared string table).
 *    // See http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2011/11/22/screen-cast-write-simpler-spreadsheetml-when-generating-spreadsheets.aspx
 *    // and http://www.docx4java.org/forums/xlsx-java-f15/cells-with-character-values-t874.html
 */
private static Cell createCell(String content) {
    Cell cell = Context.getsmlObjectFactory().createCell();
    CTXstringWhitespace ctx = Context.getsmlObjectFactory().createCTXstringWhitespace();
    ctx.setValue(content);
    CTRst ctrst = new CTRst();
    ctrst.setT(ctx);
    cell.setT(STCellType.INLINE_STR);
    // add ctrst as inline string
    cell.setIs(ctrst);
    return cell;
}
Also used : CTRst(org.xlsx4j.sml.CTRst) Cell(org.xlsx4j.sml.Cell) CTXstringWhitespace(org.xlsx4j.sml.CTXstringWhitespace)

Example 3 with CTRst

use of org.xlsx4j.sml.CTRst in project com.revolsys.open by revolsys.

the class XlsxRecordReader method readNextRow.

/**
 * Reads the next line from the buffer and converts to a string array.
 *
 * @return a string array with each comma-separated element as a separate
 *         entry.
 * @throws IOException if bad things happen during the read
 */
private List<String> readNextRow() {
    if (this.rowIndex < this.rows.size()) {
        final List<String> values = new ArrayList<>();
        final Row row = this.rows.get(this.rowIndex);
        final List<Cell> cells = row.getC();
        for (final Cell cell : cells) {
            String value = null;
            final String cellValue = cell.getV();
            final STCellType cellType = cell.getT();
            switch(cellType) {
                case S:
                    final int stringIndex = Integer.parseInt(cellValue);
                    final CTRst sharedString = this.sharedStringList.get(stringIndex);
                    final CTXstringWhitespace text = sharedString.getT();
                    value = text.getValue();
                    break;
                default:
                    if (cellValue == null) {
                        final CTRst is = cell.getIs();
                        if (is != null) {
                            value = is.getT().getValue();
                        }
                    } else {
                        value = cellValue;
                    }
                    break;
            }
            final int columnIndex = getColumnIndex(cell);
            if (columnIndex == -1) {
                values.add(value);
            } else {
                while (values.size() < columnIndex) {
                    values.add(null);
                }
                values.add(columnIndex, value);
            }
        }
        this.rowIndex++;
        return values;
    } else {
        throw new NoSuchElementException();
    }
}
Also used : STCellType(org.xlsx4j.sml.STCellType) CTRst(org.xlsx4j.sml.CTRst) ArrayList(java.util.ArrayList) Row(org.xlsx4j.sml.Row) Cell(org.xlsx4j.sml.Cell) NoSuchElementException(java.util.NoSuchElementException) CTXstringWhitespace(org.xlsx4j.sml.CTXstringWhitespace)

Example 4 with CTRst

use of org.xlsx4j.sml.CTRst in project Aspose.Cells-for-Java by aspose-cells.

the class Xlsx4jAddComments method createCell.

private static Cell createCell(String content) {
    Cell cell = Context.getsmlObjectFactory().createCell();
    CTXstringWhitespace ctx = Context.getsmlObjectFactory().createCTXstringWhitespace();
    ctx.setValue(content);
    CTRst ctrst = new CTRst();
    ctrst.setT(ctx);
    cell.setT(STCellType.INLINE_STR);
    // add ctrst as inline string
    cell.setIs(ctrst);
    return cell;
}
Also used : CTRst(org.xlsx4j.sml.CTRst) Cell(org.xlsx4j.sml.Cell) CTXstringWhitespace(org.xlsx4j.sml.CTXstringWhitespace)

Aggregations

CTRst (org.xlsx4j.sml.CTRst)4 CTXstringWhitespace (org.xlsx4j.sml.CTXstringWhitespace)4 Cell (org.xlsx4j.sml.Cell)4 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1 Row (org.xlsx4j.sml.Row)1 STCellType (org.xlsx4j.sml.STCellType)1