org.ttzero.excel.entity.e3.SheetParser 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;
/**
* 5.95 SHEET
*
* This record is located in the Workbook Globals Sub-stream and
* represents a sheet inside the workbook. One SHEET
* record is written for each sheet. It stores the sheet name
* and a stream offset to the BOF record (➜5.8)
* of the respective Sheet Sub-stream within the Workbook Stream
*
* @author guanquan.wang at 2019-01-29 11:16
*/
public class SheetParser {
/**
* Parse sheet record
*
* @param block the block data
* @return the sheet record
*/
public static SheetInfo get(Block block) {
block.ready();
SheetInfo sheet = new SheetInfo();
// Offset 0 Size 4 Absolute stream position of the BOF record of the sheet represented
// by this record. This field is never encrypted in protected files.
sheet.position = block.nextInt();
// Offset 4 Size 1 Sheet state
// 0 = Visible
// 1 = Hidden
// 2 = “Very hidden”. Can only be set programmatically, e.g. with a
// Visual Basic macro. It is not possible to make such a sheet visible via the user interface.
sheet.status = block.nextByte();
// Offset 5 Size 1 Sheet type
// 00H = Worksheet
// 02H = Chart
// 06H = Visual Basic module
sheet.type = block.nextByte();
// Offset 6 Size var.
// Sheet name
sheet.name = StringParser.get8Bit(block);
block.commit();
return sheet;
}
public static short getId() {
return ParserIdentifier.SHEET;
}
}