Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

XSSFEvenHeader.java 3.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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.Header;
  17. import org.apache.poi.xssf.usermodel.extensions.XSSFHeaderFooter;
  18. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
  19. /**
  20. * <p>
  21. * Even page header value. Corresponds to even printed pages. Even page(s) in
  22. * the sheet may not be printed, for example, if the print area is specified to
  23. * be a range such that it falls outside an even page's scope. If no even header
  24. * is specified, then odd header value is assumed for even page headers.
  25. * </p><p>
  26. * The even header is activated by the "Different Even/Odd" Header/Footer property for the sheet.
  27. * If this property is not set, the even header 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 it. 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 XSSFEvenHeader extends XSSFHeaderFooter implements Header {
  36. /**
  37. * Create an instance of XSSFEvenHeader from the supplied XML bean. If an even
  38. * header is created, The property "DifferentOddEven" is set for this sheet as well.
  39. *
  40. * @see XSSFSheet#getEvenHeader()
  41. */
  42. protected XSSFEvenHeader(CTHeaderFooter headerFooter) {
  43. super(headerFooter);
  44. headerFooter.setDifferentOddEven(true);
  45. }
  46. /**
  47. * Get the content text representing this header
  48. *
  49. * @return text
  50. */
  51. @Override
  52. public String getText() {
  53. return getHeaderFooter().getEvenHeader();
  54. }
  55. /**
  56. * Set a text for the header. If null, unset the value. If unsetting and there is no
  57. * Even Footer for this sheet, the "DifferentEvenOdd" property for this sheet is
  58. * unset.
  59. *
  60. * @see XSSFHeaderFooter to see how to create a string with Header/Footer
  61. * Formatting Syntax
  62. * @param text
  63. * - a string representing the header.
  64. */
  65. @Override
  66. public void setText(String text) {
  67. if (text == null) {
  68. getHeaderFooter().unsetEvenHeader();
  69. if (!getHeaderFooter().isSetEvenFooter()) {
  70. getHeaderFooter().unsetDifferentOddEven();
  71. }
  72. } else {
  73. getHeaderFooter().setEvenHeader(text);
  74. }
  75. }
  76. }