You've already forked lazarus-ccr
fpspreadsheet: OOXML writes diagonal border lines.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3402 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1105,51 +1105,39 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TsSpreadOOXMLWriter.WriteBorderList(AStream: TStream);
|
procedure TsSpreadOOXMLWriter.WriteBorderList(AStream: TStream);
|
||||||
|
const
|
||||||
|
LINESTYLE_NAME: Array[TsLineStyle] of String = (
|
||||||
|
'thin', 'medium', 'dashed', 'dotted', 'thick', 'double', 'hair');
|
||||||
|
|
||||||
procedure WriteBorderStyle(AStream: TStream; ACell: PCell; ABorder: TsCellBorder);
|
procedure WriteBorderStyle(AStream: TStream; ACell: PCell; ABorder: TsCellBorder;
|
||||||
|
ABorderName: String);
|
||||||
{ border names found in xlsx files for Excel selections:
|
{ border names found in xlsx files for Excel selections:
|
||||||
"thin", "hair", "dotted", "dashed", "dashDotDot", "dashDot", "mediumDashDotDot",
|
"thin", "hair", "dotted", "dashed", "dashDotDot", "dashDot", "mediumDashDotDot",
|
||||||
"slantDashDot", "mediumDashDot", "mediumDashed", "medium", "thick", "double" }
|
"slantDashDot", "mediumDashDot", "mediumDashed", "medium", "thick", "double" }
|
||||||
var
|
var
|
||||||
borderName: String;
|
|
||||||
styleName: String;
|
styleName: String;
|
||||||
colorName: String;
|
colorName: String;
|
||||||
rgb: TsColorValue;
|
rgb: TsColorValue;
|
||||||
begin
|
begin
|
||||||
// Border line location
|
|
||||||
case ABorder of
|
|
||||||
cbWest : borderName := 'left';
|
|
||||||
cbEast : borderName := 'right';
|
|
||||||
cbNorth : borderName := 'top';
|
|
||||||
cbSouth : borderName := 'bottom';
|
|
||||||
end;
|
|
||||||
if (ABorder in ACell^.Border) then begin
|
if (ABorder in ACell^.Border) then begin
|
||||||
// Line style
|
// Line style
|
||||||
case ACell.BorderStyles[ABorder].LineStyle of
|
styleName := LINESTYLE_NAME[ACell.BorderStyles[ABorder].LineStyle];
|
||||||
lsThin : styleName := 'thin';
|
|
||||||
lsMedium : styleName := 'medium';
|
|
||||||
lsDashed : styleName := 'dashed';
|
|
||||||
lsDotted : styleName := 'dotted';
|
|
||||||
lsThick : styleName := 'thick';
|
|
||||||
lsDouble : styleName := 'double';
|
|
||||||
lsHair : styleName := 'hair';
|
|
||||||
else raise Exception.Create('TsOOXMLWriter.WriteBorderList: LineStyle not supported.');
|
|
||||||
end;
|
|
||||||
// Border color
|
// Border color
|
||||||
rgb := Workbook.GetPaletteColor(ACell^.BorderStyles[ABorder].Color);
|
rgb := Workbook.GetPaletteColor(ACell^.BorderStyles[ABorder].Color);
|
||||||
colorName := Copy(ColorToHTMLColorStr(rgb), 2, 255);
|
colorName := ColorToHTMLColorStr(rgb, true);
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<%s style="%s"><color rgb="%s" /></%s>',
|
'<%s style="%s"><color rgb="%s" /></%s>',
|
||||||
[borderName, styleName, colorName, borderName]
|
[ABorderName, styleName, colorName, ABorderName]
|
||||||
));
|
));
|
||||||
end else
|
end else
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<%s />', [borderName]));
|
'<%s />', [ABorderName]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
styleCell: PCell;
|
styleCell: PCell;
|
||||||
|
diag: String;
|
||||||
begin
|
begin
|
||||||
AppendToStream(AStream, Format(
|
AppendToStream(AStream, Format(
|
||||||
'<borders count="%d">', [Length(FBorderList)]));
|
'<borders count="%d">', [Length(FBorderList)]));
|
||||||
@ -1162,14 +1150,19 @@ begin
|
|||||||
|
|
||||||
for i:=1 to High(FBorderList) do begin
|
for i:=1 to High(FBorderList) do begin
|
||||||
styleCell := FBorderList[i];
|
styleCell := FBorderList[i];
|
||||||
|
diag := '';
|
||||||
|
if (cbDiagUp in FBorderList[i].Border) then diag := diag + ' diagonalUp="1"';
|
||||||
|
if (cbDiagDown in FBorderList[i].Border) then diag := diag + ' diagonalDown="1"';
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
'<border>');
|
'<border' + diag + '>');
|
||||||
WriteBorderStyle(AStream, styleCell, cbWest);
|
WriteBorderStyle(AStream, styleCell, cbWest, 'left');
|
||||||
WriteBorderStyle(AStream, styleCell, cbEast);
|
WriteBorderStyle(AStream, styleCell, cbEast, 'right');
|
||||||
WriteBorderStyle(AStream, styleCell, cbNorth);
|
WriteBorderStyle(AStream, styleCell, cbNorth, 'top');
|
||||||
WriteBorderStyle(AStream, styleCell, cbSouth);
|
WriteBorderStyle(AStream, styleCell, cbSouth, 'bottom');
|
||||||
|
// OOXML uses the same border style for both diagonals. In agreement with
|
||||||
|
// the biff implementation we select the style from the diagonal-up line.
|
||||||
|
WriteBorderStyle(AStream, styleCell, cbDiagUp, 'diagonal');
|
||||||
AppendToStream(AStream,
|
AppendToStream(AStream,
|
||||||
'<diagonal />',
|
|
||||||
'</border>');
|
'</border>');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user