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ů.

NumberRecord.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 org.apache.poi.ss.util.NumberToTextConverter;
  17. import org.apache.poi.util.LittleEndianOutput;
  18. /**
  19. * NUMBER (0x0203) Contains a numeric cell value. <P>
  20. * REFERENCE: PG 334 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
  21. * @author Andrew C. Oliver (acoliver at apache dot org)
  22. * @author Jason Height (jheight at chariot dot net dot au)
  23. */
  24. public final class NumberRecord extends CellRecord {
  25. public static final short sid = 0x0203;
  26. private double field_4_value;
  27. /** Creates new NumberRecord */
  28. public NumberRecord() {
  29. // fields uninitialised
  30. }
  31. /**
  32. * @param in the RecordInputstream to read the record from
  33. */
  34. public NumberRecord(RecordInputStream in) {
  35. super(in);
  36. field_4_value = in.readDouble();
  37. }
  38. /**
  39. * set the value for the cell
  40. *
  41. * @param value double representing the value
  42. */
  43. public void setValue(double value){
  44. field_4_value = value;
  45. }
  46. /**
  47. * get the value for the cell
  48. *
  49. * @return double representing the value
  50. */
  51. public double getValue(){
  52. return field_4_value;
  53. }
  54. @Override
  55. protected String getRecordName() {
  56. return "NUMBER";
  57. }
  58. @Override
  59. protected void appendValueText(StringBuilder sb) {
  60. sb.append(" .value= ").append(NumberToTextConverter.toText(field_4_value));
  61. }
  62. @Override
  63. protected void serializeValue(LittleEndianOutput out) {
  64. out.writeDouble(getValue());
  65. }
  66. @Override
  67. protected int getValueDataSize() {
  68. return 8;
  69. }
  70. public short getSid() {
  71. return sid;
  72. }
  73. public Object clone() {
  74. NumberRecord rec = new NumberRecord();
  75. copyBaseFields(rec);
  76. rec.field_4_value = field_4_value;
  77. return rec;
  78. }
  79. }