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);
}
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;
}
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();
}
}
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;
}
Aggregations