fpspreadsheet: Add controls to change number format to the fpsgrid demo program. Also, add the "brush" button to copy a format to another cell.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3049 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-15 22:41:14 +00:00
parent dae7caff9c
commit e21231de03
7 changed files with 1664 additions and 974 deletions

View File

@@ -12,15 +12,12 @@ unit fpsutils;
interface
uses
Classes, SysUtils, StrUtils;
Classes, SysUtils, StrUtils, fpspreadsheet;
// Exported types
type
TsSelectionDirection = (fpsVerticalSelection, fpsHorizontalSelection);
TsRelFlag = (rfRelRow, rfRelCol, rfRelRow2, rfRelCol2);
TsRelFlags = set of TsRelFlag;
const
// Date formatting string for unambiguous date/time display as strings
// Can be used for text output when date/time cell support is not available
@@ -71,6 +68,8 @@ function IsDateFormat(s: String; out IsLong: Boolean): Boolean;
function IsTimeFormat(s: String; out isLong, isAMPM, isInterval: Boolean;
out SecDecimals: Word): Boolean;
function BuildNumFormatString(ANumberFormat: TsNumberFormat; ADecimals: Byte): String;
function SciFloat(AValue: Double; ADecimals: Word): String;
//function TimeIntervalToString(AValue: TDateTime; AFormatStr: String): String;
procedure MakeTimeIntervalMask(Src: String; var Dest: String);
@@ -732,6 +731,31 @@ begin
end;
end;
{ Builds a number format string from the numberformat code and the count of
decimals. }
function BuildNumFormatString(ANumberFormat: TsNumberFormat;
ADecimals: Byte): String;
var
decs: String;
begin
decs := DupeString('0', ADecimals);
if ADecimals > 0 then decs := '.' + decs;
case ANumberFormat of
nfFixed:
Result := '0' + decs;
nfFixedTh:
Result := '#,##0' + decs;
nfExp:
Result := '0' + decs + 'E+00';
nfSci:
Result := '##0' + decs + 'E+0';
nfPercentage:
Result := '0' + decs + '%';
else
Result := '';
end;
end;
{ Formats the number AValue in "scientific" format with the given number of
decimals. "Scientific" is the same as "exponential", but with exponents rounded
to multiples of 3 (like for "kilo" - "Mega" - "Giga" etc.). }