fpspreadsheet: Fix unit conversion error in colwidth calculation. CopyWorksheetFrom() now copies also DefaultFont and DefaultColWidth

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7529 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-07-08 17:56:08 +00:00
parent 80a3750dbd
commit 9a4f358ae2
2 changed files with 19 additions and 1 deletions

View File

@ -9267,6 +9267,8 @@ var
col: PCol;
row: PRow;
i: Integer;
w: Single;
fnt: TsFont;
begin
Result := nil;
if (AWorksheet = nil) then
@ -9275,18 +9277,34 @@ begin
Result := AddWorksheet(AWorksheet.Name, ReplaceDuplicateName);
inc(FNotificationLock);
try
// Make sure to use the same default font, colwidths depend on it!
if Result.WorkBook <> AWorksheet.Workbook then
begin
fnt := AWorksheet.Workbook.GetDefaultFont;
Result.Workbook.SetDefaultFont(fnt.FontName, fnt.Size);
end;
// Copy DefaultColWidth
w := AWorksheet.ReadDefaultColWidth(suMillimeters);
Result.WriteDefaultColWidth(w, suMillimeters);
// Copy cells (incl formulas, comments, hyperlinks etc).
for cell in AWorksheet.Cells do
begin
r := cell^.Row;
c := cell^.Col;
Result.CopyCell(r, c, r, c, AWorksheet);
end;
// Copy col records
for i := 0 to AWorksheet.Cols.Count-1 do
begin
col := AWorksheet.Cols[i];
c := col^.Col;
Result.CopyCol(c, c, AWorksheet);
end;
// Copy row records
for i := 0 to AWorksheet.Rows.Count-1 do
begin
row := AWorksheet.Rows[i];

View File

@ -422,7 +422,7 @@ begin
if lCol^.ColWidthType = cwtCustom then
w0 := lCol^.Width
else
w0 := sheet.DefaultColWidth;
w0 := sheet.ReadDefaultColWidth(sheet.Workbook.Units);
// w := PCol(sheet.Cols[0])^.Width;
for c := 1 to sheet.Cols.Count-1 do begin
lCol := PCol(sheet.Cols[c]);