Skip to content

Commit 45ef161

Browse files
author
JanKallman
committed
First version
--HG-- extra : convert_revision : svn%3Ac031521d-7fdb-604e-9ef1-0138de3cd895/trunk%401
0 parents  commit 45ef161

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+12850
-0
lines changed

ExcelPackage.sln

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 10.00
3+
# Visual Studio 2008
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelPackage", "ExcelPackage\ExcelPackage.csproj", "{7B288026-5502-4A39-BF41-77E086F3E4A3}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExcelPackageSamples", "SampleApp\ExcelPackageSamples.csproj", "{06BF3C68-E7D4-4579-90BE-E36DACE564EF}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{7B288026-5502-4A39-BF41-77E086F3E4A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{7B288026-5502-4A39-BF41-77E086F3E4A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{7B288026-5502-4A39-BF41-77E086F3E4A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{7B288026-5502-4A39-BF41-77E086F3E4A3}.Release|Any CPU.Build.0 = Release|Any CPU
18+
{06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
21+
{06BF3C68-E7D4-4579-90BE-E36DACE564EF}.Release|Any CPU.Build.0 = Release|Any CPU
22+
EndGlobalSection
23+
GlobalSection(SolutionProperties) = preSolution
24+
HideSolutionNode = FALSE
25+
EndGlobalSection
26+
GlobalSection(ExtensibilityGlobals) = postSolution
27+
VisualSVNWorkingCopyRoot = .
28+
EndGlobalSection
29+
EndGlobal
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="utf-8"?><ItemProperties xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><Properties><Property><Name>svn:mime-type</Name><Value>application/octet-stream</Value></Property></Properties></ItemProperties>

ExcelPackage/Drawing/ExcelChart.cs

Lines changed: 255 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,255 @@
1+
/*
2+
* You may amend and distribute as you like, but don't remove this header!
3+
*
4+
* EPPlus provides server-side generation of Excel 2007 spreadsheets.
5+
* EPPlus is a fork of the ExcelPackage project
6+
* See http://www.codeplex.com/EPPlus for details.
7+
*
8+
* All rights reserved.
9+
*
10+
* EPPlus is an Open Source project provided under the
11+
* GNU General Public License (GPL) as published by the
12+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13+
*
14+
* The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
15+
* If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
16+
*
17+
* The code for this project may be used and redistributed by any means PROVIDING it is
18+
* not sold for profit without the author's written consent, and providing that this notice
19+
* and the author's name and all copyright notices remain intact.
20+
*
21+
* All code and executables are provided "as is" with no warranty either express or implied.
22+
* The author accepts no liability for any damage or loss of business that this product may cause.
23+
*
24+
*
25+
* Code change notes:
26+
*
27+
* Author Change Date
28+
* ******************************************************************************
29+
* Jan Källman Initial Release 2009-10-01
30+
*******************************************************************************/
31+
using System;
32+
using System.Collections.Generic;
33+
using System.Text;
34+
using System.Xml;
35+
using System.IO.Packaging;
36+
37+
namespace OfficeOpenXml.Drawing
38+
{
39+
public enum eChartType
40+
{
41+
xl3DArea=-4098,
42+
xl3DAreaStacked=78,
43+
xl3DAreaStacked100=79,
44+
xl3DBarClustered=60,
45+
xl3DBarStacked=61,
46+
xl3DBarStacked100=62,
47+
xl3DColumn=-4100,
48+
xl3DColumnClustered=54,
49+
xl3DColumnStacked=55,
50+
xl3DColumnStacked100=56,
51+
xl3DLine=-4101,
52+
xl3DPie=-4102,
53+
xl3DPieExploded=70,
54+
xlArea=1,
55+
xlAreaStacked=76,
56+
xlAreaStacked100=77,
57+
xlBarClustered=57,
58+
xlBarOfPie=71,
59+
xlBarStacked=58,
60+
xlBarStacked100=59,
61+
xlBubble=15,
62+
xlBubble3DEffect=87,
63+
xlColumnClustered=51,
64+
xlColumnStacked=52,
65+
xlColumnStacked100=53,
66+
xlConeBarClustered=102,
67+
xlConeBarStacked=103,
68+
xlConeBarStacked100=104,
69+
xlConeCol=105,
70+
xlConeColClustered=99,
71+
xlConeColStacked=100,
72+
xlConeColStacked100=101,
73+
xlCylinderBarClustered=95,
74+
xlCylinderBarStacked=96,
75+
xlCylinderBarStacked100=97,
76+
xlCylinderCol=98,
77+
xlCylinderColClustered=92,
78+
xlCylinderColStacked=93,
79+
xlCylinderColStacked100=94,
80+
xlDoughnut=-4120,
81+
xlDoughnutExploded=80,
82+
xlLine=4,
83+
xlLineMarkers=65,
84+
xlLineMarkersStacked=66,
85+
xlLineMarkersStacked100=67,
86+
xlLineStacked=63,
87+
xlLineStacked100=64,
88+
xlPie=5,
89+
xlPieExploded=69,
90+
xlPieOfPie=68,
91+
xlPyramidBarClustered=109,
92+
xlPyramidBarStacked=110,
93+
xlPyramidBarStacked100=111,
94+
xlPyramidCol=112,
95+
xlPyramidColClustered=106,
96+
xlPyramidColStacked=107,
97+
xlPyramidColStacked100=108,
98+
xlRadar=-4151,
99+
xlRadarFilled=82,
100+
xlRadarMarkers=81,
101+
xlStockHLC=88,
102+
xlStockOHLC=89,
103+
xlStockVHLC=90,
104+
xlStockVOHLC=91,
105+
xlSurface=83,
106+
xlSurfaceTopView=85,
107+
xlSurfaceTopViewWireframe=86,
108+
xlSurfaceWireframe=84,
109+
xlXYScatter=-4169,
110+
xlXYScatterLines=74,
111+
xlXYScatterLinesNoMarkers=75,
112+
xlXYScatterSmooth=72,
113+
xlXYScatterSmoothNoMarkers=73
114+
}
115+
/// <summary>
116+
/// Provide access to Chart objects.
117+
/// </summary>
118+
public class ExcelChart : ExcelDrawing
119+
{
120+
const string rootPath = "c:chartSpace/c:chart/c:plotArea";
121+
string _chartPath;
122+
ExcelChartSeries _series;
123+
ExcelChartAxis[] _axis;
124+
XmlHelper _chartXmlHelper;
125+
internal ExcelChart(ExcelDrawings drawings, XmlNode node) :
126+
base(drawings, node, "xdr:graphicFrame/xdr:nvGraphicFramePr/xdr:cNvPr/@name")
127+
{
128+
XmlNode chartNode = node.SelectSingleNode("xdr:graphicFrame/a:graphic/a:graphicData/c:chart", drawings.NameSpaceManager);
129+
if (chartNode != null)
130+
{
131+
PackageRelationship drawingRelation = drawings.Part.GetRelationship(chartNode.Attributes["r:id"].Value);
132+
UriChart = PackUriHelper.ResolvePartUri(drawings.UriDrawing, drawingRelation.TargetUri);
133+
134+
Part = drawings.Part.Package.GetPart(UriChart);
135+
ChartXml = new XmlDocument();
136+
ChartXml.Load(Part.GetStream());
137+
SetChartType();
138+
_chartXmlHelper = new XmlHelper(drawings.NameSpaceManager, ChartXml);
139+
_series = new ExcelChartSeries(this, drawings.NameSpaceManager, ChartXml.SelectSingleNode(_chartPath, drawings.NameSpaceManager));
140+
LoadAxis();
141+
}
142+
else
143+
{
144+
ChartXml = null;
145+
}
146+
}
147+
148+
private void LoadAxis()
149+
{
150+
XmlNodeList nl = ChartXml.SelectNodes(_chartPath + "/c:axId", NameSpaceManager);
151+
List<ExcelChartAxis> l=new List<ExcelChartAxis>();
152+
foreach (XmlNode node in nl)
153+
{
154+
string id = node.Attributes["val"].Value;
155+
XmlNode axisNode = ChartXml.SelectNodes(rootPath + string.Format("/*/c:axId[@val=\"{0}\"]",id), NameSpaceManager)[1].ParentNode;
156+
ExcelChartAxis ax = new ExcelChartAxis(NameSpaceManager, axisNode);
157+
l.Add(ax);
158+
}
159+
_axis = l.ToArray();
160+
}
161+
private void SetChartType()
162+
{
163+
ChartType = 0;
164+
foreach(XmlNode n in ChartXml.SelectSingleNode(rootPath, _drawings.NameSpaceManager).ChildNodes)
165+
{
166+
switch(n.Name)
167+
{
168+
case "c:area3DChart":
169+
ChartType = eChartType.xl3DArea;
170+
break;
171+
case "c:areaChart":
172+
ChartType = eChartType.xlArea;
173+
break;
174+
case "c:barChart":
175+
ChartType = eChartType.xlBarClustered;
176+
break;
177+
case "c:bar3DChart":
178+
ChartType = eChartType.xl3DBarClustered;
179+
break;
180+
case "c:bubbleChart":
181+
ChartType = eChartType.xlBubble;
182+
break;
183+
case "c:doughnutChart":
184+
ChartType = eChartType.xlDoughnut;
185+
break;
186+
case "c:lineChart":
187+
ChartType = eChartType.xlLine;
188+
break;
189+
case "c:line3DChart":
190+
ChartType = eChartType.xl3DLine;
191+
break;
192+
case "c:pie3DChart":
193+
ChartType = eChartType.xl3DPie;
194+
break;
195+
case "c:pieChart":
196+
ChartType = eChartType.xlPie;
197+
break;
198+
case "c:radarChart":
199+
ChartType = eChartType.xlRadar;
200+
break;
201+
case "c:scatterChart":
202+
ChartType = eChartType.xlXYScatter;
203+
break;
204+
case "c:surface3DChart":
205+
case "c:surfaceChart":
206+
ChartType = eChartType.xlSurface;
207+
break;
208+
case "c:stockChart":
209+
ChartType = eChartType.xlStockHLC;
210+
break;
211+
}
212+
if (ChartType != 0)
213+
{
214+
_chartPath = rootPath + "/" + n.Name;
215+
return;
216+
}
217+
}
218+
}
219+
internal PackagePart Part { get; set; }
220+
public XmlDocument ChartXml { get; set; }
221+
internal Uri UriChart { get; set; }
222+
public eChartType ChartType { get; set; }
223+
public ExcelChartSeries Series
224+
{
225+
get
226+
{
227+
return _series;
228+
}
229+
}
230+
public ExcelChartAxis[] Axis
231+
{
232+
get
233+
{
234+
return _axis;
235+
}
236+
}
237+
const string titlePath = "c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t";
238+
public string Header
239+
{
240+
get
241+
{
242+
return _chartXmlHelper.GetXmlNode(titlePath);
243+
}
244+
set
245+
{
246+
_chartXmlHelper.CreateNode(titlePath);
247+
_chartXmlHelper.SetXmlNode(titlePath, value);
248+
}
249+
}
250+
internal string Id
251+
{
252+
get { return ""; }
253+
}
254+
}
255+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* You may amend and distribute as you like, but don't remove this header!
3+
*
4+
* EPPlus provides server-side generation of Excel 2007 spreadsheets.
5+
* EPPlus is a fork of the ExcelPackage project
6+
* See http://www.codeplex.com/EPPlus for details.
7+
*
8+
* All rights reserved.
9+
*
10+
* EPPlus is an Open Source project provided under the
11+
* GNU General Public License (GPL) as published by the
12+
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13+
*
14+
* The GNU General Public License can be viewed at http://www.opensource.org/licenses/gpl-license.php
15+
* If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
16+
*
17+
* The code for this project may be used and redistributed by any means PROVIDING it is
18+
* not sold for profit without the author's written consent, and providing that this notice
19+
* and the author's name and all copyright notices remain intact.
20+
*
21+
* All code and executables are provided "as is" with no warranty either express or implied.
22+
* The author accepts no liability for any damage or loss of business that this product may cause.
23+
*
24+
*
25+
* Code change notes:
26+
*
27+
* Author Change Date
28+
* ******************************************************************************
29+
* Jan Källman Initial Release 2009-10-01
30+
* ******************************************************************************/
31+
using System;
32+
using System.Collections.Generic;
33+
using System.Text;
34+
using System.Xml;
35+
namespace OfficeOpenXml.Drawing
36+
{
37+
public class ExcelChartAxis : XmlHelper
38+
{
39+
public ExcelChartAxis(XmlNamespaceManager nameSpaceManager, XmlNode topNode) :
40+
base(nameSpaceManager, topNode)
41+
{
42+
43+
}
44+
const string _formatPath="c:numFmt/@formatCode";
45+
public string Format
46+
{
47+
get
48+
{
49+
return GetXmlNode(_formatPath);
50+
}
51+
set
52+
{
53+
SetXmlNode(_formatPath,value);
54+
}
55+
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)