|
|
Hi!
I have a peculiar situation.
I need to export an image and a gridview control to excel.
im using rendercontrol for image and datagrid, however, the image only exports it with a link to the actual location.
The code snippet is :
//Code starts
Response.AddHeader("content-disposition", "attachment; filename=Export.xls");
Response.ContentType = "Application/vnd.ms-excel";
Response.ContentType = "Application/vnd.ms-excel";
System.IO.StringWriter strW = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(strW);
HtmlImage himg = new HtmlImage();
System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("Charts.aspx"));
himg.Src = Server.MapPath("Charts.jpg");
himg.RenderControl(htw);
HtmlTable tbl1 = new HtmlTable();
int intRows = 0;
while (intRows < 23)
{
HtmlTableRow hrow = new HtmlTableRow();
tbl1.Rows.Add(hrow);
intRows++;
}
tbl1.RenderControl(htw);
GridView1.RenderControl(htw);
Response.WriteFile(Server.MapPath("RRAT_Charts.jpg"));
Response.Write(strW.ToString());
Response.End();
//code ends
What i need is to embed the image on to the excelsheet.
How can i do that?
Any ideas?
Thanks in advance!!
I was born dumb!!
Programming made me laugh !!!
--sid--
|
|
|
|
|
|
Thanks deepak for the reply..
ill try that out..
I was born dumb!!
Programming made me laugh !!!
--sid--
|
|
|
|
|
hi friends
I have stored image in my database now i have retrieved that image how to set it to a image control
Thank You
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
it depends upin your store procedure . if you have sotore the image patg , just retrive the image path and give it to imagecontrol url.
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
hi
I have stored it in the image format of sql server 2005 i want to know how to assign the datareader value to the image control
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
is u r image control in grid or on page ahd have you stored image name to db?
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
presently...its something like i need to show the icon into a page ...
Image is stored my a X user into the Database ...so how to show the icon in the page from the database
I hope i am clear
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
These link will help you.
http://www.odetocode.com/Articles/172.aspx[^]
ry<br />
<br />
{<br />
<br />
con = new SqlConnection(constr);<br />
cmd = new SqlCommand("select photopath,Photo from employees where employeeid=14", con);<br />
con.Open();<br />
dr = cmd.ExecuteReader();<br />
while(dr.Read())<br />
{<br />
if (!dr.IsDBNull(1))<br />
{<br />
byte[] photo = (byte[])dr[1];<br />
MemoryStream ms = new MemoryStream(photo);<br />
image.Imageurl = Image.FromStream(ms);<br />
}<br />
<br />
<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
dr.Close();<br />
cmd.Dispose();<br />
con.Close();<br />
<br />
MessageBox.Show(ex.Message);<br />
}
or
http://www.developerfusion.co.uk/show/3933/[^]
People Laugh on me Because i am Different but i Laugh on them
Because they all are same.
|
|
|
|
|
Image.FromStream(ms);
It is not working !
Image. doesnt have from stream
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
|
|
|
|
|
rahul.net11 wrote: image.Imageurl = Image.FromStream(ms);
I guess ImageURL takes string - Isn't it ?
|
|
|
|
|
Image control is rendered as HTML img tag. So you need to create a page which reads image from SQL server, load to a Bitmap instance and saves to Response.OutPutStream . Set this page URL as image controls URL.
|
|
|
|
|
Thank You navneet ... i got it ...
Dont Get Paid for the Hours you worked, Get Paid for the Work You Have Done in an Hour.
modified on Monday, April 28, 2008 6:48 AM
|
|
|
|
|
Hi,
How do we maintain focus of control between postbacks
Thanks n advance
|
|
|
|
|
Please dont post same question !!!!
Best Regards
-----------------
Abhijit Jana
Microsoft Certified Professional
"Success is Journey it's not a destination"
|
|
|
|
|
but iam trying this from long time that's the reason i have posted in different way,
|
|
|
|
|
You can make the changes there in the original post itself. It is meaningless to post the same twice. Because whoever will read the one will surely read the second one too.
Apurva Kaushal
|
|
|
|
|
try to use following lie of code in page load-
Page.SmartNavigation = true;
|
|
|
|
|
First it was that person who was posting his message more that once and now you are posting your answers more than once.
Apurva Kaushal
|
|
|
|
|
Hay Apurva
I have just modified my signature but not repost the same answer. And I'm not able to see duplicate answer here!!
|
|
|
|
|
I fill a dropdownlist with values from a table's column. but when i perform an insertion operation into another table based on selected data from the dropdownlist, it only insert the first value of the dropdownlist and not the one i selected. How do i resolve this?
|
|
|
|
|
have u used Dropdownlist.SelectedValue property for gettiing the the data from the dropwornlist.
U need to explain the problem more.
Bijay Bhaskar Deo
Thanks & Regard
|
|
|
|
|
Yea! have used selectedValue property, but still pick the fisrt value and not the selected value during insertion.
pls this only affect dropdownlist filled with values from a table and not that of hardcoded values
|
|
|
|
|
you probabaly need to check the post back ispostbak property because every time
you change the selection of the dropdown it is refreshing that is why you get the
same data.try if not ispostback option
|
|
|
|