How to export datagrid to power point using C#
Hi all,
Can anyone tell me How to export datagrid to power point using C#.
I try this your article:
http://www.c-sharpcorner.com/uploadfile/krishnasarala/export-panel-in-asp-net/
But export to PPT is not working.
When I select ppt and click export it is open blank ppt.
Thanks in advance.
Regards,
Chevy
Loading
Bhavik PatelPosted Aug 28, 2014, 6:26 AM
http://forums.asp.net/t/1123406.aspx
http://www.aspose.com/community/forums/thread/96316.aspx
http://geekswithblogs.net/vivek/archive/2006/09/26/92316.aspx
http://steveorr.net/reviews/AsposePowerPoint.aspx
Chevy Mark SunderlandPosted Jul 24, 2012, 9:51 AM
I try this code.
I don't have error.
But in the test.gif I have the html format.
E.g.:
The problem is:
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
What should I use to insert an image my GridView?
Can you help me? thanks for help.
using System;
using System.IO;
using System.Data;
using System.Data.Odbc;
using System.Configuration;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using System.Drawing.Imaging;
public partial class ExpGVPPT_Default : System.Web.UI.Page
{
OdbcConnection myConnectionString = new OdbcConnection(ConfigurationManager.ConnectionStrings["ConnMySQL"].ConnectionString);
OdbcCommand Sqlcmd;
OdbcDataAdapter da;
DataTable dt = new DataTable();
String query;
protected void Page_Load(object sender, EventArgs e)
{
query = "select * from tbl_test";
Sqlcmd = new OdbcCommand(query, myConnectionString);
da = new OdbcDataAdapter(Sqlcmd);
dt.Clear();
da.Fill(dt);
DataList1.DataSource = dt;
DataList1.DataBind();
if (dt.Rows.Count > 0)
{
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
GridView1.DataSource = dt;
GridView1.DataBind();
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.RenderControl(hw);
string path = @"C:\Inetpub\wwwroot\pptx\test.gif";
Bitmap bitMap = new Bitmap(800, 400);
Graphics graphics = Graphics.FromImage(bitMap);
Brush brush = new SolidBrush(Color.YellowGreen);
Brush brushWrite = new SolidBrush(Color.White);
Font font = new Font("Arial", 13);
PointF point = new PointF(5F, 5F);
graphics.DrawString(sw.ToString(), font, brushWrite, point);
bitMap.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
bitMap.Dispose();
graphics.Dispose();
}
myConnectionString.Close();
myConnectionString.Dispose();
}
public override void VerifyRenderingInServerForm(Control control)
{
return;
}
protected void btnToExcel_Click1(object sender, EventArgs e)
{
}
}