You've already forked lazarus-ccr
fpspreadsheet: Add demo programs for reading/writing comments.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8341 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -0,0 +1,69 @@
|
|||||||
|
<?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"/>
|
||||||
|
<CompatibilityMode Value="True"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<Title Value="comments_demo_read"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<UseFileFilters Value="True"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<FormatVersion Value="2"/>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages Count="1">
|
||||||
|
<Item1>
|
||||||
|
<PackageName Value="laz_fpspreadsheet"/>
|
||||||
|
</Item1>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units Count="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="comments_demo_read.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="comments_demo_read"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf3"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
@ -0,0 +1,49 @@
|
|||||||
|
program comments_demo_read;
|
||||||
|
|
||||||
|
uses
|
||||||
|
SysUtils, fpspreadsheet, fpstypes, fpsutils, fpsallformats;
|
||||||
|
const
|
||||||
|
FILE_NAME = 'test';
|
||||||
|
|
||||||
|
function RemoveLinebreaks(s: String): String;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
SetLength(Result, Length(s));
|
||||||
|
for i := 1 to Length(s) do
|
||||||
|
if s[i] in [#10, #13] then
|
||||||
|
Result[i] := ' '
|
||||||
|
else
|
||||||
|
Result[i] := s[i];
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
workbook: TsWorkbook;
|
||||||
|
worksheet: TsWorksheet;
|
||||||
|
cmnt: PsComment;
|
||||||
|
txt: string;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
workbook := TsWorkbook.Create;
|
||||||
|
try
|
||||||
|
workbook.ReadFromFile(FILE_NAME + '.xlsx', sfOOXML);
|
||||||
|
for i := 0 to workbook.GetWorksheetCount-1 do
|
||||||
|
begin
|
||||||
|
worksheet := workbook.GetWorksheetByIndex(i);
|
||||||
|
WriteLn('Worksheet "', worksheet.Name, '":');
|
||||||
|
for cmnt in worksheet.Comments do
|
||||||
|
begin
|
||||||
|
txt := RemoveLinebreaks(cmnt^.Text);
|
||||||
|
WriteLn(' Comment in cell ', GetCellString(cmnt^.Row, cmnt^.Col), ': "', txt, '"');
|
||||||
|
end;
|
||||||
|
WriteLn;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
workbook.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
WriteLn;
|
||||||
|
WriteLn('Press ENTER to close...');
|
||||||
|
ReadLn;
|
||||||
|
end.
|
||||||
|
|
@ -0,0 +1,69 @@
|
|||||||
|
<?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"/>
|
||||||
|
<CompatibilityMode Value="True"/>
|
||||||
|
</Flags>
|
||||||
|
<SessionStorage Value="InProjectDir"/>
|
||||||
|
<Title Value="comments_demo_write"/>
|
||||||
|
<UseAppBundle Value="False"/>
|
||||||
|
<ResourceType Value="res"/>
|
||||||
|
</General>
|
||||||
|
<BuildModes Count="1">
|
||||||
|
<Item1 Name="Default" Default="True"/>
|
||||||
|
</BuildModes>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<UseFileFilters Value="True"/>
|
||||||
|
</PublishOptions>
|
||||||
|
<RunParams>
|
||||||
|
<FormatVersion Value="2"/>
|
||||||
|
</RunParams>
|
||||||
|
<RequiredPackages Count="1">
|
||||||
|
<Item1>
|
||||||
|
<PackageName Value="laz_fpspreadsheet"/>
|
||||||
|
</Item1>
|
||||||
|
</RequiredPackages>
|
||||||
|
<Units Count="1">
|
||||||
|
<Unit0>
|
||||||
|
<Filename Value="comments_demo_write.pas"/>
|
||||||
|
<IsPartOfProject Value="True"/>
|
||||||
|
</Unit0>
|
||||||
|
</Units>
|
||||||
|
</ProjectOptions>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<PathDelim Value="\"/>
|
||||||
|
<Target>
|
||||||
|
<Filename Value="comments_demo_write"/>
|
||||||
|
</Target>
|
||||||
|
<SearchPaths>
|
||||||
|
<IncludeFiles Value="$(ProjOutDir)"/>
|
||||||
|
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
<Linking>
|
||||||
|
<Debugging>
|
||||||
|
<DebugInfoType Value="dsDwarf3"/>
|
||||||
|
</Debugging>
|
||||||
|
</Linking>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Debugging>
|
||||||
|
<Exceptions Count="3">
|
||||||
|
<Item1>
|
||||||
|
<Name Value="EAbort"/>
|
||||||
|
</Item1>
|
||||||
|
<Item2>
|
||||||
|
<Name Value="ECodetoolError"/>
|
||||||
|
</Item2>
|
||||||
|
<Item3>
|
||||||
|
<Name Value="EFOpenError"/>
|
||||||
|
</Item3>
|
||||||
|
</Exceptions>
|
||||||
|
</Debugging>
|
||||||
|
</CONFIG>
|
@ -0,0 +1,31 @@
|
|||||||
|
program comments_demo_write;
|
||||||
|
|
||||||
|
uses
|
||||||
|
fpspreadsheet, fpstypes, fpsallformats;
|
||||||
|
|
||||||
|
const
|
||||||
|
FILE_NAME = 'test';
|
||||||
|
|
||||||
|
var
|
||||||
|
workbook: TsWorkbook;
|
||||||
|
worksheet: TsWorksheet;
|
||||||
|
|
||||||
|
begin
|
||||||
|
workbook := TsWorkbook.Create;
|
||||||
|
try
|
||||||
|
worksheet := workbook.AddWorksheet('Sheet 1');
|
||||||
|
worksheet.WriteText(0, 0, 'Angle');
|
||||||
|
worksheet.WriteNumber(0, 1, 30.0, nfFixed, 1);
|
||||||
|
worksheet.WriteComment(0, 1, 'Enter angle in degrees here.');
|
||||||
|
worksheet.WriteText(1, 0, 'sin(Angle)');
|
||||||
|
worksheet.WriteFormula(1, 1, '=sin(B1*pi()/180)');
|
||||||
|
workbook.WriteToFile(FILE_NAME + '.xlsx', sfOOXML, true);
|
||||||
|
// workbook.WriteToFile(FILE_NAME + '8.xls', sfExcel8, true); // no BIFF8 writing support for comments so far.
|
||||||
|
workbook.WriteToFile(FILE_NAME + '5.xls', sfExcel5, true);
|
||||||
|
workbook.WriteToFile(FILE_NAME + '2.xls', sfExcel2, true);
|
||||||
|
workbook.WriteToFile(FILE_NAME + '.ods', sfOpenDocument, true);
|
||||||
|
finally
|
||||||
|
workbook.Free;
|
||||||
|
end;
|
||||||
|
end.
|
||||||
|
|
Reference in New Issue
Block a user