org.ttzero.excel.reader.RowParser Maven / Gradle / Ivy
/*
* Copyright (c) 2019-2020, [email protected] All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ttzero.excel.reader;
import org.ttzero.excel.entity.e3.Block;
import org.ttzero.excel.entity.e3.Option;
import org.ttzero.excel.entity.e3.ParserIdentifier;
/**
* 5.88 ROW
*
* This record contains the properties of a single row in a sheet.
* Rows and cells in a sheet are divided into blocks of 32 rows.
* For details about Row Blocks see ➜4.7.
*
* @author guanquan.wang on 2019-02-05
*/
public class RowParser {
public static BIFF8Row get(Block block, BIFF8Row row) {
// Size of row record
block.nextShort();
// Index of this row(unsigned 16-bit integer)
row.index = block.nextUnsignedShort();
// Index to column of the first cell which is described by a cell record
row.fc = block.nextShort();
// Index to column of the last cell which is described by a cell record, increased by 1
row.lc = block.nextShort();
Option option = Option.of(block.nextShort());
// Height of the row, in twips = 1/20 of a point
row.height = (short) option.range(0, 14);
// 0 = Row has custom height; 1 = Row has default height
row.hasCustomHeight = option.isOff(15);
// ignore
block.skip(4);
// Option flags and default row formatting
// Bit Mask Contents
// 2-0 00000007 Outline level of the row
// 4 00000010 1 = Outline group starts or ends here (depending on where
// the outline buttons are located, see SHEETPR record,
// ➜5.97), and is collapsed
// 5 00000020 1 = Row is hidden (manually, or by a filter or outline group)
// 6 00000040 1 = Row height and default font height do not match
// 7 00000080 1 = Row has explicit default format (fl)
// 8 00000100 Always 1
// 27-16 0FFF0000 If fl = 1: Index to default XF record (➜5.115)
// 28 10000000 1 = Additional space above the row. This flag is set, if the
// upper border of at least one cell in this row or if the lower
// border of at least one cell in the row above is formatted with
// a thick line style. Thin and medium line styles are not taken
// into account.
// 29 20000000 1 = Additional space below the row. This flag is set, if the
// lower border of at least one cell in this row or if the upper
// border of at least one cell in the row below is formatted with
// a medium or thick line style. Thin line styles are not taken
// into account.
// 30 40000000 1 = Show phonetic text for all cells in this row (BIFF8 only)
row.option = Option.of(block.nextInt());
return row;
}
public static short getId() {
return ParserIdentifier.ROW;
}
}