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.

XSSFEvenFooter.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xssf.usermodel;
  16. import org.apache.poi.ss.usermodel.Footer;
  17. import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
  18. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
  19. /**
  20. * <p>
  21. * Even page footer value. Corresponds to even printed pages.
  22. * Even page(s) in the sheet may not be printed, for example, if the print area is specified to be
  23. * a range such that it falls outside an even page's scope.
  24. * If no even footer is specified, then the odd footer's value is assumed for even page footers.
  25. * </p><p>
  26. * The even footer is activated by the "Different Even/Odd" Header/Footer property for the sheet.
  27. * If this property is not set, the even footer is ignored, and the odd footer is used instead.
  28. * </p><p>
  29. * Creating an even header or footer sets this property by default, so all you need to do to
  30. * get an even header or footer to display is to create one. Likewise, if both the even header
  31. * and footer are usnset, then this property is unset, and the odd header and footer are used
  32. * for even pages.
  33. * </p>
  34. */
  35. public class XSSFEvenFooter extends XSSFHeaderFooter implements Footer{
  36. /**
  37. * Create an instance of XSSFEvenFooter from the supplied XML bean
  38. * @see XSSFSheet#getEvenFooter()
  39. * @param headerFooter
  40. */
  41. protected XSSFEvenFooter(CTHeaderFooter headerFooter) {
  42. super(headerFooter);
  43. headerFooter.setDifferentOddEven(true);
  44. }
  45. /**
  46. * Get the content text representing the footer
  47. * @return text
  48. */
  49. @Override
  50. public String getText() {
  51. return getHeaderFooter().getEvenFooter();
  52. }
  53. /**
  54. * Set a text for the footer. If null, unset the value. If unsetting and there is no
  55. * Even Header for this sheet, the "DifferentEvenOdd" property for this sheet is
  56. * unset.
  57. *
  58. * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax
  59. * @param text - a string representing the footer.
  60. */
  61. @Override
  62. public void setText(String text) {
  63. if(text == null) {
  64. getHeaderFooter().unsetEvenFooter();
  65. if (!getHeaderFooter().isSetEvenHeader()) {
  66. getHeaderFooter().unsetDifferentOddEven();
  67. }
  68. } else {
  69. getHeaderFooter().setEvenFooter(text);
  70. }
  71. }
  72. }