com.extentech.ExtenXLS
Class EncryptedWorkBookHandle

java.lang.Object
  extended by com.extentech.ExtenXLS.DocumentHandle
      extended by com.extentech.ExtenXLS.WorkBookHandle
          extended by com.extentech.ExtenXLS.EncryptedWorkBookHandle
All Implemented Interfaces:
Document, Handle, WorkBook, Closeable

public class EncryptedWorkBookHandle
extends WorkBookHandle

EncryptedWorkBookHandle is a WorkBookHandle that manages encrypted files. Encryption within Excel 2007 files (xlsx) and earlier binary versions of excel (xls) is dramatically different. If security is a concern, the AES encryption of xlsx files is superior. Passwords are required to open EncryptedWorkBooks, and if not re-set they will save as encrypted files utilizing the same password that they were opened as. Utilize the writeEncrypted methods to output encrypted workbooks. The standard write() methods will output unencrypted workbooks if needed


Field Summary
 
Fields inherited from class com.extentech.ExtenXLS.WorkBookHandle
CONVERTMULBLANKS, FORMAT_XLS, FORMAT_XLSM, FORMAT_XLSX, FORMAT_XLTM, FORMAT_XLTX
 
Fields inherited from class com.extentech.ExtenXLS.DocumentHandle
FORMAT_NATIVE
 
Fields inherited from interface com.extentech.ExtenXLS.WorkBook
ALLOWDUPES, CALC_MODE_PROP, CALCULATE_ALWAYS, CALCULATE_AUTO, CALCULATE_EXPLICIT, REFTRACK_PROP, SHAREDUPES, STRING_ENCODING_AUTO, STRING_ENCODING_COMPRESSED, STRING_ENCODING_UNICODE
 
Fields inherited from interface com.extentech.ExtenXLS.Document
DEBUG_HIGH, DEBUG_LOW, DEBUG_MEDIUM
 
Constructor Summary
EncryptedWorkBookHandle(InputStream encryptedBook, String password)
          Create a new WorkBookHandle from the byte array passed in.
EncryptedWorkBookHandle(String password)
          Default constructor creates a new, empty EncryptedWorkBookHandle with a password set for saveEncrypted functionality 3 WorkSheets: "Sheet1","Sheet2",and "Sheet3".
EncryptedWorkBookHandle(WorkBookHandle workbook, String password)
          Constructor to convert a WorkBookHandle into an EncryptedWorkBookHandle.
 
Method Summary
static void writeAndEncrypt(WorkBookHandle book, OutputStream out, String password)
          A static utility method to write a xlsx workbook in 128 bit AES encryption to the OutputStream provided.
 void writeEncrypted(OutputStream out)
          Write a workbook in 128 bit encryption to the OutputStream provided, utilizing the same password it was originally opened or created with.
 void writeEncrypted(OutputStream out, boolean Excel2007Format, String password)
          Write a workbook in 128 bit encryption to the OutputStream provided.
 void writeEncrypted(OutputStream out, String password)
          Write a workbook in 128 bit encryption to the OutputStream provided.
 
Methods inherited from class com.extentech.ExtenXLS.WorkBookHandle
addSheetFromWorkBook, addSheetFromWorkBookWithFormatting, addWorkSheet, addWorkSheet, calculateFormulas, close, copyChartToSheet, copyChartToSheet, copyWorkSheet, createChart, createNamedRange, createWorkSheet, createWorkSheet, deleteChart, eventMode, getAllStrings, getBytes, getCell, getCellRanges, getCells, getChart, getChartById, getCharts, getConditionalFormats, getFactory, getFileExtension, getFormat, getFormats, getFormulaCalculationMode, getFormulaHandle, getImage, getImage, getImages, getIsExcel2007, getLEOFile, getName, getNamedRange, getNamedRangeInScope, getNamedRanges, getNamedRangesInScope, getNoSheetWorkBook, getNumCells, getNumWorkSheets, getPivotTable, getPivotTables, getStats, getStats, getWorkBook, getWorkSheet, getWorkSheet, getWorkSheets, getXLSVersionString, is1904, markFormulasDirty, recalc, removeAllWorkSheets, reset, saveComponentAsJPEG, saveImageAsJPEG, searchAndReplace, setDefaultColWidth, setDefaultRowHeight, setDupeStringMode, setFormulaCalculationMode, setIsExcel2007, setProtected, setShowSheetTabs, setStringEncodingMode, showSheetTabs, write, write, write, write, writeBytes, writeXLSXBytes, writeXLSXBytes
 
Methods inherited from class com.extentech.ExtenXLS.DocumentHandle
addProperty, getFile, getFileName, getInstance, getProperties, getProperty, getVersion, setDebugLevel, setFile, setFileName, setName, setProperties, toString, write, write, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.extentech.ExtenXLS.WorkBook
addProperty, getProperty, setDebugLevel, setName, toString
 

Constructor Detail

EncryptedWorkBookHandle

public EncryptedWorkBookHandle(String password)
Default constructor creates a new, empty EncryptedWorkBookHandle with a password set for saveEncrypted functionality 3 WorkSheets: "Sheet1","Sheet2",and "Sheet3".


EncryptedWorkBookHandle

public EncryptedWorkBookHandle(WorkBookHandle workbook,
                               String password)
Constructor to convert a WorkBookHandle into an EncryptedWorkBookHandle.

Parameters:
workbook - - WorkBookHandle to convert into an EncryptedWorkBookHandle
password - - Password to save EncryptedWorkBookHandle with

EncryptedWorkBookHandle

public EncryptedWorkBookHandle(InputStream encryptedBook,
                               String password)
                        throws com.extentech.formats.XLS.WorkBookException
Create a new WorkBookHandle from the byte array passed in. InputStream passed in must contain a valid xls or xlsx workbook file

Parameters:
encryptedBook - - InputStream containing the valid XLS or XLSX file for reading
Throws:
WorkBookException - if the inputstream cannot be parsed correctly. Note the error codes provided in WorkBookException can detail if password is incorrect, if file is corrupt, etc.
com.extentech.formats.XLS.WorkBookException
Method Detail

writeEncrypted

public void writeEncrypted(OutputStream out,
                           String password)
                    throws com.extentech.formats.XLS.WorkBookException
Write a workbook in 128 bit encryption to the OutputStream provided. The workbook will be written in the format that it was parsed in, that is, .xls files will be saved as encrypted .xls, and .xlsx files will be saved as encrypted.xlsx. The default format for newly created workbooks is .xlsx. Choice of format can be forced by utilizing the writeEncrypted(OutputStream out, boolean Excel2007Format, String password); For more control over xlsx encryption, please utilize the extentech.crypto.mscrypto.MSOfficeEncryption classes

Parameters:
out -
password - = new password to set to the encrypted workbook
Throws:
com.extentech.formats.XLS.WorkBookException

writeEncrypted

public void writeEncrypted(OutputStream out,
                           boolean Excel2007Format,
                           String password)
                    throws com.extentech.formats.XLS.WorkBookException
Write a workbook in 128 bit encryption to the OutputStream provided. The output format can be controlled via the Excel2007Format boolean. True will write an xlsx file, while false will output xls encrypted files. For more control over xlsx encryption, please utilize the extentech.crypto.mscrypto.MSOfficeEncryption classes

Parameters:
out -
password - = new password to set to the encrypted workbook
Throws:
com.extentech.formats.XLS.WorkBookException

writeAndEncrypt

public static void writeAndEncrypt(WorkBookHandle book,
                                   OutputStream out,
                                   String password)
                            throws com.extentech.formats.XLS.WorkBookException
A static utility method to write a xlsx workbook in 128 bit AES encryption to the OutputStream provided. For more control over encryption, please utilize the extentech.crypto.mscrypto.MSOfficeEncryption classes

Parameters:
out -
password - = new password to set to the encrypted workbook
Throws:
com.extentech.formats.XLS.WorkBookException

writeEncrypted

public void writeEncrypted(OutputStream out)
                    throws com.extentech.formats.XLS.WorkBookException
Write a workbook in 128 bit encryption to the OutputStream provided, utilizing the same password it was originally opened or created with. The workbook will be written in the format that it was parsed in, that is, .xls files will be saved as encrypted .xls and .xlsx files will be saved as encrypted.xlsx. The default format for newly created workbooks is .xlsx. Choice of format can be forced by utilizing the writeEncrypted(OutputStream out, boolean Excel2007Format); File will be written utilizing the same password it was opened with

Parameters:
out -
password -
Throws:
com.extentech.formats.XLS.WorkBookException


Copyright © 2011 Extentech Inc. All Rights Reserved.