All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.ttzero.excel.entity.style.PaletteParser 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.style;

import org.ttzero.excel.entity.e3.Block;
import org.ttzero.excel.entity.e3.ParserIdentifier;

import java.awt.Color;


/**
 * 5.74 PALETTE
 * 

* This record contains the definition of all user-defined * colours available for cell and object formatting. This * record is optional. If it is omitted, a built-in * default colour table will be used (see ➜5.74.3). * * @author guanquan.wang at 2019-03-02 10:13 */ public class PaletteParser { public static Color[] get(Block block) { block.ready(); // Number of following colours (nm). Contains 16 in BIFF3-BIFF4 and 56 in BIFF5-BIFF8. short nm = block.nextShort(); if (nm == 0) { return new Color[0]; } // List of nm RGB colours (➜2.5.4) Color[] colors = new Color[nm]; for (int i = 0; i < nm; i++) { colors[i] = new Color(block.nextInt()); } block.commit(); return colors; } public static short getId() { return ParserIdentifier.PALETTE; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy