- java.lang.Object
-
- org.dhatim.fastexcel.Workbook
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class Workbook extends Object implements Closeable
-
-
Constructor Summary
Constructors Constructor Description Workbook(OutputStream os, String applicationName, String applicationVersion)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidfinish()Complete workbook generation: this writes worksheets and additional files as zip entries to the output stream.WorksheetnewWorksheet(String name)Create a new worksheet in this workbook.Propertiesproperties()voidprotectStructure(String password)Protects the workbook structure with a password.voidsetActiveTab(int tabIndex)voidsetCompressionLevel(int level)Sets the compression level of the xlsx.voidsetGlobalDefaultFont(String fontName, double fontSize)voidsetGlobalDefaultFont(org.dhatim.fastexcel.Font font)voidsortWorksheets(Comparator<Worksheet> comparator)Sort the current worksheets with the given Comparator
-
-
-
Constructor Detail
-
Workbook
public Workbook(OutputStream os, String applicationName, String applicationVersion)
Constructor.- Parameters:
os- Output stream eventually holding the serialized workbook.applicationName- Name of the application which generated this workbook.applicationVersion- Version of the application. Ignored ifnull. Refer to this page for details.
-
-
Method Detail
-
setCompressionLevel
public void setCompressionLevel(int level)
Sets the compression level of the xlsx. An xlsx file is a standard zip archive consisting of xml files. Default compression is 4.- Parameters:
level- the compression level (0-9)
-
setActiveTab
public void setActiveTab(int tabIndex)
-
protectStructure
public void protectStructure(String password)
Protects the workbook structure with a password. Prevents users from unhiding, adding, moving, or deleting sheets. (Note that this is not very secure and only meant for discouraging changes. Same amount of protection as the edit password for worksheets.)- Parameters:
password- The password to use.
-
setGlobalDefaultFont
public void setGlobalDefaultFont(String fontName, double fontSize)
-
setGlobalDefaultFont
public void setGlobalDefaultFont(org.dhatim.fastexcel.Font font)
-
properties
public Properties properties()
-
sortWorksheets
public void sortWorksheets(Comparator<Worksheet> comparator)
Sort the current worksheets with the given Comparator- Parameters:
comparator- The Comparator used to sort the worksheets
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
finish
public void finish() throws IOExceptionComplete workbook generation: this writes worksheets and additional files as zip entries to the output stream.- Throws:
IOException- In case of I/O error.
-
-