You've already forked lazarus-ccr
fpspreadsheet: Write row format to xlsx. Update colwidth test case.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5255 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1105,11 +1105,7 @@ begin
|
|||||||
try
|
try
|
||||||
MyWorkSheet:= MyWorkBook.AddWorksheet(ColWidthSheet);
|
MyWorkSheet:= MyWorkBook.AddWorksheet(ColWidthSheet);
|
||||||
for Col := Low(SollColWidths) to High(SollColWidths) do
|
for Col := Low(SollColWidths) to High(SollColWidths) do
|
||||||
begin
|
MyWorksheet.WriteColWidth(Col, SollColWidths[Col], suChars);
|
||||||
lCol.Width := SollColWidths[Col];
|
|
||||||
//MyWorksheet.WriteNumber(0, Col, 1);
|
|
||||||
MyWorksheet.WriteColInfo(Col, lCol);
|
|
||||||
end;
|
|
||||||
if AFormat = sfOpenDocument then
|
if AFormat = sfOpenDocument then
|
||||||
// In ODS empty columns are ignored due to a workaround for a
|
// In ODS empty columns are ignored due to a workaround for a
|
||||||
// LO/OO import error for xlsx files. --> add dummy cells
|
// LO/OO import error for xlsx files. --> add dummy cells
|
||||||
@ -1136,7 +1132,7 @@ begin
|
|||||||
lpCol := MyWorksheet.GetCol(Col);
|
lpCol := MyWorksheet.GetCol(Col);
|
||||||
if lpCol = nil then
|
if lpCol = nil then
|
||||||
fail('Error in test code. Failed to return saved column width');
|
fail('Error in test code. Failed to return saved column width');
|
||||||
ActualColWidth := lpCol^.Width;
|
ActualColWidth := MyWorkbook.ConvertUnits(lpCol^.Width, MyWorkbook.Units, suChars);
|
||||||
if abs(SollColWidths[Col] - ActualColWidth) > 1E-2 then // take rounding errors into account
|
if abs(SollColWidths[Col] - ActualColWidth) > 1E-2 then // take rounding errors into account
|
||||||
CheckEquals(SollColWidths[Col], ActualColWidth,
|
CheckEquals(SollColWidths[Col], ActualColWidth,
|
||||||
'Test saved colwidth mismatch, column '+ColNotation(MyWorkSheet,Col));
|
'Test saved colwidth mismatch, column '+ColNotation(MyWorkSheet,Col));
|
||||||
|
@ -2970,7 +2970,7 @@ var
|
|||||||
lCell: TCell;
|
lCell: TCell;
|
||||||
styleCell: PCell;
|
styleCell: PCell;
|
||||||
cell: PCell;
|
cell: PCell;
|
||||||
rh: String;
|
s: String;
|
||||||
begin
|
begin
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
'<sheetData>');
|
'<sheetData>');
|
||||||
@ -2983,15 +2983,18 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
for r := 0 to r2 do begin
|
for r := 0 to r2 do begin
|
||||||
row := AWorksheet.FindRow(r);
|
row := AWorksheet.FindRow(r);
|
||||||
|
s := '';
|
||||||
if row <> nil then begin
|
if row <> nil then begin
|
||||||
rh := Format(' ht="%.2f"',
|
s := s + Format(' ht="%.2f"',
|
||||||
[FWorkbook.ConvertUnits(row^.Height, FWorkbook.Units, suPoints)],
|
[FWorkbook.ConvertUnits(row^.Height, FWorkbook.Units, suPoints)],
|
||||||
FPointSeparatorSettings);
|
FPointSeparatorSettings);
|
||||||
if row^.RowHeightType = rhtCustom then rh := rh + ' customHeight="1"';
|
if row^.RowHeightType = rhtCustom then
|
||||||
end else
|
s := s + ' customHeight="1"';
|
||||||
rh := '';
|
if row^.FormatIndex > 0 then
|
||||||
|
s := s + Format(' s="%d" customFormat="1"', [row^.FormatIndex]);
|
||||||
|
end;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<row r="%d" spans="1:%d"%s>', [r+1, AWorksheet.VirtualColCount, rh]));
|
'<row r="%d" spans="1:%d"%s>', [r+1, AWorksheet.VirtualColCount, s]));
|
||||||
for c := 0 to c2 do begin
|
for c := 0 to c2 do begin
|
||||||
lCell.Row := r; // to silence a compiler hint
|
lCell.Row := r; // to silence a compiler hint
|
||||||
InitCell(lCell);
|
InitCell(lCell);
|
||||||
@ -3041,24 +3044,28 @@ begin
|
|||||||
begin
|
begin
|
||||||
// The cells need to be written in order, row by row, cell by cell
|
// The cells need to be written in order, row by row, cell by cell
|
||||||
for r := r1 to r2 do begin
|
for r := r1 to r2 do begin
|
||||||
// If the row has a custom height add this value to the <row> specification
|
// If the row has a custom or auto height and/or custom format
|
||||||
|
// then add them to the <row> specification
|
||||||
row := AWorksheet.FindRow(r);
|
row := AWorksheet.FindRow(r);
|
||||||
|
s := '';
|
||||||
if row <> nil then begin
|
if row <> nil then begin
|
||||||
rh := Format(' ht="%.2f"',
|
s := s + Format(' ht="%.2f"',
|
||||||
[FWorkbook.ConvertUnits(row^.Height, FWorkbook.Units, suPoints)],
|
[FWorkbook.ConvertUnits(row^.Height, FWorkbook.Units, suPoints)],
|
||||||
FPointSeparatorSettings);
|
FPointSeparatorSettings);
|
||||||
if row^.RowHeightType = rhtCustom then rh := rh + ' customHeight="1"';
|
if row^.RowHeightType = rhtCustom then
|
||||||
end else
|
s := s + ' customHeight="1"';
|
||||||
rh := '';
|
if row^.FormatIndex > 0 then
|
||||||
|
s := s + Format(' s="%d" customFormat="1"', [row^.FormatIndex]);
|
||||||
|
end;
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<row r="%d" spans="%d:%d"%s>', [r+1, c1+1, c2+1, rh]));
|
'<row r="%d" spans="%d:%d"%s>', [r+1, c1+1, c2+1, s]));
|
||||||
|
|
||||||
// Write cells belonging to this row.
|
// Write cells belonging to this row.
|
||||||
{ // Strange: the RowEnumerator is very slow here... ?!
|
{
|
||||||
|
// Strange: the RowEnumerator is very slow here... ?!
|
||||||
for cell in AWorksheet.Cells.GetRowEnumerator(r) do
|
for cell in AWorksheet.Cells.GetRowEnumerator(r) do
|
||||||
WriteCellToStream(AStream, cell);
|
WriteCellToStream(AStream, cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
for c := c1 to c2 do begin
|
for c := c1 to c2 do begin
|
||||||
cell := AWorksheet.FindCell(r, c);
|
cell := AWorksheet.FindCell(r, c);
|
||||||
if Assigned(cell) then
|
if Assigned(cell) then
|
||||||
|
Reference in New Issue
Block a user