Click here to Skip to main content
15,922,015 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Advanced Search in database Pin
rt28006-Jan-11 3:27
professionalrt28006-Jan-11 3:27 
QuestionGridView Pin
anishkannan30-Dec-10 1:55
anishkannan30-Dec-10 1:55 
AnswerRe: GridView Pin
Not Active30-Dec-10 2:23
mentorNot Active30-Dec-10 2:23 
AnswerRe: GridView Pin
Hiren solanki30-Dec-10 3:29
Hiren solanki30-Dec-10 3:29 
Questionall languages in application Pin
Thanusree Duth30-Dec-10 0:07
Thanusree Duth30-Dec-10 0:07 
AnswerRe: all languages in application Pin
_Erik_30-Dec-10 0:32
_Erik_30-Dec-10 0:32 
AnswerRe: all languages in application Pin
Brij30-Dec-10 17:44
mentorBrij30-Dec-10 17:44 
QuestionHow to export Image file to Excel using the output HTML method Pin
DevWithDoubts29-Dec-10 9:57
DevWithDoubts29-Dec-10 9:57 
Hi to all,

I'm having a problem that I hope someone can help me with.

I'm trying to export data from an asp.net page to an Excel file and I'm basically just outputting HTML to the XLS file and let Excel interprets it, by using this type of coding:

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("Windows-1252");
HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "\"File.xls\""));
HttpContext.Current.Response.ContentType = "application/ms-excel";

using (StringWriter sw = new StringWriter())
{
	using (HtmlTextWriter htw = new HtmlTextWriter(sw))
	{
		gridview.RenderControl(htw);
		
		HttpContext.Current.Response.Write(sw.ToString());
		HttpContext.Current.Response.Flush();
		HttpContext.Current.Response.End();
	}
}


However, although this is doing fine for exporting raw text, I now have to export to the same Excel file an image. However, the same kind of method I'm using right now only seems to insert a "linked" image, I mean, the image appears in the file, however, the user viewing the file has to be online since it's a direct link to the file in the server. I would like to able to "embeded" the image in the file, just like how it's made when you insert manually an image using Excel.

However, after some online research I can't seem to find any solution for this. Can anybody help me out here and point me to what a possible solution would be?

I can't use Microsoft.Office.Interop.Excel library, and a third party software isn't advisable also, that's what made me try out the HTML output solution, which worked ok for the text. But now, for inserting an image, what can I do? Is it possible to achieve what I pretend?

Thanks in advance.
Questionsecurite management review Pin
amina8929-Dec-10 5:14
amina8929-Dec-10 5:14 
AnswerRe: securite management review Pin
Parwej Ahamad29-Dec-10 10:19
professionalParwej Ahamad29-Dec-10 10:19 
GeneralRe: securite management review Pin
amina8929-Dec-10 23:34
amina8929-Dec-10 23:34 
GeneralRe: securite management review Pin
_Erik_30-Dec-10 0:38
_Erik_30-Dec-10 0:38 
Questioncodeproject Forum Pin
Ramkumar_S29-Dec-10 2:58
Ramkumar_S29-Dec-10 2:58 
AnswerRe: codeproject Forum Pin
Hiren solanki29-Dec-10 3:10
Hiren solanki29-Dec-10 3:10 
GeneralRe: codeproject Forum Pin
Ravi Sant29-Dec-10 4:21
Ravi Sant29-Dec-10 4:21 
GeneralRe: codeproject Forum Pin
Sandesh M Patil29-Dec-10 6:00
Sandesh M Patil29-Dec-10 6:00 
AnswerRe: codeproject Forum Pin
Not Active29-Dec-10 3:14
mentorNot Active29-Dec-10 3:14 
AnswerRe: codeproject Forum Pin
RaviRanjanKr29-Dec-10 5:45
professionalRaviRanjanKr29-Dec-10 5:45 
GeneralRe: codeproject Forum Pin
Ramkumar_S29-Dec-10 6:50
Ramkumar_S29-Dec-10 6:50 
AnswerRe: codeproject Forum Pin
Ramkumar_S29-Dec-10 6:52
Ramkumar_S29-Dec-10 6:52 
QuestionRead files on my local machine Pin
abbd29-Dec-10 0:47
abbd29-Dec-10 0:47 
AnswerRe: Read files on my local machine Pin
Manfred Rudolf Bihy29-Dec-10 0:56
professionalManfred Rudolf Bihy29-Dec-10 0:56 
QuestionRe: Read files on my local machine Pin
abbd29-Dec-10 2:30
abbd29-Dec-10 2:30 
AnswerRe: Read files on my local machine Pin
Not Active29-Dec-10 3:08
mentorNot Active29-Dec-10 3:08 
QuestionAdd Content to dymanic TabPanel Pin
treuveni28-Dec-10 21:26
treuveni28-Dec-10 21:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.