internal ExcelPivotCacheDefinition(XmlNamespaceManager ns, ExcelPivotTable pivotTable) : base(ns, null) { foreach (var r in pivotTable.Part.GetRelationshipsByType(ExcelPackage.schemaRelationships + "/pivotCacheDefinition")) { Relationship = r; } CacheDefinitionUri = PackUriHelper.ResolvePartUri(Relationship.SourceUri, Relationship.TargetUri); var pck = pivotTable.WorkSheet._package.Package; Part = pck.GetPart(CacheDefinitionUri); CacheDefinitionXml = new XmlDocument(); LoadXmlSafe(CacheDefinitionXml, Part.GetStream()); TopNode = CacheDefinitionXml.DocumentElement; PivotTable = pivotTable; if (CacheSource == eSourceType.Worksheet) { var worksheetName = GetXmlNodeString(_sourceWorksheetPath); if (pivotTable.WorkSheet.Workbook.Worksheets.Any(t => t.Name == worksheetName)) { _sourceRange = pivotTable.WorkSheet.Workbook.Worksheets[worksheetName].Cells[GetXmlNodeString(_sourceAddressPath)]; } } }
//internal ExcelBarChart(ExcelDrawings drawings, XmlNode node) : // base(drawings, node/*, 1*/) //{ // SetChartNodeText(""); //} //internal ExcelBarChart(ExcelDrawings drawings, XmlNode node, eChartType type) : // base(drawings, node, type) //{ // SetChartNodeText(""); // SetTypeProperties(drawings, type); //} internal ExcelBarChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) : base(drawings, node, type, topChart, PivotTableSource) { SetChartNodeText(""); SetTypeProperties(drawings, type); }
internal void AddPivotSerie(ExcelPivotTable pivotTableSource) { var r=pivotTableSource.WorkSheet.Cells[pivotTableSource.Address.Address]; _isPivot = true; AddSeries(r.Offset(0, 1, r._toRow - r._fromRow + 1, 1).FullAddressAbsolute, r.Offset(0, 0, r._toRow - r._fromRow + 1, 1).FullAddressAbsolute); }
internal ExcelLineChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) : base(drawings, node, type, topChart, PivotTableSource) { Smooth = false; }
internal ExcelPivotTableField(XmlNamespaceManager ns, XmlNode topNode,ExcelPivotTable table, int index, int baseIndex) : base(ns, topNode) { Index = index; BaseIndex = baseIndex; _table = table; }
internal ExcelDoughnutChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) : base(drawings, node, type, topChart, PivotTableSource) { //SetPaths(); }
internal ExcelScatterChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) : base(drawings, node, type, topChart, PivotTableSource) { SetTypeProperties(); }
internal ExcelPivotCacheDefinition(XmlNamespaceManager ns, ExcelPivotTable pivotTable, ExcelRangeBase sourceAddress, int tblId) : base(ns, null) { PivotTable = pivotTable; var pck = pivotTable.WorkSheet._package.Package; //CacheDefinition CacheDefinitionXml = new XmlDocument(); LoadXmlSafe(CacheDefinitionXml, GetStartXml(sourceAddress)); CacheDefinitionUri = GetNewUri(pck, "/xl/pivotCache/pivotCacheDefinition{0}.xml", tblId); Part = pck.CreatePart(CacheDefinitionUri, ExcelPackage.schemaPivotCacheDefinition); TopNode = CacheDefinitionXml.DocumentElement; //CacheRecord. Create an empty one. CacheRecordUri = GetNewUri(pck, "/xl/pivotCache/pivotCacheRecords{0}.xml", tblId); var cacheRecord = new XmlDocument(); cacheRecord.LoadXml("<pivotCacheRecords xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" count=\"0\" />"); var recPart = pck.CreatePart(CacheRecordUri, ExcelPackage.schemaPivotCacheRecords); cacheRecord.Save(recPart.GetStream()); RecordRelationship = Part.CreateRelationship(PackUriHelper.ResolvePartUri(CacheDefinitionUri, CacheRecordUri), TargetMode.Internal, ExcelPackage.schemaRelationships + "/pivotCacheRecords"); RecordRelationshipID = RecordRelationship.Id; CacheDefinitionXml.Save(Part.GetStream()); }
internal ExcelChart(ExcelDrawings drawings, XmlNode node, eChartType type, ExcelChart topChart, ExcelPivotTable PivotTableSource) : base(drawings, node, "xdr:graphicFrame/xdr:nvGraphicFramePr/xdr:cNvPr/@name") { ChartType = type; CreateNewChart(drawings, type, topChart); Init(drawings, _chartNode); _chartSeries = new ExcelChartSeries(this, drawings.NameSpaceManager, _chartNode, PivotTableSource!=null); if (PivotTableSource != null) SetPivotSource(PivotTableSource); SetTypeProperties(drawings); if (topChart == null) LoadAxis(); else { _axis = topChart.Axis; if (_axis.Length > 0) { XAxis = _axis[0]; YAxis = _axis[1]; } } }
internal void SetPivotSource(ExcelPivotTable pivotTableSource) { PivotTableSource = pivotTableSource; XmlElement chart = ChartXml.SelectSingleNode("c:chartSpace/c:chart", NameSpaceManager) as XmlElement; var pivotSource = ChartXml.CreateElement("pivotSource", ExcelPackage.schemaChart); chart.ParentNode.InsertBefore(pivotSource, chart); pivotSource.InnerXml = string.Format("<c:name>[]{0}!{1}</c:name><c:fmtId val=\"0\"/>", PivotTableSource.WorkSheet.Name, pivotTableSource.Name); var fmts = ChartXml.CreateElement("pivotFmts", ExcelPackage.schemaChart); chart.PrependChild(fmts); fmts.InnerXml = "<c:pivotFmt><c:idx val=\"0\"/><c:marker><c:symbol val=\"none\"/></c:marker></c:pivotFmt>"; Series.AddPivotSerie(pivotTableSource); }
internal static ExcelChart GetNewChart(ExcelDrawings drawings, XmlNode drawNode, eChartType chartType, ExcelChart topChart, ExcelPivotTable PivotTableSource) { switch(chartType) { case eChartType.Pie: case eChartType.PieExploded: case eChartType.Pie3D: case eChartType.PieExploded3D: return new ExcelPieChart(drawings, drawNode, chartType, topChart, PivotTableSource); case eChartType.BarOfPie: case eChartType.PieOfPie: return new ExcelOfPieChart(drawings, drawNode, chartType, topChart, PivotTableSource); case eChartType.Doughnut: case eChartType.DoughnutExploded: return new ExcelDoughnutChart(drawings, drawNode, chartType, topChart, PivotTableSource); case eChartType.BarClustered: case eChartType.BarStacked: case eChartType.BarStacked100: case eChartType.BarClustered3D: case eChartType.BarStacked3D: case eChartType.BarStacked1003D: case eChartType.ConeBarClustered: case eChartType.ConeBarStacked: case eChartType.ConeBarStacked100: case eChartType.CylinderBarClustered: case eChartType.CylinderBarStacked: case eChartType.CylinderBarStacked100: case eChartType.PyramidBarClustered: case eChartType.PyramidBarStacked: case eChartType.PyramidBarStacked100: case eChartType.ColumnClustered: case eChartType.ColumnStacked: case eChartType.ColumnStacked100: case eChartType.Column3D: case eChartType.ColumnClustered3D: case eChartType.ColumnStacked3D: case eChartType.ColumnStacked1003D: case eChartType.ConeCol: case eChartType.ConeColClustered: case eChartType.ConeColStacked: case eChartType.ConeColStacked100: case eChartType.CylinderCol: case eChartType.CylinderColClustered: case eChartType.CylinderColStacked: case eChartType.CylinderColStacked100: case eChartType.PyramidCol: case eChartType.PyramidColClustered: case eChartType.PyramidColStacked: case eChartType.PyramidColStacked100: return new ExcelBarChart(drawings, drawNode, chartType, topChart, PivotTableSource); case eChartType.XYScatter: case eChartType.XYScatterLines: case eChartType.XYScatterLinesNoMarkers: case eChartType.XYScatterSmooth: case eChartType.XYScatterSmoothNoMarkers: return new ExcelScatterChart(drawings, drawNode, chartType, topChart, PivotTableSource); case eChartType.Line: case eChartType.Line3D: case eChartType.LineMarkers: case eChartType.LineMarkersStacked: case eChartType.LineMarkersStacked100: case eChartType.LineStacked: case eChartType.LineStacked100: return new ExcelLineChart(drawings, drawNode, chartType, topChart, PivotTableSource); default: return new ExcelChart(drawings, drawNode, chartType, topChart, PivotTableSource); } }