use of org.xlsx4j.sml.Cell 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.Cell 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.Cell 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);
}
use of org.xlsx4j.sml.Cell 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;
}
use of org.xlsx4j.sml.Cell in project Aspose.Cells-for-Java by aspose-cells.
the class Xlsx4jHeightAdjustment method main.
/**
* @param args
* @throws JAXBException
* @throws Docx4JException
*/
public static void main(String[] args) throws JAXBException, Docx4JException {
// The path to the documents directory.
String dataDir = Utils.getDataDir(Xlsx4jHeightAdjustment.class);
// TODO Auto-generated method stub
SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);
CTSheetFormatPr format = Context.getsmlObjectFactory().createCTSheetFormatPr();
format.setDefaultRowHeight(5);
format.setCustomHeight(Boolean.TRUE);
sheet.getJaxbElement().setSheetFormatPr(format);
SheetData sheetData = sheet.getJaxbElement().getSheetData();
Row row = Context.getsmlObjectFactory().createRow();
row.setHt(66.0);
row.setCustomHeight(Boolean.TRUE);
row.setR(1L);
Cell cell1 = Context.getsmlObjectFactory().createCell();
cell1.setV("1234");
row.getC().add(cell1);
Cell cell2 = Context.getsmlObjectFactory().createCell();
cell2.setV("56");
row.getC().add(cell2);
sheetData.getRow().add(row);
SaveToZipFile saver = new SaveToZipFile(pkg);
saver.save(dataDir + "RowHeight-Xlsx4j.xlsx");
}
Aggregations