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.

PrintHeadersRecord.java 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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.hssf.record;
  16. import java.util.Map;
  17. import java.util.function.Supplier;
  18. import org.apache.poi.util.GenericRecordUtil;
  19. import org.apache.poi.util.LittleEndianOutput;
  20. /**
  21. * Whether or not to print the row/column headers when you enjoy your spreadsheet in the physical form.
  22. *
  23. * @version 2.0-pre
  24. */
  25. public final class PrintHeadersRecord extends StandardRecord {
  26. public static final short sid = 0x2a;
  27. private short field_1_print_headers;
  28. public PrintHeadersRecord() {}
  29. public PrintHeadersRecord(PrintHeadersRecord other) {
  30. super(other);
  31. field_1_print_headers = other.field_1_print_headers;
  32. }
  33. public PrintHeadersRecord(RecordInputStream in) {
  34. field_1_print_headers = in.readShort();
  35. }
  36. /**
  37. * set to print the headers - y/n
  38. * @param p printheaders or not
  39. */
  40. public void setPrintHeaders(boolean p) {
  41. if (p) {
  42. field_1_print_headers = 1;
  43. } else {
  44. field_1_print_headers = 0;
  45. }
  46. }
  47. /**
  48. * get whether to print the headers - y/n
  49. * @return printheaders or not
  50. */
  51. public boolean getPrintHeaders()
  52. {
  53. return (field_1_print_headers == 1);
  54. }
  55. public void serialize(LittleEndianOutput out) {
  56. out.writeShort(field_1_print_headers);
  57. }
  58. protected int getDataSize() {
  59. return 2;
  60. }
  61. public short getSid()
  62. {
  63. return sid;
  64. }
  65. public PrintHeadersRecord copy() {
  66. return new PrintHeadersRecord(this);
  67. }
  68. @Override
  69. public HSSFRecordTypes getGenericRecordType() {
  70. return HSSFRecordTypes.PRINT_HEADERS;
  71. }
  72. @Override
  73. public Map<String, Supplier<?>> getGenericProperties() {
  74. return GenericRecordUtil.getGenericProperties("printHeaders", this::getPrintHeaders);
  75. }
  76. }