Guest User

Untitled

a guest
Jul 21st, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // Create empty Workbook object.
  2. com.aspose.cells.Workbook wb = new com.aspose.cells.Workbook();
  3.  
  4. // Access first worksheet.
  5. Worksheet ws = wb.getWorksheets().get(0);
  6.  
  7. // Access cell C4 and add some text inside it.
  8. Cell c4 = ws.getCells().get("C4");
  9. c4.putValue("Aspose File Format APIs");
  10.  
  11. // Access cell style.
  12. Style st = c4.getStyle();
  13.  
  14. // Set the horizontal and vertical alignment of the cell style.
  15. st.setHorizontalAlignment(TextAlignmentType.CENTER);
  16. st.setVerticalAlignment(TextAlignmentType.CENTER);
  17.  
  18. // Set the font color to red.
  19. st.getFont().setColor(Color.getRed());
  20.  
  21. // Set the cell style.
  22. c4.setStyle(st);
  23.  
  24. // Set the cell's column width and row height.
  25. ws.getCells().setColumnWidth(c4.getColumn(), 30);
  26. ws.getCells().setRowHeight(c4.getRow(), 40);
  27.  
  28. // Save the workbook in output Excel format.
  29. wb.save("outputCenterAlignExcelCell.xlsx", SaveFormat.XLSX);
Add Comment
Please, Sign In to add comment