Inspired by bug #44958 - Record level support for Data Tables. (No formula parser...
[poi.git] / src / java / org / apache / poi / hssf / record / formula / TblPtg.java
blobf055b5d29bb4f9d87d76c63a3a76da07bbd509b1
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
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 ==================================================================== */
18 package org.apache.poi.hssf.record.formula;
20 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
21 import org.apache.poi.hssf.record.RecordFormatException;
22 import org.apache.poi.hssf.record.RecordInputStream;
24 import org.apache.poi.util.LittleEndian;
26 /**
27 * This ptg indicates a data table.
28 * It only occurs in a FORMULA record, never in an
29 * ARRAY or NAME record. When ptgTbl occurs in a
30 * formula, it is the only token in the formula.
31 * (TODO - check this when processing)
32 * This indicates that the cell containing the
33 * formula is an interior cell in a data table;
34 * the table description is found in a TABLE
35 * record. Rows and columns which contain input
36 * values to be substituted in the table do
37 * not contain ptgTbl.
38 * See page 811 of the june 08 binary docs.
40 public final class TblPtg extends ControlPtg {
41 private final static int SIZE = 4;
42 public final static short sid = 0x2;
43 /** The row number of the upper left corner */
44 private final short field_1_first_row;
45 /** The column number of the upper left corner */
46 private final short field_2_first_col;
48 public TblPtg(RecordInputStream in)
50 field_1_first_row = in.readShort();
51 field_2_first_col = in.readUByte();
54 public void writeBytes(byte [] array, int offset)
56 array[offset+0]= (byte) (sid);
57 LittleEndian.putShort(array,offset+1,field_1_first_row);
58 LittleEndian.putByte(array,offset+3,field_2_first_col);
61 public int getSize()
63 return SIZE;
66 public short getRow() {
67 return field_1_first_row;
70 public short getColumn() {
71 return field_2_first_col;
74 public String toFormulaString(HSSFWorkbook book)
76 // table(....)[][]
77 throw new RecordFormatException("Table and Arrays are not yet supported");
80 public String toString()
82 StringBuffer buffer = new StringBuffer("[Data Table - Parent cell is an interior cell in a data table]\n");
83 buffer.append("top left row = ").append(getRow()).append("\n");
84 buffer.append("top left col = ").append(getColumn()).append("\n");
85 return buffer.toString();