You've already forked lazarus-ccr
fpspreadsheet: Add WriteBlank to TsSpreadOOXMLWriter to standardize code.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3309 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -63,7 +63,7 @@ begin
|
||||
// writing temporaray data to a file stream instead of a memory stream.
|
||||
// woSaveMemory, however, considerably slows down writing of biff files.
|
||||
|
||||
workbook.VirtualRowCount := 1000;
|
||||
workbook.VirtualRowCount := 10000;
|
||||
workbook.VirtualColCount := 100;
|
||||
// These two numbers define the size of virtual spreadsheet.
|
||||
// In case of a database, VirtualRowCount is the RecordCount, VirtualColCount
|
||||
@ -74,8 +74,8 @@ begin
|
||||
// data to write.
|
||||
|
||||
// In case of a database, you would open the dataset before calling this:
|
||||
// workbook.WriteToFile('test_virtual.xlsx', sfOOXML, true);
|
||||
workbook.WriteToFile('test_virtual.xls', sfExcel5, true);
|
||||
workbook.WriteToFile('test_virtual.xlsx', sfOOXML, true);
|
||||
// workbook.WriteToFile('test_virtual.xls', sfExcel5, true);
|
||||
|
||||
finally
|
||||
workbook.Free;
|
||||
|
@ -2534,9 +2534,9 @@ var
|
||||
lCell: TCell;
|
||||
value: variant;
|
||||
begin
|
||||
FillChar(lCell, SizeOf(lCell), 0);
|
||||
for r := 0 to Workbook.VirtualRowCount-1 do begin
|
||||
for c := 0 to Workbook.VirtualColCount-1 do begin
|
||||
FillChar(lCell, SizeOf(lCell), 0);
|
||||
value := varNull;
|
||||
Workbook.OnNeedCellData(Workbook, r, c, value);
|
||||
lCell.Row := r;
|
||||
|
@ -88,6 +88,7 @@ type
|
||||
protected
|
||||
{ Record writing methods }
|
||||
//todo: add WriteDate
|
||||
procedure WriteBlank(AStream: TStream; const ARow, ACol: Cardinal; ACell: PCell); override;
|
||||
procedure WriteLabel(AStream: TStream; const ARow, ACol: Cardinal; const AValue: string; ACell: PCell); override;
|
||||
procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double; ACell: PCell); override;
|
||||
procedure WriteDateTime(AStream: TStream; const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell); override;
|
||||
@ -354,7 +355,7 @@ procedure TsSpreadOOXMLWriter.WriteWorksheet(CurSheet: TsWorksheet);
|
||||
var
|
||||
r, c: Cardinal;
|
||||
LastColIndex: Cardinal;
|
||||
LCell: TCell;
|
||||
lCell: TCell;
|
||||
AVLNode: TAVLTreeNode;
|
||||
CellPosText: string;
|
||||
value: Variant;
|
||||
@ -391,37 +392,34 @@ begin
|
||||
AppendToStream(FSSheets[FCurSheetNum], Format(
|
||||
'<row r="%d" spans="1:%d">', [r+1, Workbook.VirtualColCount]));
|
||||
for c := 0 to Workbook.VirtualColCount-1 do begin
|
||||
FillChar(lCell, SizeOf(lCell), 0);
|
||||
CellPosText := CurSheet.CellPosToText(r, c);
|
||||
value := varNull;
|
||||
Workbook.OnNeedCellData(Workbook, r, c, value);
|
||||
lCell.Row := r;
|
||||
lCell.Col := c;
|
||||
if VarIsNull(value) then
|
||||
AppendToStream(FSSheets[FCurSheetNum], Format(
|
||||
'<c r="%s"', [CellPosText]),
|
||||
'<v></v>',
|
||||
'</c>')
|
||||
else begin
|
||||
lCell.Row := r;
|
||||
lCell.Col := c;
|
||||
if VarIsNumeric(value) then begin
|
||||
lCell.ContentType := cctNumber;
|
||||
lCell.NumberValue := value;
|
||||
end
|
||||
{
|
||||
else if VarIsDateTime(value) then begin
|
||||
lCell.ContentType := cctNumber;
|
||||
lCell.DateTimeValue := value;
|
||||
end
|
||||
}
|
||||
else if VarIsStr(value) then begin
|
||||
lCell.ContentType := cctUTF8String;
|
||||
lCell.UTF8StringValue := VarToStrDef(value, '');
|
||||
end else
|
||||
if VarIsBool(value) then begin
|
||||
lCell.ContentType := cctBool;
|
||||
lCell.BoolValue := value <> 0;
|
||||
end;
|
||||
WriteCellCallback(@lCell, nil);
|
||||
lCell.ContentType := cctEmpty
|
||||
else
|
||||
if VarIsNumeric(value) then begin
|
||||
lCell.ContentType := cctNumber;
|
||||
lCell.NumberValue := value;
|
||||
end
|
||||
{
|
||||
else if VarIsDateTime(value) then begin
|
||||
lCell.ContentType := cctNumber;
|
||||
lCell.DateTimeValue := value;
|
||||
end
|
||||
}
|
||||
else if VarIsStr(value) then begin
|
||||
lCell.ContentType := cctUTF8String;
|
||||
lCell.UTF8StringValue := VarToStrDef(value, '');
|
||||
end else
|
||||
if VarIsBool(value) then begin
|
||||
lCell.ContentType := cctBool;
|
||||
lCell.BoolValue := value <> 0;
|
||||
end;
|
||||
WriteCellCallback(@lCell, FSSheets[FCurSheetNum]);
|
||||
end;
|
||||
AppendToStream(FSSheets[FCurSheetNum],
|
||||
'</row>');
|
||||
@ -625,6 +623,22 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TsSpreadOOXMLWriter.WriteBlank(AStream: TStream;
|
||||
const ARow, ACol: Cardinal; ACell: PCell);
|
||||
var
|
||||
cellPosText: String;
|
||||
lStyleIndex: Integer;
|
||||
begin
|
||||
cellPosText := TsWorksheet.CellPosToText(ARow, ACol);
|
||||
lStyleIndex := GetStyleIndex(ACell);
|
||||
|
||||
AppendToStream(AStream, Format(
|
||||
'<c r="%s" s="%d">', [CellPosText, lStyleIndex]),
|
||||
'<v></v>',
|
||||
'</c>');
|
||||
end;
|
||||
|
||||
|
||||
{*******************************************************************
|
||||
* TsSpreadOOXMLWriter.WriteLabel ()
|
||||
*
|
||||
@ -664,7 +678,7 @@ begin
|
||||
|
||||
CellPosText := TsWorksheet.CellPosToText(ARow, ACol);
|
||||
lStyleIndex := GetStyleIndex(ACell);
|
||||
AppendToStream(FSSheets[FCurSheetNum], Format(
|
||||
AppendToStream(AStream, Format(
|
||||
'<c r="%s" s="%d" t="s"><v>%d</v></c>', [CellPosText, lStyleIndex, FSharedStringsCount]));
|
||||
Inc(FSharedStringsCount);
|
||||
|
||||
@ -691,7 +705,7 @@ begin
|
||||
Unused(AStream, ACell);
|
||||
CellPosText := TsWorksheet.CellPosToText(ARow, ACol);
|
||||
CellValueText := Format('%g', [AValue], FPointSeparatorSettings);
|
||||
AppendToStream(FSSheets[FCurSheetNum], Format(
|
||||
AppendToStream(AStream, Format(
|
||||
'<c r="%s" s="0" t="n"><v>%s</v></c>', [CellPosText, CellValueText]));
|
||||
end;
|
||||
|
||||
|
Reference in New Issue
Block a user