fpspreadsheet: Overload methods FindCell and GetCell to TsWorksheet to accept an Excel "A1" address string. Update chm help file.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3269 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-07-02 19:38:21 +00:00
parent 8a41c46316
commit 4bd85f70fd
3 changed files with 50 additions and 15 deletions

View File

@ -603,8 +603,10 @@ type
procedure CopyCell(AFromRow, AFromCol, AToRow, AToCol: Cardinal; AFromWorksheet: TsWorksheet); procedure CopyCell(AFromRow, AFromCol, AToRow, AToCol: Cardinal; AFromWorksheet: TsWorksheet);
procedure CopyFormat(AFormat: PCell; AToRow, AToCol: Cardinal); overload; procedure CopyFormat(AFormat: PCell; AToRow, AToCol: Cardinal); overload;
procedure CopyFormat(AFromCell, AToCell: PCell); overload; procedure CopyFormat(AFromCell, AToCell: PCell); overload;
function FindCell(ARow, ACol: Cardinal): PCell; function FindCell(ARow, ACol: Cardinal): PCell; overload;
function GetCell(ARow, ACol: Cardinal): PCell; function FindCell(AddressStr: String): PCell; overload;
function GetCell(ARow, ACol: Cardinal): PCell; overload;
function GetCell(AddressStr: String): PCell; overload;
function GetCellCount: Cardinal; function GetCellCount: Cardinal;
function GetFirstCell(): PCell; function GetFirstCell(): PCell;
function GetNextCell(): PCell; function GetNextCell(): PCell;
@ -1615,8 +1617,7 @@ begin
end; end;
{@@ {@@
Tries to locate a Cell in the list of already Tries to locate a Cell in the list of already written Cells
written Cells
@param ARow The row of the cell @param ARow The row of the cell
@param ACol The column of the cell @param ACol The column of the cell
@ -1637,20 +1638,35 @@ begin
result := PCell(AVLNode.Data); result := PCell(AVLNode.Data);
end; end;
{@@
Tries to locate a Cell in the list of already written Cells
@param AddressStr Address of the cell in Excel A1 notation
@return Pointer to the cell if found, or nil if not found
@see TCell
}
function TsWorksheet.FindCell(AddressStr: String): PCell;
var
r, c: Cardinal;
begin
if ParseCellString(AddressStr, r, c) then
Result := FindCell(r, c)
else
Result := nil;
end;
{@@ {@@
Obtains an allocated cell at the desired location. Obtains an allocated cell at the desired location.
If the Cell already exists, a pointer to it will If the Cell already exists, a pointer to it will be returned.
be returned.
If not, then new memory for the cell will be allocated, If not, then new memory for the cell will be allocated, a pointer to it
a pointer to it will be returned and it will be added will be returned and it will be added to the list of cells.
to the list of cells.
@param ARow Row index of the cell @param ARow Row index of the cell
@param ACol Column index of the cell @param ACol Column index of the cell
@return A pointer to the Cell on the desired location. @return A pointer to the cell at the desired location.
@see TCell @see TCell
} }
@ -1672,6 +1688,30 @@ begin
end; end;
end; end;
{@@
Obtains an allocated cell at the desired location.
If the Cell already exists, a pointer to it will be returned.
If not, then new memory for the cell will be allocated, a pointer to it
will be returned and it will be added to the list of cells.
@param AddressStr Address of the cell in Excel A1 notation (an exception is
raised in case on an invalid cell address).
@return A pointer to the cell at the desired location.
@see TCell
}
function TsWorksheet.GetCell(AddressStr: String): PCell;
var
r, c: Cardinal;
begin
if ParseCellString(AddressStr, r, c) then
Result := GetCell(r, c)
else
raise Exception.CreateFmt(lpNoValidCellAddress, [AddressStr]);
end;
{@@ {@@
Returns the number of cells in the worksheet with contents. Returns the number of cells in the worksheet with contents.

View File

@ -2034,13 +2034,8 @@ procedure TsSpreadBIFFWriter.WriteRPNFormula(AStream: TStream;
const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell); const ARow, ACol: Cardinal; const AFormula: TsRPNFormula; ACell: PCell);
var var
i: Integer; i: Integer;
len: Integer;
RPNLength: Word; RPNLength: Word;
RecordSizePos, FinalPos: Int64; RecordSizePos, FinalPos: Int64;
// TokenID: Word;
// lSecondaryID: Word;
// c: Cardinal;
wideStr: WideString;
begin begin
{ BIFF Record header } { BIFF Record header }
AStream.WriteWord(WordToLE(INT_EXCEL_ID_FORMULA)); AStream.WriteWord(WordToLE(INT_EXCEL_ID_FORMULA));