org.ttzero.excel.entity.e3.BoolErrParser 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.entity.e3.enums.ErrorCodeEnum;
import org.ttzero.excel.reader.AllInOneCell;
/**
* 5.10 BOOLERR
*
* This record represents a Boolean value or error value cell.
*
* @author guanquan.wang at 2019-04-18 22:36
*/
public class BoolErrParser {
public static void get(Block block, AllInOneCell cell) {
block.skip(2);
// Index to row
cell.row = block.nextUnsignedShort();
// Index to column
cell.column = block.nextShort();
// Index to XF record (➜5.115)
cell.xf = block.nextShort();
// Boolean or error value (type depends on the following byte)
byte v = block.nextByte();
// 0 = Boolean value; 1 = Error code
byte t = block.nextByte();
// If the value field is a Boolean value, it will contain 0 for FALSE and 1 for TRUE
if (t == 0x0) {
cell.bValue = v == 0x1;
} else {
cell.error = ErrorCodeEnum.of(v);
}
}
public static short getId() {
return ParserIdentifier.BOOLERR;
}
}