org.ttzero.excel.entity.e3.DBCellParser 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.entity.e3;
import org.ttzero.excel.reader.RowBlock;
/**
* 5.29 DBCELL
*
* This record is written once in a Row Block. It
* contains relative offsets to calculate the stream
* position of the first cell record for each row.
*
* The offset list in this record contains as many
* offsets as ROW records are present in the Row Block.
* For details about calculation of cell record positions
* see ➜4.7.
*
* @author guanquan.wang at 2019-03-04 18:43
*/
public class DBCellParser {
public static DBCell get(Block block, RowBlock rb) {
block.skip(2);
DBCell dbCell = rb.dbCell;
// Relative offset to first ROW record in the Row Block (difference between record position
// of this record and the ROW record; positive offset for an earlier stream position)
dbCell.firstRowOffset = block.nextInt();
// Array of nm relative offsets (16-bit values) to calculate stream position of the first cell
// record for the respective row (➜4.7.2). nm is the number of ROW records in this Row Block
for (int i = 0; i < rb.nm; i++) {
dbCell.firstCellOffsets[i] = block.nextShort();
}
return dbCell;
}
public static short getId() {
return ParserIdentifier.DBCELL;
}
}