Type xlsxChart = Class(TSChart)
	///缺省构造函数
	Function Create(sheet,excel); overload;
	Begin
		excel_ := excel;
		class(TSChart).Create(chartData);
		chartId_ := excel.WorkBook().GetFilesCount('xl/charts/chart') + 1;
		drawingRID_ := excel_.WorkBook().GetSheetDrawing(sheet);
		drawingXmlObj_ := excel_.WorkBook().GetXmlFileObj('xl/drawings/drawing' $ drawingRID_ $ '.xml');
		drawingRelsObj := excel_.WorkBook().GetDrawingRelsFile(drawingRID_);
		[chartRid_, find] := class(TSXml).FindRelationshipRid(drawingRelsObj, '');
		chartRid_ ++;
		class(TSXml).AddRelationshipRid(drawingRelsObj, '../charts/chart'+inttostr(chartId_)+'.xml', 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart', 'rId' + inttostr(chartRid_));
		xlChartFileName_ := 'xl/charts/chart'+inttostr(chartId_)+'.xml';
		content_xml := excel_.WorkBook().GetXmlFileObj(class(TSXml).GetFileName('Content_Types'));
		class(TSXml).AddOverrideContentType(content_xml, '/' + xlChartFileName_, 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml');
	End;
	
	class Function NewObject(sheet, excel);
	Begin
		excel_ := excel;
		o := excel_.WorkBook().GetSheetObj(sheet);//sheet存在
		if not ifObj(o, chart) then return 0;
		return new xlsxChart(sheet, excel);
	End;
	
	Function AddChart(range, chartData);
	Begin
		chartData_ := chartData;
		excel_.Zip().Add(xlChartFileName_, GetDefaultXml());
		xmlObj := excel_.Zip().Get(xlChartFileName_);
		Apply(xmlObj);

		a := str2array(range,':');
		if length(a) <> 2 then return array(1,'Invalid params.');
		[err1, col1,row1] := excel_.CellNameToCoordinates(a[0]);
		[err2, col2,row2] := excel_.CellNameToCoordinates(a[1]);
		if err1 or err2 then return array(1,'Invalid params.');
		o := TOfficeObj('TtwoCellAnchor');
		o.XFrom.Col := col1 - 1;
		o.XFrom.ColOff := chartData.BegColOff ? chartData.BegColOff : 0;
		o.XFrom.Row := row1 - 1;
		o.XFrom.RowOff := chartData.BegRowOff ? chartData.BegRowOff : 0;

		o.XTo.Col := col2;
		o.XTo.ColOff := chartData.EndColOff ? chartData.EndColOff : 0;
		o.XTo.Row := row2;
		o.XTo.RowOff := chartData.EndRowOff ? chartData.EndRowOff : 0;

		//o.GraphicFrame.macro := '';
		o.GraphicFrame.GraphicFramePr.Name := chartData.Name ? chartData.Name : 'Chart' + inttostr(chartId_);
		o.GraphicFrame.GraphicFramePr.Id := class(TSXml).GetcNvPrID(drawingXmlObj_);
		o.GraphicFrame.GraphicFramePr.cNvGraphicFramePr := true;

		o.GraphicFrame.XFrm.Off.X := 0;
		o.GraphicFrame.XFrm.Off.Y := 0;
		o.GraphicFrame.XFrm.Ext.Cx := 0;
		o.GraphicFrame.XFrm.Ext.Cy := 0;

		o.GraphicFrame.Graphic.GraphicData.uri := 'http://schemas.openxmlformats.org/drawingml/2006/chart';
		o.GraphicFrame.Graphic.GraphicData.Rid := 'rId' + inttostr(chartRid_);
		o.GraphicFrame.Graphic.GraphicData.R := 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
		o.GraphicFrame.Graphic.GraphicData.C := 'http://schemas.openxmlformats.org/drawingml/2006/chart';
		o.ClientData.ObjectType := true;
		node := drawingXmlObj_.FirstChild('xdr:wsDr').InsertEndChild(o.Marshal());
	End;
private	
	excel_;
	drawingRID_:integer;
	chartId_;
	chartRid_;
	xlChartFileName_;
	drawingXmlObj_;
End;
