Hyperlink support on a
TXLSXWorksheet의 하이퍼링크 지원. 각 항목은 단일 셀을 외부 URL에 연결합니다. SaveAs는 워크시트의
<hyperlinks> 블록과 일치하는
xl/worksheets/_rels/sheetN.xml.rels 파일을 방출합니다. Open은 관계 대상을 다시 컬렉션으로 해석합니다.
lxHandleXTXLSXHyperlink 선언
type
TXLSXHyperlink = class
constructor Create(ARow, ACol: Integer; const AUrl, ADisplay, ATooltip: WideString);
function IsInternal: Boolean; // True when Location is set and Url is empty
property Row: Integer;
property Col: Integer;
property Url: WideString; // External URL (mutually exclusive with Location)
property Location: WideString; // Internal anchor, e.g. "Sheet2!A1"
property Display: WideString;
property Tooltip: WideString;
end;
TXLSXHyperlink 멤버
| Row, Col | 1-기반 셀 anchor coordinates |
| Url | External URL. Written 로 sheetN.xml.rels
사용 TargetMode="External" |
| Display | Optional display 텍스트 shown 통해 Excel 에서 place 의
URL. Maps 로 display attribute on
<hyperlink> |
| Tooltip | Optional tooltip shown 때 user hovers
셀. Maps 로 tooltip attribute on
<hyperlink> |
TXLSXHyperlinks 선언
type
TXLSXHyperlinks = class
constructor Create;
destructor Destroy; override;
function Add(ARow, ACol: Integer; const AUrl: WideString): Integer; overload;
function Add(ARow, ACol: Integer; const AUrl, ADisplay: WideString): Integer; overload;
function Add(ARow, ACol: Integer; const AUrl, ADisplay, ATooltip: WideString): Integer; overload;
// Internal hyperlink — Location overload. No rels relationship.
function AddInternal(ARow, ACol: Integer; const ALocation, ADisplay, ATooltip: WideString): Integer;
function IndexOfCell(ARow, ACol: Integer): Integer;
function FindAt(ARow, ACol: Integer): TXLSXHyperlink;
function DeleteAt(ARow, ACol: Integer): Boolean;
function DeleteInRange(ARow1, ACol1, ARow2, ACol2: Integer): Integer;
procedure Delete(Index: Integer);
procedure Clear;
property Count: Integer;
property Items[Index: Integer]: TXLSXHyperlink; default;
end;
TXLSXHyperlinks 멤버
| Add(Row, Col, Url) | URL만 포함된 하이퍼링크를 추가합니다 새 항목 인덱스를 반환합니다 |
| Add(Row, Col, Url, Display) | 명시적인 표시 텍스트가 포함된 하이퍼링크를 추가합니다 |
| Add(Row, Col, Url, Display, Tooltip) | 표시 텍스트와 툴팁이 모두 포함된 하이퍼링크를 추가합니다 |
| AddInternal(Row, Col, Location, Display, Tooltip) | 내부 앵커 하이퍼링크를 추가합니다 Workbook의 다른 위치인 Sheet!Cell 위치로 이동합니다 예를 들어 "Sheet2!A1" 입니다 별도의 worksheet rels 관계는 생성되지 않으며, <hyperlink> 요소가 inline location 속성을 포함합니다 일반적인 바로 가기는 Worksheet.AddHyperlinkToCell(...)을 사용하세요
Sheet!Cell IndexOfCell(Row, Col)
"Sheet2!A1") 통합 문서의 다른 곳에 있는 경우입니다. 워크시트
rels 관계는 생성되지 않으며, 다음 <hyperlink>
element carries an inline location attribute. Use
Worksheet.AddHyperlinkToCell(...) 1부터 시작하는 셀 좌표에 고정된 하이퍼링크의 0부터 시작하는 인덱스를 반환하며 셀에 하이퍼링크가 없으면 -1을 반환합니다 |
| IndexOfCell(Row, Col) | 셀에 고정된 하이퍼링크 객체를 반환하며 하이퍼링크가 없으면 nil을 반환합니다 -1 셀에 하이퍼링크가 없는 경우입니다 |
| FindAt(Row, Col) | 해당 셀에 앵커된 하이퍼링크 개체를 반환하거나
다음을 반환합니다 nil when no hyperlink is present |
| DeleteAt(Row, Col) | 해당 셀에 앵커된 하이퍼링크를 삭제하고
다음을 반환합니다 True; returns False 셀에 고정된 hyperlink를 삭제하고 True를 반환합니다 일치하는 hyperlink가 없으면 False를 반환합니다 |
| DeleteInRange(Row1, Col1, Row2, Col2) | 앵커가 포함된 inclusive 1부터 시작하는 셀 범위 안의 모든 hyperlink를 삭제하고 제거한 개수를 반환합니다 반전된 좌표도 허용됩니다 |
| Delete(Index) | 지정한 0부터 시작하는 컬렉션 인덱스의 하이퍼링크를 삭제합니다 |
| Count | 워크시트의 하이퍼링크 수입니다 |
| Items[Index] | 지정한 0부터 시작하는 인덱스의 하이퍼링크입니다 기본 속성으로 선언됩니다 |
| Clear | 모든 하이퍼링크를 제거하고 해제합니다 |
예제
var
ws: TXLSXWorksheet;
begin
ws := Workbook.Sheets.Add('Links');
ws.Cells.Item[1, 1].Value := 'losLab';
ws.AddHyperlink(1, 1, 'https://www.loslab.com',
'losLab home', 'Open in browser');
// Equivalent through the collection:
ws.Hyperlinks.Add(2, 1, 'https://www.loslab.com/docs');
if ws.Hyperlinks.FindAt(1, 1) <> nil then
ws.Hyperlinks.DeleteInRange(1, 1, 2, 1);
end;
참조