use of org.xlsx4j.sml.Cell in project com.revolsys.open by revolsys.
the class XlsxRecordWriter method addCellNumber.
private void addCellNumber(final List<Cell> cells, final String value) {
final Cell cell = smlObjectFactory.createCell();
cell.setV(value);
cells.add(cell);
}
use of org.xlsx4j.sml.Cell 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.Cell in project com.revolsys.open by revolsys.
the class XlsxRecordWriter method write.
@Override
public void write(final Record record) {
final Row recordRow = smlObjectFactory.createRow();
this.sheetRows.add(recordRow);
final List<Cell> cells = recordRow.getC();
for (final FieldDefinition field : this.recordDefinition.getFields()) {
final Object value = record.getValue(field);
final String string = field.toString(value);
if (value instanceof Number) {
addCellNumber(cells, string);
} else {
addCellInlineString(cells, string);
}
}
}
use of org.xlsx4j.sml.Cell 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.Cell in project Aspose.Cells-for-Java by aspose-cells.
the class Xlsx4jAddComments method addContent.
private static void addContent(WorksheetPart sheet) throws JAXBException, Docx4JException {
// Minimal content already present
SheetData sheetData = sheet.getContents().getSheetData();
// Now add
Row row = Context.getsmlObjectFactory().createRow();
Cell cell = Context.getsmlObjectFactory().createCell();
cell.setV("1234");
row.getC().add(cell);
row.getC().add(createCell("hello world!"));
sheetData.getRow().add(row);
// ADD A COMMENT TO CELL A1
CommentsPart cp = new CommentsPart();
cp.setContents(createComment("A1"));
sheet.addTargetPart(cp);
// Add <legacyDrawing r:id="rId1"/>
VMLPart vmlPart = new VMLPart();
// corresponds to A1
vmlPart.setContents(getVml(0, 0));
// you'll need extra VML for each comment
Relationship rel = sheet.addTargetPart(vmlPart);
CTLegacyDrawing legacyDrawing = Context.getsmlObjectFactory().createCTLegacyDrawing();
legacyDrawing.setId(rel.getId());
sheet.getContents().setLegacyDrawing(legacyDrawing);
}
Aggregations