|
xlsgen > overview > Encryption |
|
xlsgen makes it possible to encrypt XLS (XLA, XLT, XLM, ...), XLSX (XLSA, XLST, XLSM, ...) and PDF files. All it takes is a password. When the file is encrypted, opening the file in Excel will result in a prompt asking for the password to be entered.
XLS and XLSX encrypted files can be opened with xlsgen.
Encryption
The password must be less or equal than 15 characters for XLS files and 255 characters for XLSX files.
Java code |
// pass "abcd" as password
workbook.putEncryptPassword("abcd");
|
VB code |
' pass "abcd" as password
workbook.EncryptPassword = "abcd"
|
C# code |
// pass "abcd" as password
workbook.EncryptPassword = "abcd";
|
C++ code |
// pass "abcd" as password
workbook->EncryptPassword = L"abcd";
|
Decryption
Likewise, decrypting files implies to pass a password before opening the file itself.
Java code |
// pass "abcd" as open password
engine.getWorkbooks().putOpenPassword("abcd");
// now we can attempt to open the XLSX encrypted file
XlsWorkbook workbook = engine.Open( "input\\Book1_Excel_protected.xlsx", "" );
//...
workbook.Close();
|
VB code |
' pass "abcd" as open password
engine.Workbooks.OpenPassword = "abcd"
' now we can attempt to open the XLSX encrypted file
IXlsWorkbook workbook = engine.Open( "input\\Book1_Excel_protected.xlsx", "" )
'...
workbook.Close
|
C# code |
// pass "abcd" as open password
engine.Workbooks.OpenPassword = "abcd";
// now we can attempt to open the XLSX encrypted file
IXlsWorkbook workbook = engine.Open( "input\\Book1_Excel_protected.xlsx", "" );
//...
workbook.Close();
|
C++ code |
xlsgen::IXlsEnginePtr engine( __uuidof(xlsgen::CoXlsEngine) );
// pass "abcd" as open password
engine->Workbooks->OpenPassword = L"abcd";
// now we can attempt to open the XLSX encrypted file
xlsgen::IXlsWorkbookPtr workbook = engine->Open( L"input\\Book1_Excel_protected.xlsx", L"" );
//...
workbook->Close();
|
xlsgen documentation. © ARsT Design all rights reserved.