c# - Export MS ChartImage to PPT in asp.net -


i trying export chart images ppt i.e each image in 1 slide, below code

 string strtemplate, strpic;             strtemplate = "c:\\program files (x86)\\microsoft office\\templates\\presentation designs\\maple.gif";              //strpic = @"c:\users\rongala.ganesh\pictures\arrow_left_green_large.png";              bool bassistanton;              microsoft.office.interop.powerpoint.application objapp;             microsoft.office.interop.powerpoint.presentations objpresset;             microsoft.office.interop.powerpoint._presentation objpres;             microsoft.office.interop.powerpoint.slides objslides;             microsoft.office.interop.powerpoint._slide objslide;             microsoft.office.interop.powerpoint.textrange objtextrng;             microsoft.office.interop.powerpoint.shapes objshapes;             microsoft.office.interop.powerpoint.shape objshape;             microsoft.office.interop.powerpoint.slideshowwindows objssws;             microsoft.office.interop.powerpoint.slideshowtransition objsst;             microsoft.office.interop.powerpoint.slideshowsettings objsss;             microsoft.office.interop.powerpoint.sliderange objsldrng;             //create new presentation based on template.             objapp = new microsoft.office.interop.powerpoint.application();             objapp.visible = msotristate.msotrue;             objpresset = objapp.presentations;             objpres = objpresset.open(strtemplate,                  msotristate.msofalse, msotristate.msotrue, msotristate.msotrue);             objslides = objpres.slides;             //build slide #1:             //add text slide, change font , insert/position             //picture on first slide.             objslide = objslides.add(1, microsoft.office.interop.powerpoint.ppslidelayout.pplayouttitleonly);             objtextrng = objslide.shapes[1].textframe.textrange;             // objtextrng.text = "fame presentation";             objtextrng.font.name = "comic sans ms";             objtextrng.font.size = 25;             foreach (var ar in arr)             {                 // scriptmanager.registerclientscriptblock(this.page,typeof(string),"alert"                 objslide = objslides.add(1, microsoft.office.interop.powerpoint.ppslidelayout.pplayouttitleonly);                 objtextrng = objslide.shapes[1].textframe.textrange;                 // objtextrng.text = "fame presentation";                 objtextrng.font.name = "comic sans ms";                 objtextrng.font.size = 25;                 string[] str = (string[])ar;                 strpic = str[0];                 objslide.shapes.addpicture(strpic, msotristate.msofalse, msotristate.msotrue,                       150, 150, 500, 350);                 objtextrng = objslide.shapes[1].textframe.textrange;                 objtextrng.text = str[1];                 objtextrng.font.name = "comic sans ms";                 objtextrng.font.size = 48;                  //build slide #2:                 //add text slide title, format text. add chart                 //slide , change chart type 3d pie chart.                  //build slide #3:                 //change background color of slide only. add text effect slide                 //and apply various color schemes , shadows text effect.             }            }         catch (exception ex)         {              throw ex;         } 

when run this, every thing working fine in localhost, when host appilcaion iis7 throwing exception powerpoint not open file. thought better add response header, followed below code

// dt datatable name containt, path of images saved when click on saveimage

 gridview1.allowpaging = false;              gridview1.datasource = dt;             gridview1.databind();////////write code if paging enabled.              response.clear();              response.addheader("content-disposition", "attachment;filename=filename.ppt");///////for text file write filename.txt              response.charset = "";             // if want option open excel file without saving              // comment out line below             // response.cache.setcacheability(httpcacheability.nocache);              response.contenttype = "application/vnd.ppt";//for text file write vnd.txt                system.io.stringwriter stringwrite = new system.io.stringwriter();             system.web.ui.htmltextwriter htmlwrite =              new htmltextwriter(stringwrite);             gridview1.rendercontrol(htmlwrite);              response.write(stringwrite.tostring());              response.end(); 

here can add images ppt, in same slide,and images overlapping each other.

any 1 me it's urgent please.

using interop on server (like asp.net) not supported ms - see http://support.microsoft.com/default.aspx?scid=kb;en-us;q257757#kb2

since windows vista ms introduced several security-related measures prevent windows service doing "desktop-like" things... means have circumvent several security measures work (not recommended!).

to deal ppt in server-scenario there options (free , commercial) out there:

a free option (though newer pptx format only!) example openxml 2 ms.

a commercial option aspose.slides can handle old (ppt) , new (pptx) format.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -