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.

XSSFBCellHeader.java 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.binary;
  16. import org.apache.poi.ss.util.CellReference;
  17. import org.apache.poi.util.Internal;
  18. import org.apache.poi.util.LittleEndian;
  19. /**
  20. * This class encapsulates what the spec calls a "Cell" object.
  21. * I added "Header" to clarify that this does not contain the contents
  22. * of the cell, only the column number, the style id and the phonetic boolean
  23. */
  24. @Internal
  25. class XSSFBCellHeader {
  26. public static int length = 8;
  27. /**
  28. *
  29. * @param data raw data
  30. * @param offset offset at which to start reading the record
  31. * @param currentRow 0-based current row count
  32. * @param cell cell buffer to update
  33. */
  34. public static void parse(byte[] data, int offset, int currentRow, XSSFBCellHeader cell) {
  35. long colNum = LittleEndian.getUInt(data, offset); offset += LittleEndian.INT_SIZE;
  36. int styleIdx = XSSFBUtils.get24BitInt(data, offset); offset += 3;
  37. //TODO: range checking
  38. boolean showPhonetic = false;//TODO: fill this out
  39. cell.reset(currentRow, (int)colNum, styleIdx, showPhonetic);
  40. }
  41. private int rowNum;
  42. private int colNum;
  43. private int styleIdx;
  44. private boolean showPhonetic;
  45. public void reset(int rowNum, int colNum, int styleIdx, boolean showPhonetic) {
  46. this.rowNum = rowNum;
  47. this.colNum = colNum;
  48. this.styleIdx = styleIdx;
  49. this.showPhonetic = showPhonetic;
  50. }
  51. int getColNum() {
  52. return colNum;
  53. }
  54. String formatAddressAsString() {
  55. return CellReference.convertNumToColString(colNum)+(rowNum+1);
  56. }
  57. int getStyleIdx() {
  58. return styleIdx;
  59. }
  60. }