Class ExcelDocument
java.lang.Object
com.northconcepts.datapipeline.excel.ExcelDocument
- All Implemented Interfaces:
Closeable,AutoCloseable
The in-memory abstraction for an Excel workbook. This object is not thread-safe and will throw an exception if used in
multiple ExcelReaders and/or ExcelWriter concurrently. Since its data is stored in memory, reading and re-reading from
it multiple times is very cheap (think millions of reads per second).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSelects the Excel library (Apache POI or JXL) and workbook format anExcelDocumentuses. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty workbook that uses theExcelDocument.ProviderType.POI_XSSF(.xlsx) provider.ExcelDocument(ExcelDocument.ProviderType providerType) Creates an empty workbook that uses the given provider; use anopenmethod to load existing content. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()The method can be called when this document can be discarded, but it will be called automatically in the finalize() method.protected voidfinalize()getFile()Returns the file last passed toopen(File)or null if the workbook was not opened from a file.String[]Returns the workbook's sheet names in order, or null with theExcelDocument.ProviderType.POI_XSSFBprovider.booleanisClosed()open(InputStream inputStream) Loads the workbook from the given stream; not supported by theExcelDocument.ProviderType.POI_XSSF_SAXandExcelDocument.ProviderType.POI_XSSFBproviders, which needopen(File).Writes the workbook to the given file; call it after theExcelWriters close since they do not save it.save(OutputStream outputStream) Writes the workbook to the given stream; call it after theExcelWriters close since they do not save it.
-
Constructor Details
-
ExcelDocument
public ExcelDocument()Creates an empty workbook that uses theExcelDocument.ProviderType.POI_XSSF(.xlsx) provider. -
ExcelDocument
Creates an empty workbook that uses the given provider; use anopenmethod to load existing content.
-
-
Method Details
-
getProviderType
-
open
Loads the workbook from the given stream; not supported by theExcelDocument.ProviderType.POI_XSSF_SAXandExcelDocument.ProviderType.POI_XSSFBproviders, which needopen(File). -
open
-
close
public void close()The method can be called when this document can be discarded, but it will be called automatically in the finalize() method. It's safe to call this method multiple times -- subsequent calls will do nothing.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isClosed
public boolean isClosed() -
finalize
-
save
Writes the workbook to the given stream; call it after theExcelWriters close since they do not save it. -
save
Writes the workbook to the given file; call it after theExcelWriters close since they do not save it. -
getSheetNames
Returns the workbook's sheet names in order, or null with theExcelDocument.ProviderType.POI_XSSFBprovider. -
getFile
Returns the file last passed toopen(File)or null if the workbook was not opened from a file.
-