aakash:Well adding a chart on the fly in a package using open xml is not easy. I'd suggest to make a template of the chart and modify (update the data) that on the fly.
Hi,
Please have a look at this
http://msdn.microsoft.com/en-us/library/cc820055(office.14).aspx
Regards,Ankush
Finally I am able to insert a chart into an existing Presentation.
Here is the sample code for reference:
Please note that I have extracted chart1.xml,chartdata.xlsx from a presentation having a single chart in it. Basically I am using them as a template and then manipulating them later on.
===========
// Open an existing Presentation
xDoc.Load(strFileName);
xDoc.Save(objDocMainWrt);
strFileName =
objEmbPart.FeedData(partStream);
nsManager1.AddNamespace(
{
node.Attributes[
}
xDoc.Save(chPrt.GetStream(
nsManager.AddNamespace(
presXML.Load(slidePart.GetStream());
nodeTree.AppendChild(presXML.ImportNode(childNode,
presXML.Save(o);
oPDoc.Close();
===================
xwb.AppendChild(xwb.CreateXmlDeclaration(
xmlns.AddNamespace(
xwb.AppendChild(eleGraphic);
eleGraphic.AppendChild(eleGrpFrm);
eleGrpFrm.AppendChild(elePpr);
attrRid.Value =
elePpr.SetAttributeNode(attrRid);
attrName.Value =
elePpr.SetAttributeNode(attrName);
eleGrpFrm.AppendChild(elecNvGraphicFramePr);
eleGrpFrm.AppendChild(elenvPr);
eleGraphic.AppendChild(elexfrm);
elexfrm.AppendChild(eleoff);
xvalue.Value =
eleoff.SetAttributeNode(xvalue);
yvalue.Value =
eleoff.SetAttributeNode(yvalue);
elexfrm.AppendChild(eleext);
cxvalue.Value =
eleext.SetAttributeNode(cxvalue);
cyvalue.Value =
eleext.SetAttributeNode(cyvalue);
eleGraphic.AppendChild(elegraphic);
elegraphic.AppendChild(elegraphicData);
uri.Value =
elegraphicData.SetAttributeNode(uri);
elegraphicData.AppendChild(elechart);
id.Value = rId;
elechart.SetAttributeNode(id);
Thanks
Ankush