poi/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java

435 lines
13 KiB
Java
Raw Normal View History

/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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.apache.poi.ss.usermodel;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-657701,657703-657874,657876-658032,658034-658284,658286,658288-658301,658303-658307,658309-658321,658323-658335,658337-658348,658351,658353-658832,658834-658983,658985,658987-659066,659068-659402,659404-659428,659430-659451,659453-659454,659456-659461,659463-659477,659479-659525 via svnmerge from https://svn.apache.org:443/repos/asf/poi/trunk ........ r659525 | nick | 2008-05-23 13:58:56 +0100 (Fri, 23 May 2008) | 1 line Extend the support for specifying a policy to HSSF on missing / blank cells when fetching, to be able to specify the policy at the HSSFWorkbook level ........ Also, port this to XSSF git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@659533 13f79535-47bb-0310-9956-ffa450edef68
2008-05-23 09:12:43 -04:00
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
public interface Workbook {
/**
* used for compile-time performance/memory optimization. This determines the
* initial capacity for the sheet collection. Its currently set to 3.
* Changing it in this release will decrease performance
* since you're never allowed to have more or less than three sheets!
*/
public final static int INITIAL_CAPACITY = 3;
/** Extended windows meta file */
public static final int PICTURE_TYPE_EMF = 2;
/** Windows Meta File */
public static final int PICTURE_TYPE_WMF = 3;
/** Mac PICT format */
public static final int PICTURE_TYPE_PICT = 4;
/** JPEG format */
public static final int PICTURE_TYPE_JPEG = 5;
/** PNG format */
public static final int PICTURE_TYPE_PNG = 6;
/** Device independant bitmap */
public static final int PICTURE_TYPE_DIB = 7;
/**
* sets the order of appearance for a given sheet.
*
* @param sheetname the name of the sheet to reorder
* @param pos the position that we want to insert the sheet into (0 based)
*/
void setSheetOrder(String sheetname, int pos);
/**
* sets the tab whose data is actually seen when the sheet is opened.
* This may be different from the "selected sheet" since excel seems to
* allow you to show the data of one sheet when another is seen "selected"
* in the tabs (at the bottom).
* @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
* @param index
*/
void setSelectedTab(short index);
/**
* gets the tab whose data is actually seen when the sheet is opened.
* This may be different from the "selected sheet" since excel seems to
* allow you to show the data of one sheet when another is seen "selected"
* in the tabs (at the bottom).
* @see org.apache.poi.hssf.usermodel.HSSFSheet#setSelected(boolean)
*/
short getSelectedTab();
/**
* sets the first tab that is displayed in the list of tabs
* in excel.
* @param index
*/
void setDisplayedTab(short index);
/**
* sets the first tab that is displayed in the list of tabs
* in excel.
*/
short getDisplayedTab();
/**
* set the sheet name.
* Will throw IllegalArgumentException if the name is greater than 31 chars
* or contains /\?*[]
* @param sheet number (0 based)
*/
void setSheetName(int sheet, String name);
/**
* get the sheet name
* @param sheet Number
* @return Sheet name
*/
String getSheetName(int sheet);
/** Returns the index of the sheet by his name
* @param name the sheet name
* @return index of the sheet (0 based)
*/
int getSheetIndex(String name);
/** Returns the index of the given sheet
* @param sheet the sheet to look up
* @return index of the sheet (0 based)
*/
int getSheetIndex(Sheet sheet);
/**
* create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
* the high level representation. Use this to create new sheets.
*
* @return HSSFSheet representing the new sheet.
*/
Sheet createSheet();
/**
* create an HSSFSheet from an existing sheet in the HSSFWorkbook.
*
* @return HSSFSheet representing the cloned sheet.
*/
Sheet cloneSheet(int sheetNum);
/**
* create an HSSFSheet for this HSSFWorkbook, adds it to the sheets and returns
* the high level representation. Use this to create new sheets.
*
* @param sheetname sheetname to set for the sheet.
* @return HSSFSheet representing the new sheet.
*/
Sheet createSheet(String sheetname);
/**
* get the number of spreadsheets in the workbook (this will be three after serialization)
* @return number of sheets
*/
int getNumberOfSheets();
/**
* Get the HSSFSheet object at the given index.
* @param index of the sheet number (0-based physical & logical)
* @return HSSFSheet at the provided index
*/
Sheet getSheetAt(int index);
/**
* Get sheet with the given name
* @param name of the sheet
* @return HSSFSheet with the name provided or null if it does not exist
*/
Sheet getSheet(String name);
/**
* removes sheet at the given index
* @param index of the sheet (0-based)
*/
void removeSheetAt(int index);
/**
* determine whether the Excel GUI will backup the workbook when saving.
*
* @param backupValue true to indicate a backup will be performed.
*/
void setBackupFlag(boolean backupValue);
/**
* determine whether the Excel GUI will backup the workbook when saving.
*
* @return the current setting for backups.
*/
boolean getBackupFlag();
/**
* Sets the repeating rows and columns for a sheet (as found in
* File->PageSetup->Sheet). This is function is included in the workbook
* because it creates/modifies name records which are stored at the
* workbook level.
* <p>
* To set just repeating columns:
* <pre>
* workbook.setRepeatingRowsAndColumns(0,0,1,-1-1);
* </pre>
* To set just repeating rows:
* <pre>
* workbook.setRepeatingRowsAndColumns(0,-1,-1,0,4);
* </pre>
* To remove all repeating rows and columns for a sheet.
* <pre>
* workbook.setRepeatingRowsAndColumns(0,-1,-1,-1,-1);
* </pre>
*
* @param sheetIndex 0 based index to sheet.
* @param startColumn 0 based start of repeating columns.
* @param endColumn 0 based end of repeating columns.
* @param startRow 0 based start of repeating rows.
* @param endRow 0 based end of repeating rows.
*/
void setRepeatingRowsAndColumns(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow);
/**
* create a new Font and add it to the workbook's font table
* @return new font object
*/
Font createFont();
/**
* Finds a font that matches the one with the supplied attributes
*/
Font findFont(short boldWeight, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline);
/**
* get the number of fonts in the font table
* @return number of fonts
*/
short getNumberOfFonts();
/**
* get the font at the given index number
* @param idx index number
* @return HSSFFont at the index
*/
Font getFontAt(short idx);
/**
* create a new Cell style and add it to the workbook's style table
* @return the new Cell Style object
*/
CellStyle createCellStyle();
/**
* get the number of styles the workbook contains
* @return count of cell styles
*/
short getNumCellStyles();
/**
* get the cell style object at the given index
* @param idx index within the set of styles
* @return HSSFCellStyle object at the index
*/
CellStyle getCellStyleAt(short idx);
/**
* Method write - write out this workbook to an Outputstream. Constructs
* a new POI POIFSFileSystem, passes in the workbook binary representation and
* writes it out.
*
* @param stream - the java OutputStream you wish to write the XLS to
*
* @exception IOException if anything can't be written.
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem
*/
void write(OutputStream stream) throws IOException;
/** gets the total number of named ranges in the workboko
* @return number of named ranges
*/
int getNumberOfNames();
/** gets the Named range
* @param index position of the named range
* @return named range high level
*/
Name getNameAt(int index);
/** gets the named range name
* @param index the named range index (0 based)
* @return named range name
*/
String getNameName(int index);
/**
* Sets the printarea for the sheet provided
* <p>
* i.e. Reference = $A$1:$B$2
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
* @param reference Valid name Reference for the Print Area
*/
void setPrintArea(int sheetIndex, String reference);
/**
* For the Convenience of Java Programmers maintaining pointers.
* @see #setPrintArea(int, String)
* @param sheetIndex Zero-based sheet index (0 = First Sheet)
* @param startColumn Column to begin printarea
* @param endColumn Column to end the printarea
* @param startRow Row to begin the printarea
* @param endRow Row to end the printarea
*/
void setPrintArea(int sheetIndex, int startColumn, int endColumn, int startRow, int endRow);
/**
* Retrieves the reference for the printarea of the specified sheet, the sheet name is appended to the reference even if it was not specified.
* @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
* @return String Null if no print area has been defined
*/
String getPrintArea(int sheetIndex);
/**
* Delete the printarea for the sheet specified
* @param sheetIndex Zero-based sheet index (0 = First Sheet)
*/
void removePrintArea(int sheetIndex);
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-657701,657703-657874,657876-658032,658034-658284,658286,658288-658301,658303-658307,658309-658321,658323-658335,658337-658348,658351,658353-658832,658834-658983,658985,658987-659066,659068-659402,659404-659428,659430-659451,659453-659454,659456-659461,659463-659477,659479-659525 via svnmerge from https://svn.apache.org:443/repos/asf/poi/trunk ........ r659525 | nick | 2008-05-23 13:58:56 +0100 (Fri, 23 May 2008) | 1 line Extend the support for specifying a policy to HSSF on missing / blank cells when fetching, to be able to specify the policy at the HSSFWorkbook level ........ Also, port this to XSSF git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@659533 13f79535-47bb-0310-9956-ffa450edef68
2008-05-23 09:12:43 -04:00
/**
* Retrieves the current policy on what to do when
* getting missing or blank cells from a row.
* The default is to return blank and null cells.
* {@link MissingCellPolicy}
*/
MissingCellPolicy getMissingCellPolicy();
/**
* Sets the policy on what to do when
* getting missing or blank cells from a row.
* This will then apply to all calls to
* {@link Row.getCell()}. See
* {@link MissingCellPolicy}
*/
void setMissingCellPolicy(MissingCellPolicy missingCellPolicy);
/** creates a new named range and add it to the model
* @return named range high level
*/
Name createName();
/** gets the named range index by his name
* <i>Note:</i>Excel named ranges are case-insensitive and
* this method performs a case-insensitive search.
*
* @param name named range name
* @return named range index
*/
int getNameIndex(String name);
/** remove the named range by his index
* @param index named range index (0 based)
*/
void removeName(int index);
/**
* Returns the instance of HSSFDataFormat for this workbook.
* @return the HSSFDataFormat object
* @see org.apache.poi.hssf.record.FormatRecord
* @see org.apache.poi.hssf.record.Record
*/
DataFormat createDataFormat();
/** remove the named range by his name
* @param name named range name
*/
void removeName(String name);
Palette getCustomPalette();
/** Test only. Do not use */
void insertChartRecord();
/**
* Adds a picture to the workbook.
*
* @param pictureData The bytes of the picture
* @param format The format of the picture. One of <code>PICTURE_TYPE_*</code>
*
* @return the index to this picture (1 based).
*/
int addPicture(byte[] pictureData, int format);
/**
* Gets all pictures from the Workbook.
*
* @return the list of pictures (a list of {@link HSSFPictureData} objects.)
*/
List getAllPictures();
/**
* protect a workbook with a password (not encypted, just sets writeprotect
* flags and the password.
* @param password to set
*/
void writeProtectWorkbook(String password, String username);
/**
* removes the write protect flag
*/
void unwriteProtectWorkbook();
/**
* Gets all embedded OLE2 objects from the Workbook.
*
* @return the list of embedded objects (a list of {@link HSSFObjectData} objects.)
*/
List getAllEmbeddedObjects();
/**
* Returns an object that handles instantiating concrete
* classes of the various instances one needs for
* HSSF and XSSF.
* Works around a major shortcoming in Java, where we
* can't have static methods on interfaces or abstract
* classes.
*/
CreationHelper getCreationHelper();
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-657701,657703-657874,657876-658032,658034-658284,658286,658288-658301,658303-658307,658309-658321,658323-658335,658337-658348,658351,658353-658832,658834-658983,658985,658987-659066,659068-659402,659404-659428,659430-659451,659453-659454,659456-659461,659463-659477,659479-659525 via svnmerge from https://svn.apache.org:443/repos/asf/poi/trunk ........ r659525 | nick | 2008-05-23 13:58:56 +0100 (Fri, 23 May 2008) | 1 line Extend the support for specifying a policy to HSSF on missing / blank cells when fetching, to be able to specify the policy at the HSSFWorkbook level ........ Also, port this to XSSF git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@659533 13f79535-47bb-0310-9956-ffa450edef68
2008-05-23 09:12:43 -04:00
}