fpspreadsheet: Cells for which the OnWriteCellData event handler returns null are skipped in virtual mode if they don't carry a format.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3603 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-09-24 13:59:51 +00:00
parent 55792a75f9
commit dcbbb0c0a1
3 changed files with 34 additions and 16 deletions

View File

@ -44,6 +44,9 @@ var
// formatting of all virtual cells in row 0.
// Important: The template cell must be an existing cell in the worksheet.
end else
if (ACol = 0) then
AData := NULL // Let's skip the column #0
else
if odd(random(10)) then begin
AData := Format('R=%d-C=%d', [ARow, ACol]);
end else

View File

@ -2869,10 +2869,10 @@ var
lCell: TCell;
value: variant;
styleCell: PCell;
begin
for r := 0 to Workbook.VirtualRowCount-1 do begin
for c := 0 to Workbook.VirtualColCount-1 do begin
for r := 0 to Workbook.VirtualRowCount-1 do
for c := 0 to Workbook.VirtualColCount-1 do
begin
InitCell(lCell);
value := varNull;
styleCell := nil;
@ -2881,21 +2881,29 @@ begin
lCell.Row := r;
lCell.Col := c;
if VarIsNull(value) then
lCell.ContentType := cctEmpty
else
if VarIsNumeric(value) then begin
begin // ignore empty cells that don't have a format
if styleCell <> nil then
lCell.ContentType := cctEmpty
else
Continue;
end else
if VarIsNumeric(value) then
begin
lCell.ContentType := cctNumber;
lCell.NumberValue := value;
end else
if VarType(value) = varDate then begin
if VarType(value) = varDate then
begin
lCell.ContentType := cctDateTime;
lCell.DateTimeValue := StrToDateTime(VarToStr(value), Workbook.FormatSettings);
end else
if VarIsStr(value) then begin
if VarIsStr(value) then
begin
lCell.ContentType := cctUTF8String;
lCell.UTF8StringValue := VarToStrDef(value, '');
end else
if VarIsBool(value) then begin
if VarIsBool(value) then
begin
lCell.ContentType := cctBool;
lCell.BoolValue := value <> 0;
end else
@ -2903,7 +2911,6 @@ begin
WriteCellCallback(@lCell, AStream);
value := varNULL;
end;
end;
end;
{ Writes an Excel 5/8 WINDOW1 record

View File

@ -2010,21 +2010,29 @@ begin
lCell.Row := r;
lCell.Col := c;
if VarIsNull(value) then
lCell.ContentType := cctEmpty
else
if VarIsNumeric(value) then begin
begin
if styleCell <> nil then
lCell.ContentType := cctEmpty
else
Continue;
end else
if VarIsNumeric(value) then
begin
lCell.ContentType := cctNumber;
lCell.NumberValue := value;
end else
if VarType(value) = varDate then begin
if VarType(value) = varDate then
begin
lCell.ContentType := cctDateTime;
lCell.DateTimeValue := StrToDate(VarToStr(value), Workbook.FormatSettings);
end else
if VarIsStr(value) then begin
if VarIsStr(value) then
begin
lCell.ContentType := cctUTF8String;
lCell.UTF8StringValue := VarToStrDef(value, '');
end else
if VarIsBool(value) then begin
if VarIsBool(value) then
begin
lCell.ContentType := cctBool;
lCell.BoolValue := value <> 0;
end;