You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XSSFDxfStyleProvider.java 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package org.apache.poi.xssf.usermodel;
  2. import org.apache.poi.ss.usermodel.BorderFormatting;
  3. import org.apache.poi.ss.usermodel.DifferentialStyleProvider;
  4. import org.apache.poi.ss.usermodel.ExcelNumberFormat;
  5. import org.apache.poi.ss.usermodel.FontFormatting;
  6. import org.apache.poi.ss.usermodel.PatternFormatting;
  7. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf;
  8. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmt;
  9. /**
  10. * Style based on a dxf record - e.g. table style element or conditional formatting rule
  11. */
  12. public class XSSFDxfStyleProvider implements DifferentialStyleProvider {
  13. private final BorderFormatting border;
  14. private final FontFormatting font;
  15. private final ExcelNumberFormat number;
  16. private final PatternFormatting fill;
  17. /**
  18. * @param dxf
  19. */
  20. public XSSFDxfStyleProvider(CTDxf dxf) {
  21. if (dxf == null) {
  22. border = null;
  23. font = null;
  24. number = null;
  25. fill = null;
  26. } else {
  27. border = dxf.isSetBorder() ? new XSSFBorderFormatting(dxf.getBorder()) : null;
  28. font = dxf.isSetFont() ? new XSSFFontFormatting(dxf.getFont()) : null;
  29. if (dxf.isSetNumFmt()) {
  30. CTNumFmt numFmt = dxf.getNumFmt();
  31. number = new ExcelNumberFormat((int) numFmt.getNumFmtId(), numFmt.getFormatCode());
  32. } else {
  33. number = null;
  34. }
  35. fill = dxf.isSetFill() ? new XSSFPatternFormatting(dxf.getFill()) : null;
  36. }
  37. }
  38. public BorderFormatting getBorderFormatting() {
  39. return border;
  40. }
  41. public FontFormatting getFontFormatting() {
  42. return font;
  43. }
  44. public ExcelNumberFormat getNumberFormat() {
  45. return number;
  46. }
  47. public PatternFormatting getPatternFormatting() {
  48. return fill;
  49. }
  50. }