use of org.xlsx4j.sml.Row 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.Row 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);
}
use of org.xlsx4j.sml.Row 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.Row in project com.revolsys.open by revolsys.
the class XlsxRecordWriter method addHeaderRow.
private void addHeaderRow(final Worksheet worksheet, final RecordDefinition recordDefinition) {
final List<Cols> columnGroups = worksheet.getCols();
final Cols columns = smlObjectFactory.createCols();
columnGroups.add(columns);
final Row headerRow = smlObjectFactory.createRow();
this.sheetRows.add(headerRow);
final List<Cell> cells = headerRow.getC();
for (final FieldDefinition field : recordDefinition.getFields()) {
final String fieldName = field.getName();
final Col column = smlObjectFactory.createCol();
columns.getCol().add(column);
column.setMin(field.getIndex() + 1);
column.setMax(field.getIndex() + 1);
column.setBestFit(true);
final int textLength = Math.min(40, Math.max(fieldName.length() + 2, field.getMaxStringLength()));
column.setWidth(textLength * 1.25);
addCellInlineString(cells, fieldName);
}
}
use of org.xlsx4j.sml.Row in project Aspose.Cells-for-Java by aspose-cells.
the class Xlsx4jNewSpreadSheet method addContent.
private static void addContent(WorksheetPart sheet) {
// Minimal content already present
SheetData sheetData = sheet.getJaxbElement().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);
}
Aggregations