use of org.apache.poi.ss.usermodel.CreationHelper in project Aspose.Cells-for-Java by aspose-cells.
the class ApacheInsertCellsData method main.
public static void main(String[] args) throws Exception {
// The path to the documents directory.
String dataDir = Utils.getDataDir(ApacheInsertCellsData.class);
Workbook wb = new HSSFWorkbook();
CreationHelper createHelper = wb.getCreationHelper();
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
Row row = sheet.createRow((short) 0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell(1).setCellValue(1.2);
row.createCell(2).setCellValue(createHelper.createRichTextString("This is a string"));
row.createCell(3).setCellValue(true);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream(dataDir + "DataInCells_Apache_Out.xls");
wb.write(fileOut);
fileOut.close();
// Print message
System.out.println("Data Added Successfully");
}
use of org.apache.poi.ss.usermodel.CreationHelper in project ART-TIME by Artezio.
the class XlsxEmitter method setComment.
private void setComment(Cell cell, String commentText) {
CreationHelper factory = getHandlerState().getWb().getCreationHelper();
Sheet sheet = getHandlerState().currentSheet;
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = factory.createClientAnchor();
anchor.setCol1(cell.getColumnIndex() + 2);
anchor.setCol2(cell.getColumnIndex() + 5);
anchor.setRow1(cell.getRowIndex() - 1);
anchor.setRow2(cell.getRowIndex() + 3);
Comment comment = drawing.createCellComment(anchor);
RichTextString str = factory.createRichTextString(commentText);
comment.setString(str);
cell.setCellComment(comment);
}
Aggregations