### Guide() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/sl/draw/geom/Guide.html Constructor for the Guide class. Creates a new instance of a geometry guide. ```APIDOC ## Guide() ### Description Constructs a new Guide object representing a geometry guide. ### Method Constructor ### Signature `public Guide()` ### Parameters None ### Returns A new Guide instance. ``` -------------------------------- ### PrintSetupRecord Methods Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/record/PrintSetupRecord.html Methods to get and set print setup properties. ```APIDOC ## PrintSetupRecord Methods ### Description Provides getter and setter methods for various print setup options. ### Methods #### Getter Methods - `short getCopies()` - Returns the number of copies. - `boolean getDraft()` - Returns whether draft mode is enabled. - `short getFitHeight()` - Returns the fit height. - `short getFitWidth()` - Returns the fit width. - `double getFooterMargin()` - Returns the footer margin. - `double getHeaderMargin()` - Returns the header margin. - `short getHResolution()` - Returns the horizontal resolution. - `boolean getLandscape()` - Returns whether landscape orientation is set. - `boolean getLeftToRight()` - Returns whether left-to-right printing is set. - `boolean getNoColor()` - Returns whether color is disabled. - `boolean getNoOrientation()` - Returns whether orientation is not set. - `boolean getNotes()` - Returns whether notes are printed. - `short getOptions()` - Returns the options field. - `short getPageStart()` - Returns the starting page number. - `short getPaperSize()` - Returns the paper size. - `short getScale()` - Returns the scale percentage. - `short getSid()` - Returns the record id. - `boolean getUsePage()` - Returns whether page setup is used. - `boolean getValidSettings()` - Returns whether settings are valid. - `short getVResolution()` - Returns the vertical resolution. #### Setter Methods - `void setCopies(short copies)` - Sets the number of copies. - `void setDraft(boolean d)` - Sets draft mode. - `void setFitHeight(short height)` - Sets the fit height. - `void setFitWidth(short width)` - Sets the fit width. - `void setFooterMargin(double footermargin)` - Sets the footer margin. - `void setHeaderMargin(double headermargin)` - Sets the header margin. - `void setHResolution(short resolution)` - Sets the horizontal resolution. - `void setLandscape(boolean ls)` - Sets landscape orientation. - `void setLeftToRight(boolean ltor)` - Sets left-to-right printing. - `void setNoColor(boolean mono)` - Sets whether color is disabled. - `void setNoOrientation(boolean orientation)` - Sets whether orientation is not set. - `void setNotes(boolean printnotes)` - Sets whether notes are printed. - `void setOptions(short options)` - Sets the options field. - `void setPageStart(short start)` - Sets the starting page number. - `void setPaperSize(short size)` - Sets the paper size. - `void setScale(short scale)` - Sets the scale percentage. - `void setUsePage(boolean page)` - Sets whether page setup is used. - `void setValidSettings(boolean valid)` - Sets whether settings are valid. - `void setVResolution(short resolution)` - Sets the vertical resolution. ### Usage Example ```java PrintSetupRecord record = new PrintSetupRecord(); record.setPaperSize((short) 1); record.setScale((short) 100); ``` ``` -------------------------------- ### Expected build output for ExcelAnt example Source: https://poi.apache.org/components/spreadsheet/excelant.html Expected output when running the example build. Shows the ExcelAnt version, input file, test result, and build success. ```text Buildfile: C:\opt\eclipse\workspaces\excelant\excelant.examples\build.xml simpleTest: [excelant] ExcelAnt version 0.4.0 Copyright 2011 [excelant] Using input file: resources/excelant.xls [excelant] 1/1 tests passed. BUILD SUCCESSFUL Total time: 406 milliseconds ``` -------------------------------- ### getStartBlock() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/poifs/property/PropertyTable.html Get the start block for the property table. ```APIDOC ## getStartBlock() ### Description Get the start block for the property table. ### Method getStartBlock ### Parameters None ### Returns - **int** - Start block index. ### Example ```java PropertyTable propertyTable = ...; int startBlock = propertyTable.getStartBlock(); ``` ``` -------------------------------- ### getTable(Paragraph paragraph) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwpf/usermodel/Range.html Gets the table that starts with the given paragraph. ```APIDOC ## getTable(Paragraph paragraph) ### Description Gets the table that starts with paragraph. In a Word file, a table consists of a group of paragraphs with certain flags set. ### Method getTable ### Parameters - **paragraph** (Paragraph) - Required - The paragraph that is the first paragraph in the table. ### Returns The table that starts with paragraph ``` -------------------------------- ### main(String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwpf/dev/HWPFLister.html Static entry point for command-line usage of HWPFLister. Throws java.lang.Exception. ```APIDOC ## Method: main(String[] args) ### Description Static method that serves as the command-line entry point for the HWPFLister utility. ### Signature `public static void main(java.lang.String[] args) throws java.lang.Exception` ### Parameters - **args** (String[]) - Required - Command-line arguments. ### Throws - `java.lang.Exception` - If an error occurs during execution. ### Example ```java HWPFLister.main(new String[] {"document.doc"}); ``` ``` -------------------------------- ### void startElement(String uri, String localName, String name, Attributes attributes) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/eventusermodel/ReadOnlySharedStringsTable.html SAX callback for the start of an element. ```APIDOC ## Method: void startElement(java.lang.String uri, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes attributes) ### Description SAX callback invoked when the start of an element is reached. ### Parameters - **uri** (java.lang.String) - Required - The namespace URI. - **localName** (java.lang.String) - Required - The local name. - **name** (java.lang.String) - Required - The qualified name. - **attributes** (org.xml.sax.Attributes) - Required - The attributes of the element. ``` -------------------------------- ### getPropertyTag(ClassID guid, String name, long id) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hsmf/datatypes/NameIdChunks.html Get property tag id by property set GUID and string name or numerical name from named properties mapping. ```APIDOC ## getPropertyTag(ClassID guid, String name, long id) ### Description Get property tag id by property set GUID and string name or numerical name from named properties mapping. ### Method `public long getPropertyTag(ClassID guid, String name, long id)` ### Parameters - **guid** (ClassID) - Required - Property set GUID in registry format without brackets. May be one of the PS_* or PSETID_* constants. - **name** (String) - Required - Property name in case of string named property. - **id** (long) - Required - Property id in case of numerical named property. ### Returns - **long** - Property tag which can be matched with `MAPIProperty.id` or 0 if the property could not be found. ``` -------------------------------- ### main(String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/dev/SlideShowDumper.html Static entry point that takes a ppt file as a parameter and outputs a dump of its contents. ```APIDOC ## Method: main ### Description Right now this function takes one parameter: a ppt file, and outputs a dump of what it contains. ### Signature ```java public static void main(java.lang.String[] args) throws java.io.IOException ``` ### Parameters - **args** (String[]) - Required - Command-line arguments; expects a ppt file path. ### Throws - **java.io.IOException** ``` -------------------------------- ### getDelayTime() / setDelayTime(int) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/record/AnimationInfoAtom.html Gets and sets the delay time in milliseconds before the animation starts to play. ```APIDOC ### Method Detail #### getDelayTime() ```java public int getDelayTime() ``` A signed integer that specifies the delay time, in milliseconds, before the animation starts to play. If `Automatic` is 0x1, this value MUST be greater than or equal to 0; otherwise, this field MUST be ignored. #### setDelayTime(int id) ```java public void setDelayTime(int id) ``` A signed integer that specifies the delay time, in milliseconds, before the animation starts to play. If `Automatic` is 0x1, this value MUST be greater than or equal to 0; otherwise, this field MUST be ignored. ``` -------------------------------- ### isDate1904() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFWorkbook.html Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904. ```APIDOC ## isDate1904() ### Description Gets a boolean value that indicates whether the date systems used in the workbook starts in 1904. The default value is false, meaning that the workbook uses the 1900 date system, where 1/1/1900 is the first day in the system. ### Method isDate1904() ### Returns - **boolean** - true if the date systems used in the workbook starts in 1904 ``` -------------------------------- ### main(String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/dev/FormulaViewer.html Command-line entry point. Pass a filename to parse formulas from it, or --help for usage. ```APIDOC ## main(String[] args) ### Description Command-line entry point. Pass a filename to parse formulas from it, or --help for usage. ### Method `public static void main(java.lang.String[] args) throws java.io.IOException` ### Parameters - **args** (String[]) - Required - Pass one argument with the filename or --help. ### Throws - `java.io.IOException` - if the file can't be read or contained errors ``` -------------------------------- ### setupMaster(XDGFSection section) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xdgf/usermodel/section/CharacterSection.html Sets up this section from a master section. This method is specified by the XDGFSection class. ```APIDOC ## setupMaster(XDGFSection section) ### Description Configures this character section based on a master section. ### Method `public void setupMaster(XDGFSection section)` ### Parameters - **section** (XDGFSection) - Required - The master section to copy settings from. ### Specified By - `setupMaster` in class `XDGFSection` ``` -------------------------------- ### Iterate over HwmfBitmapDib.Compression constants with values() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwmf/record/HwmfBitmapDib.Compression.html Use values() to get an array of all enum constants in declaration order. The example shows a for-each loop that prints each constant. ```java for (HwmfBitmapDib.Compression c : HwmfBitmapDib.Compression.values()) System.out.println(c); ``` -------------------------------- ### getDataRowCount Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFTable.html Get the number of data rows in this table. This does not include any header rows or totals rows. Returns 0 if the start or end cell references are not set. Does not track updates to underlying changes to CTTable. To synchronize with changes to the underlying CTTable, call updateReferences(). ```APIDOC ## getDataRowCount ### Description Get the number of data rows in this table. This does not include any header rows or totals rows. Returns 0 if the start or end cell references are not set. Does not track updates to underlying changes to CTTable. To synchronize with changes to the underlying CTTable, call updateReferences(). ### Method getDataRowCount ### Signature public int getDataRowCount() ### Returns - int - the number of data rows ### Since 4.0.0 ``` -------------------------------- ### main(String[]) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xdgf/util/VsdxToPng.html Command-line entry point for converting Visio diagrams to PNG. The exact arguments are not documented in the source. ```APIDOC ## main(String[] args) ### Description Command-line entry point for converting Visio diagrams to PNG. The exact arguments are not documented in the source. ### Method static void ### Signature `public static void main(String[] args) throws java.lang.Exception` ### Parameters - **args** (String[]) - Required - Command-line arguments. ### Throws - **java.lang.Exception** - If an error occurs during execution. ### Example ```java VsdxToPng.main(new String[]{"input.vsdx", "output"}); ``` ``` -------------------------------- ### main(java.lang.String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/ooxml/dev/OOXMLLister.html Main entry point for the OOXMLLister command-line tool. ```APIDOC ## main(java.lang.String[] args) ### Description Main entry point for the OOXMLLister command-line tool. ### Method public static void main(java.lang.String[] args) throws java.io.IOException, InvalidFormatException ### Parameters - **args** (java.lang.String[]) - Required - Command-line arguments. ### Throws - **java.io.IOException** - If an I/O error occurs. - **InvalidFormatException** - If the package format is invalid. ``` -------------------------------- ### getRowCount Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFTable.html Get the total number of rows in this table, including all header rows and all totals rows. (Note: in this version autofiltering is ignored) Returns 0 if the start or end cell references are not set. Does not track updates to underlying changes to CTTable. To synchronize with changes to the underlying CTTable, call updateReferences(). ```APIDOC ## getRowCount ### Description Get the total number of rows in this table, including all header rows and all totals rows. (Note: in this version autofiltering is ignored) Returns 0 if the start or end cell references are not set. Does not track updates to underlying changes to CTTable. To synchronize with changes to the underlying CTTable, call updateReferences(). ### Method getRowCount ### Signature public int getRowCount() ### Returns - int - the total number of rows ``` -------------------------------- ### getGuide Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.html Returns the guide at the specified index. ```APIDOC ## getGuide ### Description Returns the guide at the specified index. ### Method `public XDDFGeometryGuide getGuide(int index)` ### Parameters - **index** (int) - Required - The index of the guide to retrieve. ### Returns - **XDDFGeometryGuide** - The guide at the specified index. ``` -------------------------------- ### setPageStart(short start) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/usermodel/HSSFPrintSetup.html Sets the page numbering start. ```APIDOC ## setPageStart(short start) ### Description Set the page numbering start. ### Method setPageStart ### Signature `public void setPageStart(short start)` ### Parameters - **start** (short) - Required - the page numbering start ### Specified By - `setPageStart` in interface `PrintSetup` ``` -------------------------------- ### main(String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/poifs/dev/POIFSLister.html Display the entries of multiple POIFS files. This is the entry point for command-line usage. ```APIDOC ## main(String[] args) ### Description Display the entries of multiple POIFS files. This is the entry point for command-line usage. ### Method main ### Signature `public static void main(java.lang.String[] args) throws java.io.IOException` ### Parameters - **args** (String[]) - Required - The names of the files to be displayed. ### Throws - **java.io.IOException** - If an I/O error occurs. ``` -------------------------------- ### POIFSDocumentPath constructor examples Source: https://poi.apache.org/components/poifs/how-to.html Shows the constructors for POIFSDocumentPath and the directories they describe. The root directory can be described by no-arg, null, or empty array constructors; other constructors describe nested paths. ```java new POIFSDocumentPath() ``` ```java new POIFSDocumentPath(null) ``` ```java new POIFSDocumentPath(new String[ 0 ]) ``` ```java new POIFSDocumentPath(new String[ ] { "foo", "bar"} ) ``` ```java new POIFSDocumentPath(new POIFSDocumentPath(new String[] { "foo" }), new String[ ] { "fu", "bar"} ) ``` -------------------------------- ### Define ParagraphAlignment constant START Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xwpf/usermodel/ParagraphAlignment.html Constant for the START alignment option. ```java public static final ParagraphAlignment START ``` -------------------------------- ### cellIterator Usage Example Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFRow.html Example of iterating over cells using cellIterator(). ```java for (Iterator it = row.cellIterator(); it.hasNext(); ) { Cell cell = it.next(); ... } ``` -------------------------------- ### HSSFPrintSetup Constructor Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/usermodel/HSSFPrintSetup.html Constructor that takes the low level print setup record. ```APIDOC ## HSSFPrintSetup Constructor ### Description Constructor. Takes the low level print setup record. ### Method Constructor ### Signature `protected HSSFPrintSetup(PrintSetupRecord printSetupRecord)` ### Parameters - **printSetupRecord** (PrintSetupRecord) - Required - the low level print setup record ``` -------------------------------- ### iterator Usage Example Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/XSSFRow.html Example of iterating over cells using foreach loop. ```java for(Cell cell : row){ ... } ``` -------------------------------- ### getStart() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwmf/record/HwmfFill.WmfFloodFill.html Returns the starting point for the flood fill. ```APIDOC ## getStart() ### Description Returns the starting point for the flood fill. ### Method `public java.awt.geom.Point2D getStart()` ### Returns - **java.awt.geom.Point2D** - The starting point. ``` -------------------------------- ### setSpaceAfter usage examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/usermodel/HSLFTextParagraph.html Examples of setting space after with percentage and point values. ```java // The paragraph will be formatted to have a spacing after the paragraph text. // The spacing will be 200% of the size of the largest text on each line paragraph.setSpaceAfter(200); // The spacing will be a size of 48 points paragraph.setSpaceAfter(-48.0); ``` -------------------------------- ### addGuide Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.html Adds a new geometry guide and returns it. ```APIDOC ## XDDFCustomGeometry2D.addGuide() ### Description Adds a new geometry guide to the custom geometry. ### Method ADD ### Endpoint `addGuide()` ### Response #### Success Response - **XDDFGeometryGuide** - The newly added geometry guide. ``` -------------------------------- ### setSpaceBefore usage examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/usermodel/HSLFTextParagraph.html Examples of setting space before with percentage and point values. ```java // The paragraph will be formatted to have a spacing before the paragraph text. // The spacing will be 200% of the size of the largest text on each line paragraph.setSpaceBefore(200); // The spacing will be a size of 48 points paragraph.setSpaceBefore(-48.0); ``` -------------------------------- ### initialize(EncryptionInfo, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/poifs/crypt/EncryptionInfoBuilder.html Initializes the builder from scratch using the specified encryption algorithm parameters. ```APIDOC ## initialize(EncryptionInfo, CipherAlgorithm, HashAlgorithm, int, int, ChainingMode) ### Description Initializes the builder from scratch using the specified encryption algorithm parameters. ### Method initialize ### Signature ```java void initialize(EncryptionInfo ei, CipherAlgorithm cipherAlgorithm, HashAlgorithm hashAlgorithm, int keyBits, int blockSize, ChainingMode chainingMode) ``` ### Parameters - **ei** (EncryptionInfo) - Required - The EncryptionInfo object to initialize. - **cipherAlgorithm** (CipherAlgorithm) - Required - The cipher algorithm to use. - **hashAlgorithm** (HashAlgorithm) - Required - The hash algorithm to use. - **keyBits** (int) - Required - The key size in bits. - **blockSize** (int) - Required - The block size in bytes. - **chainingMode** (ChainingMode) - Required - The chaining mode for the cipher. ``` -------------------------------- ### setLineSpacing usage examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/usermodel/HSLFTextParagraph.html Examples of setting line spacing with percentage and point values. ```java // spacing will be 120% of the size of the largest text on each line paragraph.setLineSpacing(120); // spacing will be 200% of the size of the largest text on each line paragraph.setLineSpacing(200); // spacing will be 48 points paragraph.setLineSpacing(-48.0); ``` -------------------------------- ### Create a new empty POIFSFileSystem Source: https://poi.apache.org/components/poifs/how-to.html Initializes a new, empty POIFSFileSystem instance for writing a file system from scratch. ```java POIFSFileSystem fs = new POIFSFileSystem(); ``` -------------------------------- ### Repeating columns range examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/streaming/SXSSFSheet.html Examples of valid repeating columns ranges in Excel notation. ```text Sheet1!$A:$A Sheet2!$C:$F ``` -------------------------------- ### Sample GPG verification of poi-bin-3.5-FINAL-20090928.tgz Source: https://poi.apache.org/download.html Example session showing how to import the KEYS file and verify a POI binary archive using GPG. The output demonstrates a successful signature verification and fingerprint display for the signing key. ```bash % gpg --import KEYS gpg: key 12DAE9BE: "Glen Stampoultzis " not changed gpg: key 4CEED75F: "Nick Burch " not changed gpg: key 84B5A42E: "Rainer Klute " not changed gpg: key F5BB52CD: "Yegor Kozlov " not changed gpg: Total number processed: 4 gpg: unchanged: 4 % gpg --verify poi-bin-3.5-FINAL-20090928.tgz.asc poi-bin-3.5-FINAL-20090928.tgz gpg: Signature made Mon Sep 28 10:28:25 2009 PDT using DSA key ID F5BB52CD gpg: Good signature from "Yegor Kozlov " gpg: aka "Yegor Kozlov " gpg: aka "Yegor Kozlov " Primary key fingerprint: 7D77 0C77 6CE7 754E E6AF 23AA 6934 0A02 F5BB 52CD % gpg --fingerprint F5BB52CD pub 1024D/F5BB52CD 2007-06-18 [expires: 2012-06-16] Key fingerprint = 7D77 0C77 6CE7 754E E6AF 23AA 6934 0A02 F5BB 52CD uid Yegor Kozlov uid Yegor Kozlov uid Yegor Kozlov sub 4096g/7B45A98A 2007-06-18 [expires: 2012-06-16] ``` -------------------------------- ### Repeating rows range examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/streaming/SXSSFSheet.html Examples of valid repeating rows ranges in Excel notation. ```text Sheet1!$1:$1 Sheet2!$5:$8 ``` -------------------------------- ### get(Object key) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hpsf/CustomProperties.html Gets a named value from the custom properties. Only works for keys of type String. ```APIDOC ## get(Object key) ### Description Gets a named value from the custom properties - only works for keys of type String. ### Method get ### Signature public java.lang.Object get(java.lang.Object key) ### Parameters - **key** (Object) - Required - The name of the value to get. ### Returns The value or `null` if a value with the specified name is not found in the custom properties. ### Specified By `get` in interface `java.util.Map` ``` -------------------------------- ### main(String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/poifs/dev/POIFSDump.html Command-line entry point to dump the internal structure of a POIFS file. ```APIDOC ## main(String[] args) ### Description Dumps the internal structure of a POIFS file. The method is a command-line entry point that accepts arguments and throws java.io.IOException. ### Method main ### Signature `public static void main(java.lang.String[] args) throws java.io.IOException` ### Parameters - `args` (String[]) - Required - Command line arguments. ### Throws - `java.io.IOException` ``` -------------------------------- ### create() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/sl/usermodel/SlideShowProvider.html Creates a new SlideShow instance with default settings. ```APIDOC ## create() ### Description Creates a new SlideShow instance with default settings. ### Method create ### Signature `SlideShow create()` ### Returns - **SlideShow** - A new SlideShow instance. ``` -------------------------------- ### get(Object key) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hpsf/CustomProperties.html Gets a named value from the custom properties - only works for keys of type String. ```APIDOC ## get(Object key) ### Description Gets a named value from the custom properties - only works for keys of type String. ### Method `public Object get(Object key)` ### Parameters - **key** (Object) - The key whose associated value is to be returned. Must be a String. ### Returns - **Object** - The value to which the specified key is mapped, or null if this map contains no mapping for the key. ``` -------------------------------- ### Read XLSX sheets with XSSFReader and SAX (ExampleEventUserModel) Source: https://poi.apache.org/components/spreadsheet/how-to.html Complete Java example for reading a single sheet (by rId) or all sheets from an .xlsx file using the XSSF event API. It constructs an XSSFReader, gets the shared strings table, and parses sheet XML with a custom SAX handler. The handler prints cell references and string values. Note that the API only fires events for data actually stored in the file, so there may be gaps. ```java import java.io.InputStream; import java.util.Iterator; import org.apache.poi.util.XMLHelper; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.xssf.eventusermodel.XSSFReader; import org.apache.poi.xssf.model.SharedStringsTable; import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.DefaultHandler; import javax.xml.parsers.ParserConfigurationException; public class ExampleEventUserModel { public void processOneSheet(String filename) throws Exception { OPCPackage pkg = OPCPackage.open(filename); XSSFReader r = new XSSFReader( pkg ); SharedStringsTable sst = r.getSharedStringsTable(); XMLReader parser = fetchSheetParser(sst); // To look up the Sheet Name / Sheet Order / rID, // you need to process the core Workbook stream. // Normally it's of the form rId# or rSheet# InputStream sheet2 = r.getSheet("rId2"); InputSource sheetSource = new InputSource(sheet2); parser.parse(sheetSource); sheet2.close(); } public void processAllSheets(String filename) throws Exception { OPCPackage pkg = OPCPackage.open(filename); XSSFReader r = new XSSFReader( pkg ); SharedStringsTable sst = r.getSharedStringsTable(); XMLReader parser = fetchSheetParser(sst); Iterator sheets = r.getSheetsData(); while(sheets.hasNext()) { System.out.println("Processing new sheet:\n"); InputStream sheet = sheets.next(); InputSource sheetSource = new InputSource(sheet); parser.parse(sheetSource); sheet.close(); System.out.println(""); } } public XMLReader fetchSheetParser(SharedStringsTable sst) throws SAXException, ParserConfigurationException { XMLReader parser = XMLHelper.newXMLReader(); ContentHandler handler = new SheetHandler(sst); parser.setContentHandler(handler); return parser; } /** * See org.xml.sax.helpers.DefaultHandler javadocs */ private static class SheetHandler extends DefaultHandler { private SharedStringsTable sst; private String lastContents; private boolean nextIsString; private SheetHandler(SharedStringsTable sst) { this.sst = sst; } public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException { // c => cell if(name.equals("c")) { // Print the cell reference System.out.print(attributes.getValue("r") + " - "); // Figure out if the value is an index in the SST String cellType = attributes.getValue("t"); if(cellType != null && cellType.equals("s")) { nextIsString = true; } else { nextIsString = false; } } // Clear contents cache lastContents = ""; } public void endElement(String uri, String localName, String name) throws SAXException { // Process the last contents as required. // Do now, as characters() may be called more than once if(nextIsString) { int idx = Integer.parseInt(lastContents); lastContents = sst.getItemAt(idx).getString(); nextIsString = false; } // v => contents of a cell // Output after we've seen the string contents if(name.equals("v")) { System.out.println(lastContents); } } public void characters(char[] ch, int start, int length) { lastContents += new String(ch, start, length); } } public static void main(String[] args) throws Exception { ExampleEventUserModel example = new ExampleEventUserModel(); example.processOneSheet(args[0]); example.processAllSheets(args[0]); } } ``` -------------------------------- ### setupMaster(GeometryRow row) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xdgf/usermodel/section/geometry/PolyLineTo.html Sets up this geometry row from a master row. ```APIDOC ## setupMaster(GeometryRow row) ### Description Sets up this geometry row from a master row. ### Method `public void setupMaster(GeometryRow row)` ### Parameters - **row** (GeometryRow) - Required - The master geometry row to copy settings from. ### Specified By - `setupMaster` in interface `GeometryRow` ``` -------------------------------- ### XWPFSettings() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xwpf/usermodel/XWPFSettings.html Constructs a new XWPFSettings instance. ```APIDOC ## XWPFSettings() ### Description Constructs a new XWPFSettings instance. ### Constructor `public XWPFSettings()` ``` -------------------------------- ### delete(int, int) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwpf/HWPFDocument.html Deletes a range of content from the document starting at the given start position with the specified length. ```APIDOC ## delete(int, int) ### Description Deletes a range of content from the document starting at the given start position with the specified length. ### Method delete ### Signature public void delete(int start, int length) ### Parameters - **start** (int) - Required - The start position of the deletion. - **length** (int) - Required - The number of characters to delete. ``` -------------------------------- ### Line spacing examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xslf/usermodel/XSLFTextParagraph.html Examples showing how to set line spacing as a percentage of the largest text size on each line. ```java // spacing will be 120% of the size of the largest text on each line paragraph.setLineSpacing(120); ``` ```java // spacing will be 200% of the size of the largest text on each line paragraph.setLineSpacing(200); ``` -------------------------------- ### create Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/poifs/filesystem/POIFSFileSystem.html Creates a new POIFSFileSystem in a new File. Use POIFSFileSystem(File) to open an existing File, this should only be used to create a new empty filesystem. ```APIDOC ## create ### Description Creates a new POIFSFileSystem in a new File. Use POIFSFileSystem(File) to open an existing File, this should only be used to create a new empty filesystem. ### Method create ### Parameters - **file** (File) - Required - The file to create and open. ### Returns - **POIFSFileSystem** - The created and opened POIFSFileSystem. ### Throws - **java.io.IOException** ``` -------------------------------- ### WmfPie() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwmf/record/HwmfDraw.WmfPie.html Constructs a new WmfPie instance. ```APIDOC ## WmfPie() ### Description Constructs a new WmfPie instance. ### Constructor `public WmfPie()` ### Parameters None. ### Returns A new WmfPie object. ``` -------------------------------- ### Example iteration using values() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/sl/usermodel/RectAlign.html Example usage of the values() method to iterate over all RectAlign constants and print each one. ```java for (RectAlign c : RectAlign.values())   System.out.println(c); ``` -------------------------------- ### Tint calculation examples Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/usermodel/HSSFExtendedColor.html Examples of how to apply tint to ctColor, showing formulas for darkening and lightening with sample calculations. ```text If (tint < 0) Lum' = Lum * (1.0 + tint) For example: Lum = 200; tint = -0.5; Darken 50% Lum' = 200 * (0.5) => 100 For example: Lum = 200; tint = -1.0; Darken 100% (make black) Lum' = 200 * (1.0-1.0) => 0 If (tint > 0) Lum' = Lum * (1.0-tint) + (HLSMAX - HLSMAX * (1.0-tint)) For example: Lum = 100; tint = 0.75; Lighten 75% Lum' = 100 * (1-.75) + (HLSMAX - HLSMAX*(1-.75)) = 100 * .25 + (255 - 255 * .25) = 25 + (255 - 63) = 25 + 192 = 217 For example: Lum = 100; tint = 1.0; Lighten 100% (make white) Lum' = 100 * (1-1) + (HLSMAX - HLSMAX*(1-1)) = 100 * 0 + (255 - 255 * 0) = 0 + (255 - 0) = 255 ``` -------------------------------- ### Example: converting .xlsm to .xlsx Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/openxml4j/opc/OPCPackage.html Shows how to open a macro-enabled workbook, replace its content type, and save as a regular .xlsx file. ```java OPCPackage pkg = OPCPackage.open(new FileInputStream("macro-workbook.xlsm")); pkg.replaceContentType( "application/vnd.ms-excel.sheet.macroEnabled.main+xml", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"); FileOutputStream out = new FileOutputStream("workbook.xlsx"); pkg.save(out); out.close(); ``` -------------------------------- ### Example: Iterate HashAlgorithm values() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/poifs/crypt/HashAlgorithm.html Iterates over the enum constants using HashAlgorithm.values() and prints each constant. Provided as an example of using the values() method. ```java for (HashAlgorithm c : HashAlgorithm.values()) System.out.println(c); ``` -------------------------------- ### getPageStart Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/record/PrintSetupRecord.html Returns the starting page number. ```APIDOC ### Method getPageStart ### Signature public short getPageStart() ### Returns - **short** - The starting page number. ### Description Returns the starting page number. ``` -------------------------------- ### Constructor: XDDFLineProperties() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xddf/usermodel/XDDFLineProperties.html Creates a new instance of XDDFLineProperties with default settings. ```APIDOC ## Constructor: XDDFLineProperties() ### Description Creates a new instance of XDDFLineProperties with default settings. ### Method Constructor ### Signature `public XDDFLineProperties()` ``` -------------------------------- ### Get POI filesystem root directory Source: https://poi.apache.org/components/hpsf/how-to.html Gets the root directory of the POI filesystem as a DirectoryEntry. This is the first step to access entries in the filesystem. ```java DirectoryEntry dir = poifs.getRoot(); ``` -------------------------------- ### Example external reference formulas Source: https://poi.apache.org/components/spreadsheet/eval.html Formulas that reference cells or named ranges in another workbook. These are shown as examples of what external references look like. ```text =SUM([Finances.xlsx]Numbers!D10:D25) =SUM('C:\Data\[Finances.xlsx]Numbers'!D10:D25) =SUM([Finances.xlsx]Range20) ``` -------------------------------- ### initDirectory Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/usermodel/HSLFSlideShow.html Check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data. ```APIDOC ## initDirectory ### Description Check if we were created by POIFS otherwise create a new dummy POIFS for storing the package data. ### Method `protected boolean initDirectory()` ### Returns - `boolean` - True if the directory was initialized successfully. ``` -------------------------------- ### TextCap.values() and iteration example Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xssf/usermodel/TextCap.html The values() method returns an array of the enum constants in the order they are declared. The example shows how to iterate over the constants and print each one. ```java public static TextCap[] values() ``` ```java for (TextCap c : TextCap.values()) System.out.println(c); ``` -------------------------------- ### main(java.lang.String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hslf/dev/SLWTTextListing.html The main entry point for the SLWTTextListing utility. It processes the provided arguments (typically file paths) to locate SlideListWithText entries and print any text found. Throws IOException if an I/O error occurs. ```APIDOC ## main(java.lang.String[] args) ### Description Public static method that serves as the entry point for the SLWTTextListing utility. It uses record-level code to locate SlideListWithText entries in the input files and prints any text found. ### Method main ### Signature `public static void main(java.lang.String[] args) throws java.io.IOException` ### Parameters - **args** (String[]) - Required - Command-line arguments, typically file paths to process. ### Throws - **java.io.IOException** - If an I/O error occurs while reading the input files. ### Usage Example ```java SLWTTextListing.main(new String[] {"presentation.ppt"}); ``` ``` -------------------------------- ### Iteration example: for (Grouping c : Grouping.values()) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xddf/usermodel/chart/Grouping.html Shows how to iterate over the Grouping enum constants using the values() method. The example prints each constant to the console. ```java for (Grouping c : Grouping.values()) System.out.println(c); ``` -------------------------------- ### init Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hemf/record/emfplus/HemfPlusBrush.EmfPlusBrushData.html Initializes the brush data from an input stream. Throws IOException if an I/O error occurs. ```APIDOC ## init ### Description Initializes the brush data from an input stream. ### Method `long init(LittleEndianInputStream leis, long dataSize) throws java.io.IOException` ### Parameters - **leis** (LittleEndianInputStream) - Required - The input stream to read from. - **dataSize** (long) - Required - The size of the data to read. ### Returns - **long** - The number of bytes read or processed. ### Throws - **java.io.IOException** - If an I/O error occurs. ``` -------------------------------- ### getGuides Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xddf/usermodel/XDDFCustomGeometry2D.html Returns a list of all guides in the custom geometry. ```APIDOC ## getGuides ### Description Returns a list of all guides in the custom geometry. ### Method `public java.util.List getGuides()` ### Returns - **java.util.List** - A list of guides. ``` -------------------------------- ### Example commit() implementation for generic XML entry Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/ooxml/POIXMLDocumentPart.html Example of overriding commit() to save a generic XML entry. Uses getPackagePart(), getXmlBean(), and DEFAULT_XML_OPTIONS. ```java protected void commit() throws IOException { PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); XmlObject bean = getXmlBean(); //the "model" which holds changes in memory bean.save(out, DEFAULT_XML_OPTIONS); out.close(); } ``` -------------------------------- ### getStart Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwpf/usermodel/Bookmark.html Returns the start position of the bookmark in the document. ```APIDOC ## getStart ### Description Returns the start position of the bookmark. ### Method int getStart() ### Returns - **int** - The start position of the bookmark. ``` -------------------------------- ### calculateWorkdays(double start, double end, double[] holidays) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/ss/formula/atp/WorkdayCalculator.html Calculates the number of workdays between a start and an end date, as Excel representations, considering a range of holidays. ```APIDOC ## calculateWorkdays(double start, double end, double[] holidays) ### Description Calculate how many workdays are there between a start and an end date, as excel representations, considering a range of holidays. ### Method calculateWorkdays ### Parameters - **start** (double) - start date. - **end** (double) - end date. - **holidays** (double[]) - an array of holidays. ### Returns number of workdays between start and end dates, including both dates. ``` ```APIDOC ## calculateWorkdays(double start, int workdays, double[] holidays) ### Description Calculate the workday past x workdays from a starting date, considering a range of holidays. ### Parameters - **start** (double) - start date. - **workdays** (int) - number of workdays to be past from starting date. - **holidays** (double[]) - an array of holidays. ### Returns - **java.util.Date** - date past x workdays. ``` -------------------------------- ### Sign an office document from a file (PKCS12 keystore) Source: https://poi.apache.org/encryption.html Loads a PKCS12 keystore, extracts a private key and certificate, configures SignatureConfig, and signs an OPC package. Optionally verifies the signature and closes the package. ```java // loading the keystore - pkcs12 is used here, but of course jks & co are also valid // the keystore needs to contain a private key and it's certificate having a // 'digitalSignature' key usage char password[] = "test".toCharArray(); File file = new File("test.pfx"); KeyStore keystore = KeyStore.getInstance("PKCS12"); FileInputStream fis = new FileInputStream(file); keystore.load(fis, password); fis.close(); // extracting private key and certificate String alias = "xyz"; // alias of the keystore entry Key key = keystore.getKey(alias, password); X509Certificate x509 = (X509Certificate)keystore.getCertificate(alias); // filling the SignatureConfig entries (minimum fields, more options are available ...) SignatureConfig signatureConfig = new SignatureConfig(); signatureConfig.setKey(keyPair.getPrivate()); signatureConfig.setSigningCertificateChain(Collections.singletonList(x509)); // adding the signature document to the package SignatureInfo si = new SignatureInfo(); OPCPackage pkg = OPCPackage.open(..., PackageAccess.READ_WRITE); si.setOpcPackage(pkg); si.setSignatureConfig(signatureConfig); si.confirmSignature(); // optionally verify the generated signature boolean b = si.verifySignature(); assert (b); // write the changes back to disc pkg.close(); ``` -------------------------------- ### setFillBackgroundColor with SOLID_FILL example in HSSFCellStyle Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hssf/usermodel/HSSFCellStyle.html Shows the method signature and the example for the special case SOLID_FILL. Setting the fill style is required for the color to be shown in the cell. ```java public void setFillBackgroundColor(short bg) ``` ```java cs.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND ); cs.setFillForegroundColor(new HSSFColor.RED().getIndex()); ``` -------------------------------- ### Open POIFSFileSystem from File or InputStream Source: https://poi.apache.org/components/poifs/how-to.html Shows two ways to open a POIFSFileSystem: from a File (memory efficient) or from an InputStream (requires more memory). Both obtain the root directory and handle IOException. ```java // This is the most memory efficient way to open the FileSystem try (POIFSFileSystem fs = new POIFSFileSystem(new File(filename))) { DirectoryEntry root = fs.getRoot(); } catch (IOException e) { // an I/O error occurred, or the File did not provide a compatible // POIFS data structure } ``` ```java // Using an InputStream requires more memory than using a File try (POIFSFileSystem fs = new POIFSFileSystem(inputStream)) { DirectoryEntry root = fs.getRoot(); } catch (IOException e) { // an I/O error occurred, or the InputStream did not provide // a compatible POIFS data structure } ``` -------------------------------- ### Example iteration over FontHeader.PanoseFamily.values() Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/common/usermodel/fonts/FontHeader.PanoseFamily.html Example usage of the values() method to iterate over all enum constants and print each one. This is shown in the documentation as a typical way to use the method. ```java for (FontHeader.PanoseFamily c : FontHeader.PanoseFamily.values()) System.out.println(c); ``` -------------------------------- ### setupMaster(GeometryRow) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/xdgf/usermodel/section/geometry/SplineStart.html Sets up the master geometry row for this spline start. ```APIDOC ## setupMaster(GeometryRow) ### Description Sets up the master geometry row for this spline start. ### Method public void setupMaster(GeometryRow row) ### Parameters - **row** (GeometryRow) - Required - The master geometry row. ``` -------------------------------- ### getBookmarksStartedBetween(int startInclusive, int endExclusive) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hwpf/usermodel/Bookmarks.html Returns a map of bookmarks started in the specified range, where the key is the start position and the value is a sorted list of Bookmark objects. ```APIDOC ## getBookmarksStartedBetween(int startInclusive, int endExclusive) ### Description Returns a map of bookmarks started in the specified range, where the key is the start position and the value is a sorted list of Bookmark objects. ### Method java.util.Map> getBookmarksStartedBetween(int startInclusive, int endExclusive) ### Parameters - **startInclusive** (int) - Required - The inclusive start position of the range. - **endExclusive** (int) - Required - The exclusive end position of the range. ### Returns - **java.util.Map>** - Map of bookmarks started in the specified range, where key is start position and value is sorted List of Bookmark. ``` -------------------------------- ### main(java.lang.String[] args) Source: https://poi.apache.org/apidocs/5.0/org/apache/poi/hsmf/dev/TypesLister.html Static main method for command-line execution of the TypesLister. ```APIDOC ## main(java.lang.String[] args) ### Description Static main method that serves as the entry point for command-line execution. ### Method `public static void main(java.lang.String[] args)` ### Parameters - **args** (java.lang.String[]) - Required - Command-line arguments. ### Returns No return value. ```