public IChart CreateChart(IClientAnchor anchor) { int idx = this.GetPackagePart().Package.GetPartsByContentType(XSSFRelation.CHART.ContentType).Count + 1; XSSFChart relationship = (XSSFChart)this.CreateRelationship((POIXMLRelation)XSSFRelation.CHART, (POIXMLFactory)XSSFFactory.GetInstance(), idx); string id = relationship.GetPackageRelationship().Id; this.CreateGraphicFrame((XSSFClientAnchor)anchor).SetChart(relationship, id); return((IChart)relationship); }
/// <summary> /// Creates a chart. /// </summary> /// <param name="anchor">the client anchor describes how this chart is attached to</param> /// <returns>the newly created chart</returns> public IChart CreateChart(IClientAnchor anchor) { int chartNumber = GetPackagePart().Package. GetPartsByContentType(XSSFRelation.CHART.ContentType).Count + 1; XSSFChart chart = (XSSFChart)CreateRelationship( XSSFRelation.CHART, XSSFFactory.GetInstance(), chartNumber); String chartRelId = chart.GetPackageRelationship().Id; XSSFGraphicFrame frame = CreateGraphicFrame((XSSFClientAnchor)anchor); frame.SetChart(chart, chartRelId); return(chart); }