⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 namerecord.java

📁 Office格式转换代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2003 The Apache Software Foundation.  All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. * * 3. The end-user documentation included with the redistribution, *    if any, must include the following acknowledgment: *       "This product includes software developed by the *        Apache Software Foundation (http://www.apache.org/)." *    Alternately, this acknowledgment may appear in the software itself, *    if and wherever such third-party acknowledgments normally appear. * * 4. The names "Apache" and "Apache Software Foundation" and *    "Apache POI" must not be used to endorse or promote products *    derived from this software without prior written permission. For *    written permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache", *    "Apache POI", nor may "Apache" appear in their name, without *    prior written permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation.  For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */package org.apache.poi.hssf.record;import java.util.List;import java.util.Stack;import org.apache.poi.hssf.model.Workbook;import org.apache.poi.hssf.record.formula.Area3DPtg;import org.apache.poi.hssf.record.formula.Ptg;import org.apache.poi.hssf.record.formula.Ref3DPtg;import org.apache.poi.hssf.util.RangeAddress;import org.apache.poi.util.HexDump;import org.apache.poi.util.LittleEndian;import org.apache.poi.util.StringUtil;/** * Title:        Name Record (aka Named Range) <P> * Description:  Defines a named range within a workbook. <P> * REFERENCE:  <P> * @author Libin Roman (Vista Portal LDT. Developer) * @author  Sergei Kozello (sergeikozello at mail.ru) * @author Glen Stampoultzis (glens at apache.org) * @version 1.0-pre */public class NameRecord extends Record {    /**     */    public final static short sid = 0x18; //Docs says that it is 0x218    	/**Included for completeness sake, not implemented	   */	public final static byte  BUILTIN_CONSOLIDATE_AREA      = (byte)1;		/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_AUTO_OPEN             = (byte)2;	/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_AUTO_CLOSE            = (byte)3;	/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_DATABASE              = (byte)4;	/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_CRITERIA              = (byte)5;		public final static byte  BUILTIN_PRINT_AREA            = (byte)6;	public final static byte  BUILTIN_PRINT_TITLE           = (byte)7;		/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_RECORDER              = (byte)8;		/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_DATA_FORM             = (byte)9;		/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_AUTO_ACTIVATE         = (byte)10;		/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_AUTO_DEACTIVATE       = (byte)11;		/**Included for completeness sake, not implemented	 */	public final static byte  BUILTIN_SHEET_TITLE           = (byte)12;        public static final short OPT_HIDDEN_NAME =   (short) 0x0001;    public static final short OPT_FUNCTION_NAME = (short) 0x0002;    public static final short OPT_COMMAND_NAME =  (short) 0x0004;    public static final short OPT_MACRO =         (short) 0x0008;    public static final short OPT_COMPLEX =       (short) 0x0010;    public static final short OPT_BUILTIN =       (short) 0x0020;    public static final short OPT_BINDATA =       (short) 0x1000;        private short             field_1_option_flag;    private byte              field_2_keyboard_shortcut;    private byte              field_3_length_name_text;    private short             field_4_length_name_definition;    private short             field_5_index_to_sheet;     // unused: see field_6    private short             field_6_equals_to_index_to_sheet;    private byte              field_7_length_custom_menu;    private byte              field_8_length_description_text;    private byte              field_9_length_help_topic_text;    private byte              field_10_length_status_bar_text;    private byte              field_11_compressed_unicode_flag;   // not documented    private byte              field_12_builtIn_name;    private String            field_12_name_text;    private Stack             field_13_name_definition;    private byte[]            field_13_raw_name_definition;       // raw data    private String            field_14_custom_menu_text;    private String            field_15_description_text;    private String            field_16_help_topic_text;    private String            field_17_status_bar_text;    /** Creates new NameRecord */    public NameRecord() {        field_13_name_definition = new Stack();        field_12_name_text = new String();        field_14_custom_menu_text = new String();        field_15_description_text = new String();        field_16_help_topic_text = new String();        field_17_status_bar_text = new String();    }    /**     * Constructs a Name record and sets its fields appropriately.     *     * @param id     id must be 0x18 or an exception will be throw upon validation     * @param size  the size of the data area of the record     * @param data  data of the record (should not contain sid/len)     */    public NameRecord(short id, short size, byte [] data) {        super(id, size, data);    }    /**     * Constructs a Name record and sets its fields appropriately.     *     * @param id     id must be 0x18 or an exception will be throw upon validation     * @param size  the size of the data area of the record     * @param data  data of the record (should not contain sid/len)     * @param offset of the record's data     */    public NameRecord(short id, short size, byte [] data, int offset) {        super(id, size, data, offset);    }	/**	 * Constructor to create a built-in named region	 * @param builtin Built-in byte representation for the name record, use the public constants	 * @param index 	 */	public NameRecord(byte builtin, short index)	{	    this();	    	    this.field_12_builtIn_name = builtin;	    this.setOptionFlag((short)(this.getOptionFlag() | OPT_BUILTIN));	    this.setNameTextLength((byte)1);	    this.setEqualsToIndexToSheet(index); //the extern sheets are set through references	    	    //clearing these because they are not used with builtin records		this.setCustomMenuLength((byte)0);		this.setDescriptionTextLength((byte)0);		this.setHelpTopicLength((byte)0);		this.setStatusBarLength((byte)0);	    	}    /** sets the option flag for the named range     * @param flag option flag     */    public void setOptionFlag(short flag){        field_1_option_flag = flag;    }    /** sets the keyboard shortcut     * @param shortcut keyboard shortcut     */    public void setKeyboardShortcut(byte shortcut){        field_2_keyboard_shortcut = shortcut;    }    /** sets the name of the named range length     * @param length name length     */    public void setNameTextLength(byte length){        field_3_length_name_text = length;    }    /** sets the definition (reference - formula) length     * @param length defenition length     */    public void setDefinitionTextLength(short length){        field_4_length_name_definition = length;    }    /** sets the index number to the extern sheet (thats is what writen in documentation     *  but as i saw , it works differently)     * @param index extern sheet index     */    public void setUnused(short index){        field_5_index_to_sheet = index;        // field_6_equals_to_index_to_sheet is equal to field_5_index_to_sheet//        field_6_equals_to_index_to_sheet = index;    }    public short getEqualsToIndexToSheet()    {        return field_6_equals_to_index_to_sheet;    }	/**	 * Convenience method to retrieve the index the name refers to.	 * @see #getEqualsToIndexToSheet()	 * @return short	 */	public short getIndexToSheet() {		return getEqualsToIndexToSheet();	}    /**     * @return function group     * @see FnGroupCountRecord     */    public byte getFnGroup() {        int masked = field_1_option_flag & 0x0fc0;        return (byte) (masked >> 4);    }    public void setEqualsToIndexToSheet(short value)    {        field_6_equals_to_index_to_sheet = value;    }    /** sets the custom menu length     * @param length custom menu length     */    public void setCustomMenuLength(byte length){        field_7_length_custom_menu = length;    }    /** sets the length of named range description     * @param length description length     */    public void setDescriptionTextLength(byte length){        field_8_length_description_text = length;    }    /** sets the help topic length     * @param length help topic length     */    public void setHelpTopicLength(byte length){        field_9_length_help_topic_text = length;    }    /** sets the length of the status bar text     * @param length status bar text length     */    public void setStatusBarLength(byte length){        field_10_length_status_bar_text = length;    }    /** sets the compressed unicode flag     * @param flag unicode flag     */    public void setCompressedUnicodeFlag(byte flag) {        field_11_compressed_unicode_flag = flag;    }    /** sets the name of the named range     * @param name named range name     */    public void setNameText(String name){        field_12_name_text = name;    }    //    public void setNameDefintion(String definition){    //        test = definition;    //    }    /** sets the custom menu text     * @param text custom menu text     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -