You've already forked lazarus-ccr
fpspreadsheet: Add demo for reading encrypted xlsx file.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8908 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
BIN
components/fpspreadsheet/examples/other/crypto/pwd 123.xlsx
Normal file
BIN
components/fpspreadsheet/examples/other/crypto/pwd 123.xlsx
Normal file
Binary file not shown.
@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="12"/>
|
||||
<PathDelim Value="\"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
<MainUnitHasScaledStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<Title Value="read_encrypted_xlsx"/>
|
||||
<UseAppBundle Value="False"/>
|
||||
<ResourceType Value="res"/>
|
||||
</General>
|
||||
<BuildModes>
|
||||
<Item Name="Default" Default="True"/>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
<UseFileFilters Value="True"/>
|
||||
</PublishOptions>
|
||||
<RunParams>
|
||||
<FormatVersion Value="2"/>
|
||||
</RunParams>
|
||||
<RequiredPackages>
|
||||
<Item>
|
||||
<PackageName Value="laz_fpspreadsheet_crypto"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<PackageName Value="laz_fpspreadsheet"/>
|
||||
</Item>
|
||||
</RequiredPackages>
|
||||
<Units>
|
||||
<Unit>
|
||||
<Filename Value="read_encrypted_xlsx.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
</Unit>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="11"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="read_encrypted_xlsx"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||
</SearchPaths>
|
||||
<Linking>
|
||||
<Debugging>
|
||||
<DebugInfoType Value="dsDwarf3"/>
|
||||
<UseHeaptrc Value="True"/>
|
||||
</Debugging>
|
||||
</Linking>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Exceptions>
|
||||
<Item>
|
||||
<Name Value="EAbort"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item>
|
||||
<Item>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
@ -0,0 +1,34 @@
|
||||
program read_encrypted_xlsx;
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
fpSpreadsheet, fpsTypes, fpsUtils, xlsxOOXML_Crypto;
|
||||
|
||||
const
|
||||
FILENAME = 'pwd 123.xlsx';
|
||||
PASSWORD = '123';
|
||||
|
||||
var
|
||||
wb: TsWorkbook;
|
||||
ws: TsWorksheet;
|
||||
cell: PCell;
|
||||
t: TDateTime;
|
||||
begin
|
||||
t := Now;
|
||||
wb := TsWorkbook.Create;
|
||||
try
|
||||
wb.ReadFromFile(FILENAME, sfidOOXML_Crypto, PASSWORD, []);
|
||||
ws := wb.GetFirstWorksheet;
|
||||
if ws <> nil then
|
||||
for cell in ws.Cells do
|
||||
WriteLn('cell ', GetCellString(cell^.Row, cell^.Col), ' = "', ws.ReadAsText(cell), '"');
|
||||
finally
|
||||
wb.Free;
|
||||
end;
|
||||
t := Now - t;
|
||||
WriteLn('Time to decrypt and load: ', FormatDateTime('nn:ss.zzz', t), ' seconds');
|
||||
WriteLn;
|
||||
Write('Press ENTER to close...');
|
||||
ReadLn;
|
||||
end.
|
||||
|
Reference in New Issue
Block a user