You've already forked lazarus-ccr
fpspreadsheet: Ignore the million of ods filler rows added by LibreOffice to Excel files - see memory overflow reported in http://forum.lazarus.freepascal.org/index.php/topic,34464.0.html)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5268 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -3338,6 +3338,12 @@ var
|
|||||||
s: String;
|
s: String;
|
||||||
colsSpanned, rowsSpanned: Integer;
|
colsSpanned, rowsSpanned: Integer;
|
||||||
begin
|
begin
|
||||||
|
// Workaround for Excel files converted to ods by Calc: These files are
|
||||||
|
// expanded to fill the entire max worksheet. They also have single empty
|
||||||
|
// cell in the outermost cells --> don't write anything here to prevent this.
|
||||||
|
if (ARow > FLimitations.MaxRowCount - 10) or (ACol > FLimitations.MaxColCount - 10) then
|
||||||
|
exit;
|
||||||
|
|
||||||
// select this cell value's type
|
// select this cell value's type
|
||||||
paramValueType := GetAttrValue(ANode, 'office:value-type');
|
paramValueType := GetAttrValue(ANode, 'office:value-type');
|
||||||
paramFormula := GetAttrValue(ANode, 'table:formula');
|
paramFormula := GetAttrValue(ANode, 'table:formula');
|
||||||
@ -3412,7 +3418,7 @@ end;
|
|||||||
procedure TsSpreadOpenDocReader.ReadRowsAndCells(ATableNode: TDOMNode);
|
procedure TsSpreadOpenDocReader.ReadRowsAndCells(ATableNode: TDOMNode);
|
||||||
var
|
var
|
||||||
row: Integer;
|
row: Integer;
|
||||||
rowNode, childnode: TDOMNode;
|
rNode, childnode: TDOMNode;
|
||||||
nodeName: String;
|
nodeName: String;
|
||||||
rowsRepeated: Integer;
|
rowsRepeated: Integer;
|
||||||
colFmt: array of Integer;
|
colFmt: array of Integer;
|
||||||
@ -3478,7 +3484,8 @@ var
|
|||||||
// If all cell styles in the row are the same then hasRowFormat is true
|
// If all cell styles in the row are the same then hasRowFormat is true
|
||||||
// and we can store the format of the first cell in the row record.
|
// and we can store the format of the first cell in the row record.
|
||||||
if GetRowFormat and hasRowFormat and
|
if GetRowFormat and hasRowFormat and
|
||||||
(col + colsRepeated >= LongInt(FLimitations.MaxColCount) - 10) then
|
(col + colsRepeated >= LongInt(FLimitations.MaxColCount) - 10) and
|
||||||
|
(row < FLimitations.MaxRowCount - 10) then
|
||||||
begin
|
begin
|
||||||
lRow := FWorksheet.GetRow(row);
|
lRow := FWorksheet.GetRow(row);
|
||||||
// Find first cell in row, all cells have the same format here.
|
// Find first cell in row, all cells have the same format here.
|
||||||
@ -3523,7 +3530,7 @@ var
|
|||||||
cellNode := cellNode.NextSibling;
|
cellNode := cellNode.NextSibling;
|
||||||
end; //while Assigned(cellNode)
|
end; //while Assigned(cellNode)
|
||||||
|
|
||||||
s := GetAttrValue(RowNode, 'table:number-rows-repeated');
|
s := GetAttrValue(ARowNode, 'table:number-rows-repeated');
|
||||||
if s = '' then
|
if s = '' then
|
||||||
rowsRepeated := 1
|
rowsRepeated := 1
|
||||||
else
|
else
|
||||||
@ -3580,10 +3587,10 @@ begin
|
|||||||
isFirstRow := true;
|
isFirstRow := true;
|
||||||
PrintRowMode := false;
|
PrintRowMode := false;
|
||||||
|
|
||||||
rownode := ATableNode.FirstChild;
|
rnode := ATableNode.FirstChild;
|
||||||
while Assigned(rowNode) do
|
while Assigned(rNode) do
|
||||||
begin
|
begin
|
||||||
nodename := rowNode.NodeName;
|
nodename := rNode.NodeName;
|
||||||
|
|
||||||
// Repeated print rows
|
// Repeated print rows
|
||||||
if nodeName = 'table:table-header-rows' then
|
if nodeName = 'table:table-header-rows' then
|
||||||
@ -3591,7 +3598,7 @@ begin
|
|||||||
PrintRowMode := true;
|
PrintRowMode := true;
|
||||||
if FRepeatedRows.FirstIndex = Cardinal(UNASSIGNED_ROW_COL_INDEX) then
|
if FRepeatedRows.FirstIndex = Cardinal(UNASSIGNED_ROW_COL_INDEX) then
|
||||||
FRepeatedRows.FirstIndex := row;
|
FRepeatedRows.FirstIndex := row;
|
||||||
childnode := rowNode.FirstChild;
|
childnode := rNode.FirstChild;
|
||||||
while Assigned(childnode) do
|
while Assigned(childnode) do
|
||||||
begin
|
begin
|
||||||
nodename := childnode.NodeName;
|
nodename := childnode.NodeName;
|
||||||
@ -3606,9 +3613,9 @@ begin
|
|||||||
else
|
else
|
||||||
// "normal" rows
|
// "normal" rows
|
||||||
if nodeName = 'table:table-row' then
|
if nodeName = 'table:table-row' then
|
||||||
ProcessRow(rowNode, true);
|
ProcessRow(rNode, true);
|
||||||
|
|
||||||
rowNode := rowNode.NextSibling;
|
rNode := rNode.NextSibling;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Construct column records with column format
|
// Construct column records with column format
|
||||||
|
@ -4473,6 +4473,8 @@ end;
|
|||||||
initial column widths and row heights.
|
initial column widths and row heights.
|
||||||
-------------------------------------------------------------------------------}
|
-------------------------------------------------------------------------------}
|
||||||
procedure TsCustomWorksheetGrid.Setup;
|
procedure TsCustomWorksheetGrid.Setup;
|
||||||
|
var
|
||||||
|
nc, nr: Integer;
|
||||||
begin
|
begin
|
||||||
if csLoading in ComponentState then
|
if csLoading in ComponentState then
|
||||||
exit;
|
exit;
|
||||||
@ -4495,6 +4497,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
if Worksheet <> nil then begin
|
if Worksheet <> nil then begin
|
||||||
|
nc := ColCount;
|
||||||
|
nr := RowCount;
|
||||||
if FHeaderCount = 0 then
|
if FHeaderCount = 0 then
|
||||||
begin
|
begin
|
||||||
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex), ColCount-1);
|
ColCount := Max(GetGridCol(Worksheet.GetLastColIndex), ColCount-1);
|
||||||
@ -4811,7 +4815,7 @@ begin
|
|||||||
if Worksheet <> nil then
|
if Worksheet <> nil then
|
||||||
begin
|
begin
|
||||||
lCol := Worksheet.FindCol(i - FHeaderCount);
|
lCol := Worksheet.FindCol(i - FHeaderCount);
|
||||||
if lCol <> nil then
|
if (lCol <> nil) and (lCol^.ColWidthType = cwtCustom) then
|
||||||
w100 := CalcColWidthFromSheet(lCol^.Width)
|
w100 := CalcColWidthFromSheet(lCol^.Width)
|
||||||
else
|
else
|
||||||
w100 := CalcColWidthFromSheet(Worksheet.ReadDefaultColWidth(Workbook.Units));
|
w100 := CalcColWidthFromSheet(Worksheet.ReadDefaultColWidth(Workbook.Units));
|
||||||
|
Reference in New Issue
Block a user