Type xlsxHyperLink = Class
	Function Create(sheetName, file, xmlFile); overload;
	Begin
		sheetName_ := sheetName;
		file_  := file;
		xmlFile_ := xmlFile;
	End;

	class Function NewObject(sheetname, file);
	Begin
		xmlFile := file.WorkBook().GetSheetXmlfile(sheetname);
		return new xlsxHyperLink(sheetname, file, xmlFile);
	End;

	Function SetCellHyperLink(axis, hyperlink);
	Begin
		work_node := xmlFile_.FirstChildElement('worksheet');
		hyperlinks := work_node.FirstChildElement('hyperlinks');
		if not ifObj(hyperlinks) then begin
			phone_node := work_node.FirstChildElement('phoneticPr');
			hyperlinks := work_node.InsertAfterChild(phone_node, 'element', 'hyperlinks');
		end;
		node := hyperlinks.FirstChildElement('hyperlink');
		while ifObj(node) do begin
			ref := node.GetAttribute('ref');
			if ref = axis then begin
				node := hyperlinks.DeleteChild(node);
				break;
			end;
			node := node.NextElement();
		end;
		hyperlink.Axis := axis;
		marshal := hyperlink.Marshal();
		attrs := marshal['attributes'];
		if attrs['linkType'] = "Location" then reindex(attrs, array('linkType': nil, 'linkUrl': 'location'));
		else if attrs['linkType'] = "External" then
		Begin
			[rid, commentFileName, sheetFileName, relsfile] := file_.WorkBook().GetRelationshipRid(sheetName_, hyperlink.LinkUrl);
			if commentFileName = "" then
			Begin
				rid++;
				ridstr := 'rId' + inttostr(rid);
				xmlfile := file_.WorkBook().GetXmlFileObj(relsfile);
				class(xlsxXml).AddRelationshipRid(xmlfile, hyperlink.LinkUrl, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink", ridstr, "External");
			End
			reindex(attrs, array('linkType': nil, 'linkUrl': nil));
			attrs['r:id'] := 'rId' + inttostr(rid);
		End
		marshal['attributes'] := attrs;
		hyperlinks.InsertEndChild(marshal);
		return array(0,'ok');
	End;

	Function GetCellHyperLink(axis);
	Begin
		data := array();
		hyperlinks := xmlFile_.FirstChildElement('worksheet').FirstChildElement('hyperlinks');
		if not ifObj(hyperlinks) then return array(-1, 'Node::hyperlinks is not exist.');
		node := hyperlinks.FirstChildElement('hyperlink');
		while ifObj(node) do begin
			marshal := node.marshal()[0];
			attrs := marshal['attributes'];
			if attrs['ref'] = axis then
			begin
				link := TOfficeObj('THyperLink');
				link.LinkType := ifnil(attrs['location']) ? "External" : "Location";
				if not ifnil(attrs['location']) then
					link.LinkUrl := attrs['location'];
				else Begin
					rid := attrs['r:id'];
					file := 'xl/worksheets/_rels/' + ExtractFileName(LowerCase(sheetName_)) + '.xml.rels';
					xmlfile := file_.WorkBook().GetXmlFileObj(file);
					relnode := class(xlsxXml).FindRelationship(xmlfile, rid);
					if ifObj(relnode) then link.LinkUrl := relnode.GetAttribute('Target');
				End
				link.Display := attrs['display'];
				link.Tooltip := attrs['tooltip'];
				return array(0, link);
			end;
			node := node.NextElement();
		end;
		return array(-2, "The cell has no hyperlink.");
	End;

private
	file_; //TSExcelFile对象
	xmlFile_;//XmlFile对象
	sheetName_;

End;
