fpspreadsheet: clean up examples: progress messages; remove win32 gui for console applications etc

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3362 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
bigchimp
2014-07-23 10:47:38 +00:00
parent 243d3b0c7d
commit 40e2a85bd1
7 changed files with 48 additions and 46 deletions

View File

@ -38,11 +38,6 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
</Item2>
@ -65,6 +60,7 @@
<Unit0>
<Filename Value="test_formula_func.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="test_formula_func"/>
</Unit0>
<Unit1>
<Filename Value="financemath.pas"/>

View File

@ -1,8 +1,8 @@
{ This demo show how user-provided functions can be used for calculation of
rpn formulas that are built-in to fpspreadsheet, but don't have an own
{ This demo shows how user-provided functions can be used for calculation of
RPN formulas that are built-in to fpspreadsheet, but don't have their own
calculation procedure.
The example will show implementation of the some financial formulas:
The example will show implementation of some financial formulas:
- FV() (future value)
- PV() (present value)
- PMT() (payment)
@ -19,12 +19,13 @@ program test_formula_func;
{$mode delphi}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
{$IFDEF UNIX}
{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, laz_fpspreadsheet
{ you can add units after this },
math, fpspreadsheet, xlsbiff8, fpsfunc, financemath;
{$ENDIF}
{$ENDIF}
Classes, SysUtils,
math, laz_fpspreadsheet, fpspreadsheet, xlsbiff8, fpsfunc, financemath;
{------------------------------------------------------------------------------}
@ -65,6 +66,7 @@ begin
end;
function fpsPV(Args: TsArgumentStack; NumArgs: Integer): TsArgument;
// Present value
var
data: TsArgNumberArray;
begin
@ -121,7 +123,6 @@ var
workbook: TsWorkbook;
worksheet: TsWorksheet;
fval, pval, pmtval, nperval, rateval: Double;
begin
{ We have to register our financial functions in fpspreadsheet. Otherwise an
error code would be displayed in the reading part of this demo for these
@ -326,7 +327,8 @@ begin
WriteLn('Contents of file "', AFileName, '"');
WriteLn('');
for r := 0 to worksheet.GetLastRowIndex do begin
for r := 0 to worksheet.GetLastRowIndex do
begin
s1 := UTF8ToAnsi(worksheet.ReadAsUTF8Text(r, 0));
s2 := UTF8ToAnsi(worksheet.ReadAsUTF8Text(r, 1));
if s1 = '' then
@ -346,10 +348,11 @@ begin
end;
end;
const
TestFile='test_fv.xls';
begin
WriteFile('test_fv.xls');
ReadFile('test_fv.xls');
WriteFile(TestFile);
ReadFile(TestFile);
end.

View File

@ -38,11 +38,6 @@
<StripSymbols Value="True"/>
</Debugging>
<LinkSmart Value="True"/>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
</Item2>
@ -64,6 +59,7 @@
<Unit0>
<Filename Value="test_recursive_calc.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="test_recursive_calc"/>
</Unit0>
</Units>
</ProjectOptions>
@ -78,13 +74,6 @@
<OptimizationLevel Value="0"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">

View File

@ -9,18 +9,21 @@ program test_recursive_calc;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
{$IFDEF UNIX}
{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, laz_fpspreadsheet
{ you can add units after this },
math, fpspreadsheet, fpsfunc;
{$ENDIF}
{$ENDIF}
Classes,
math, laz_fpspreadsheet, fpspreadsheet, fpsfunc;
var
workbook: TsWorkbook;
worksheet: TsWorksheet;
const
OutputFile='test_calc.xls';
begin
writeln('Starting program.');
workbook := TsWorkbook.Create;
try
worksheet := workbook.AddWorksheet('Calc_test');
@ -48,7 +51,8 @@ begin
// B3
worksheet.WriteNumber(2, 1, 1);
workbook.WriteToFile('test_calc.xls', sfExcel8, true);
workbook.WriteToFile(OutputFile, sfExcel8, true);
writeln('Finished. Please open "'+OutputFile+'" in your spreadsheet program.');
finally
workbook.Free;
end;

View File

@ -3,12 +3,14 @@ program test_virtualmode;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
{$IFDEF UNIX}
{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, laz_fpspreadsheet,
{ you can add units after this } lazutf8,
SysUtils, variants, fpspreadsheet, xlsbiff2, xlsbiff5, xlsbiff8, xlsxooxml;
{$ENDIF}
{$ENDIF}
Classes, SysUtils,
lazutf8,
variants, laz_fpspreadsheet, fpspreadsheet, xlsbiff2, xlsbiff5, xlsbiff8, xlsxooxml;
type
TDataProvider = class

View File

@ -159,7 +159,10 @@ begin
MyCell^.UsedFormattingFields := [uffBorder, uffBackgroundColor];
end;
const
TestFile='test3.odt';
begin
writeln('Starting program.');
MyDir := ExtractFilePath(ParamStr(0));
// Create the spreadsheet
@ -171,7 +174,8 @@ begin
// Save the spreadsheet to a file
// MyWorkbook.WriteToFile(MyDir + 'test3.xls', sfExcel8, False);
MyWorkbook.WriteToFile(MyDir + 'test3.odt', sfOpenDocument, False);
MyWorkbook.WriteToFile(MyDir + TestFile, sfOpenDocument, False);
MyWorkbook.Free;
writeln('Finished. Please open "'+TestFile+'" in your spreadsheet program.');
end.

View File

@ -1,7 +1,7 @@
{
test_write_formula.pas
Demonstrates how to write an formula using the fpspreadsheet library
Demonstrates how to write a formula using the fpspreadsheet library
AUTHORS: Felipe Monteiro de Carvalho
}
@ -84,7 +84,10 @@ begin
MyCell^.UsedFormattingFields := [uffBorder, uffBackgroundColor, uffBold];}
end;
const
TestFile='test_formula.xls';
begin
writeln('Starting program.');
MyDir := ExtractFilePath(ParamStr(0));
// Create the spreadsheet
@ -95,8 +98,9 @@ begin
WriteSecondWorksheet();
// Save the spreadsheet to a file
MyWorkbook.WriteToFile(MyDir + 'test_formula.xls', sfExcel8, True);
MyWorkbook.WriteToFile(MyDir + TestFile, sfExcel8, True);
// MyWorkbook.WriteToFile(MyDir + 'test_formula.odt', sfOpenDocument, False);
MyWorkbook.Free;
writeln('Finished. Please open "'+Testfile+'" in your spreadsheet program.');
end.