You've already forked lazarus-ccr
fpspreadsheet: Avoid merging a newly loaded workbook with previous content and formats.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6519 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -702,6 +702,8 @@ type
|
|||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
procedure Clear;
|
||||||
|
|
||||||
procedure ReadFromFile(AFileName: string; AFormatID: TsSpreadFormatID;
|
procedure ReadFromFile(AFileName: string; AFormatID: TsSpreadFormatID;
|
||||||
APassword: String = ''; AParams: TsStreamParams = []); overload;
|
APassword: String = ''; AParams: TsStreamParams = []); overload;
|
||||||
procedure ReadFromFile(AFileName: string; AFormat: TsSpreadsheetFormat;
|
procedure ReadFromFile(AFileName: string; AFormat: TsSpreadsheetFormat;
|
||||||
@@ -761,6 +763,7 @@ type
|
|||||||
function GetCellFormatAsString(AIndex: Integer): String;
|
function GetCellFormatAsString(AIndex: Integer): String;
|
||||||
function GetNumCellFormats: Integer;
|
function GetNumCellFormats: Integer;
|
||||||
function GetPointerToCellFormat(AIndex: Integer): PsCellFormat;
|
function GetPointerToCellFormat(AIndex: Integer): PsCellFormat;
|
||||||
|
procedure RemoveAllCellFormats(AKeepDefaultFormat: Boolean);
|
||||||
|
|
||||||
{ Font handling }
|
{ Font handling }
|
||||||
function AddFont(const AFontName: String; ASize: Single; AStyle: TsFontStyles;
|
function AddFont(const AFontName: String; ASize: Single; AStyle: TsFontStyles;
|
||||||
@@ -787,6 +790,7 @@ type
|
|||||||
function AddNumberFormat(AFormatStr: String): Integer;
|
function AddNumberFormat(AFormatStr: String): Integer;
|
||||||
function GetNumberFormat(AIndex: Integer): TsNumFormatParams;
|
function GetNumberFormat(AIndex: Integer): TsNumFormatParams;
|
||||||
function GetNumberFormatCount: Integer;
|
function GetNumberFormatCount: Integer;
|
||||||
|
procedure RemoveAllNumberFormats;
|
||||||
|
|
||||||
{ Formulas }
|
{ Formulas }
|
||||||
procedure CalcFormulas;
|
procedure CalcFormulas;
|
||||||
@@ -7988,11 +7992,7 @@ end;
|
|||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsWorkbook.PrepareBeforeReading;
|
procedure TsWorkbook.PrepareBeforeReading;
|
||||||
begin
|
begin
|
||||||
// Initializes fonts
|
Clear;
|
||||||
InitFonts;
|
|
||||||
|
|
||||||
// Clear error log
|
|
||||||
ClearErrorList;
|
|
||||||
|
|
||||||
// Abort if virtual mode is active without an event handler
|
// Abort if virtual mode is active without an event handler
|
||||||
if (boVirtualMode in FOptions) and not Assigned(OnReadCellData) then
|
if (boVirtualMode in FOptions) and not Assigned(OnReadCellData) then
|
||||||
@@ -8202,6 +8202,34 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Clears content and formats from the workbook
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsWorkbook.Clear;
|
||||||
|
begin
|
||||||
|
// Initialize fonts
|
||||||
|
InitFonts;
|
||||||
|
|
||||||
|
// Remove already existing worksheets.
|
||||||
|
RemoveAllWorksheets;
|
||||||
|
|
||||||
|
// Remove all cell formats, but keep the default format
|
||||||
|
RemoveAllCellFormats(true);
|
||||||
|
|
||||||
|
// Remove all number formats
|
||||||
|
RemoveAllNumberFormats;
|
||||||
|
|
||||||
|
// Remove embedded images
|
||||||
|
RemoveAllEmbeddedObj;
|
||||||
|
|
||||||
|
// Reset cryptoinfo
|
||||||
|
InitCryptoInfo(FCryptoInfo);
|
||||||
|
|
||||||
|
// Clear error log
|
||||||
|
ClearErrorList;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Helper method for determining the spreadsheet type. Read the first few bytes
|
Helper method for determining the spreadsheet type. Read the first few bytes
|
||||||
of a file and determines the spreadsheet type from the characteristic
|
of a file and determines the spreadsheet type from the characteristic
|
||||||
@@ -9309,6 +9337,25 @@ begin
|
|||||||
Result := FCellFormatList.Items[AIndex];
|
Result := FCellFormatList.Items[AIndex];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Removes all cell formats from the workbook.
|
||||||
|
|
||||||
|
If AKeepDefaultFormat is true then index 0 containing the default cell format
|
||||||
|
is retained.
|
||||||
|
|
||||||
|
Use carefully!
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsWorkbook.RemoveAllCellFormats(AKeepDefaultFormat: Boolean);
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if AKeepDefaultFormat then
|
||||||
|
for i := FCellFormatList.Count-1 downto 1 do
|
||||||
|
FCellFormatList.Delete(i)
|
||||||
|
else
|
||||||
|
FCellFormatList.Clear;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ Font handling }
|
{ Font handling }
|
||||||
|
|
||||||
@@ -9593,6 +9640,22 @@ begin
|
|||||||
Result := FNumFormatList.Count;
|
Result := FNumFormatList.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{@@ ----------------------------------------------------------------------------
|
||||||
|
Removes all numberformats
|
||||||
|
Use carefully!
|
||||||
|
-------------------------------------------------------------------------------}
|
||||||
|
procedure TsWorkbook.RemoveAllNumberFormats;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
nfp: TsNumFormatParams;
|
||||||
|
begin
|
||||||
|
for i:= FEmbeddedObjList.Count-1 downto 0 do begin
|
||||||
|
nfp := TsNumFormatParams(FNumFormatList[i]);
|
||||||
|
FNumFormatList.Delete(i);
|
||||||
|
nfp.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{@@ ----------------------------------------------------------------------------
|
{@@ ----------------------------------------------------------------------------
|
||||||
Calculates all formulas of the workbook.
|
Calculates all formulas of the workbook.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user