use of org.xlsx4j.sml.SheetData 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.SheetData in project com.revolsys.open by revolsys.
the class XlsxRecordReader method initDo.
@Override
protected void initDo() {
super.initDo();
try (InputStream in = this.resource.newBufferedInputStream()) {
final SpreadsheetMLPackage spreadsheetPackage = (SpreadsheetMLPackage) OpcPackage.load(in);
final DocPropsCustomPart customProperties = spreadsheetPackage.getDocPropsCustomPart();
if (customProperties != null) {
int srid = 0;
try {
srid = Integer.parseInt(customProperties.getProperty("srid").getLpwstr());
} catch (final Throwable e) {
}
int axisCount = 2;
try {
axisCount = Integer.parseInt(customProperties.getProperty("axisCount").getLpwstr());
if (axisCount > 4) {
axisCount = 2;
}
} catch (final Throwable e) {
}
double scaleXy = 0;
try {
scaleXy = Double.parseDouble(customProperties.getProperty("scaleXy").getLpwstr());
} catch (final Throwable e) {
}
double scaleZ = 0;
try {
scaleZ = Double.parseDouble(customProperties.getProperty("scaleZ").getLpwstr());
} catch (final Throwable e) {
}
final GeometryFactory geometryFactory = GeometryFactory.fixed(srid, axisCount, scaleXy, scaleXy, scaleZ);
setGeometryFactory(geometryFactory);
}
WorksheetPart worksheetPart = null;
for (final Part part : spreadsheetPackage.getParts().getParts().values()) {
if (part instanceof WorksheetPart) {
if (worksheetPart == null) {
worksheetPart = (WorksheetPart) part;
}
} else if (part instanceof SharedStrings) {
final SharedStrings sharedStrings = (SharedStrings) part;
final CTSst contents = sharedStrings.getContents();
this.sharedStringList = contents.getSi();
}
}
if (worksheetPart != null) {
final Worksheet worksheet = worksheetPart.getContents();
final SheetData sheetData = worksheet.getSheetData();
this.rows = sheetData.getRow();
final List<String> line = readNextRow();
final String baseName = this.resource.getBaseName();
newRecordDefinition(baseName, line);
}
} catch (final IOException | Docx4JException e) {
Logs.error(this, "Unable to open " + this.resource, e);
} catch (final NoSuchElementException e) {
}
}
use of org.xlsx4j.sml.SheetData 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.SheetData 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