asp.net - How to bind data form database to a existing table in powerpoint using open xml -


i using openxml create powerpoint web app.i created ppt charts , opened ppt in openxml sdk productivity tool , code generated modified chart data coming database,code created modify chart data as

created class code in sdk,in createpart() added these links

 chartpart chartpart1 = slidepart1.addnewpart<chartpart>("rid3");         generatechartpart1content(chartpart1);        // below code added         #if true    // injects chart part modification process                     var chartmodifier1 = new chartpartmodifier();                     chartmodifier1.updatesecondchartpart(chartpart1);         #endif          embeddedpackagepart embeddedpackagepart1 = chartpart1.addnewpart<embeddedpackagepart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "rid2");         generateembeddedpackagepart1content(embeddedpackagepart1); 

and created class chartpartmodifier()

public void updatesecondchartpart(chartpart chartpart)     {         // searchs seriestext , values replace them dynamic data         var serieslabels = chartpart.chartspace.descendants<seriestext>().tolist();         var seriesvalues = chartpart.chartspace.descendants<values>().tolist();         var categoryaxis = chartpart.chartspace.descendants<categoryaxisdata>().tolist();          (int = 0; < this._lineseccharts.count; ++i)         {             var yourline = this._lineseccharts[i];              var label = serieslabels[i].descendants<numericvalue>().firstordefault();             var values = seriesvalues[i].descendants<numericvalue>().tolist();             var categories = categoryaxis[i].descendants<numericvalue>().tolist();              // replaces label of series             label.text = yourline.label;             // replaces values of series             (int validx = 0; validx < values.count(); ++validx)             {                 values[validx].text = yourline.plots[validx].value.tostring();                 categories[validx].text = yourline.plots[validx].category;             }         }     } 

like there way modify data in table,if can 1 provide me solution appreciated.

i found answer after research i'm able update table values database using openxml

the below code which(if condition) added between table appending rows , graphicdata appending

table1.append(tableproperties1);         table1.append(tablegrid1);         table1.append(tablerow1);         table1.append(tablerow2);         table1.append(tablerow3);         table1.append(tablerow4);         table1.append(tablerow5);         table1.append(tablerow6);         table1.append(tablerow7);   #if true    // injects table modification process         tablemodifier tablemodifier = new tablemodifier();//create class         tablemodifier.updatetable(table1);//send table object of wanted update  #endif         graphicdata1.append(table1);          graphic1.append(graphicdata1); 

in class of tablemodifier

using documentformat.openxml.drawing; using documentformat.openxml.packaging;  public class tablemodifier {     public tablemodifier()     {         this.setupdatasource();     }      public void updatetable(table table)     {         var rows = table.descendants<tablerow>().tolist();          (int r = 0; r < rows.count(); ++r)         {             var yourrow = this._rows[r];             var cells = rows[r].descendants<tablecell>().tolist();              (int c = 0; c < cells.count(); ++c)             {                 var yourcell = yourrow.cells[c];                 var text = cells[c].descendants<text>().firstordefault();                 if (text != null)                 {                     text.text = yourcell.value;                 }             }         }     }      private void setupdatasource()     {         this._rows.add(new row()         {             cells = new list<cell>()             {                 new cell(){ value = "products" },                 new cell(){ value = "2010" },                 new cell(){ value = "2011" },                 new cell(){ value = "2012" },             }         });          (int = 0; < 6; ++i)         {             var productname = string.format("product {0}", (char)(i + 'a'));              this._rows.add(new row()             {                 cells = new list<cell>()                 {                     new cell(){ value = productname },                     new cell(){ value = "10%" },                     new cell(){ value = "20%" },                     new cell(){ value = "30%" },                 }             });         }     }      #region private data structure      private class row     {         public list<cell> cells { get; set; }     }      private class cell     {         public string value { get; set; }     }      #endregion      private list<row> _rows = new list<row>(); } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -