Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

XSSFEvenFooter.java 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. */
  40. protected XSSFEvenFooter(CTHeaderFooter headerFooter) {
  41. super(headerFooter);
  42. headerFooter.setDifferentOddEven(true);
  43. }
  44. /**
  45. * Get the content text representing the footer
  46. * @return text
  47. */
  48. @Override
  49. public String getText() {
  50. return getHeaderFooter().getEvenFooter();
  51. }
  52. /**
  53. * Set a text for the footer. If null, unset the value. If unsetting and there is no
  54. * Even Header for this sheet, the "DifferentEvenOdd" property for this sheet is
  55. * unset.
  56. *
  57. * @see XSSFHeaderFooter to see how to create a string with Header/Footer Formatting Syntax
  58. * @param text - a string representing the footer.
  59. */
  60. @Override
  61. public void setText(String text) {
  62. if(text == null) {
  63. getHeaderFooter().unsetEvenFooter();
  64. if (!getHeaderFooter().isSetEvenHeader()) {
  65. getHeaderFooter().unsetDifferentOddEven();
  66. }
  67. } else {
  68. getHeaderFooter().setEvenFooter(text);
  69. }
  70. }
  71. }