I am working on implementing exporting data to Excel functionality in ASP.Net and as part of that an image stored in the database has to be exported to Excel along with some other content. I am able to write the content to Excel by referring to the required
cells. Is it possible to write the image byte stream read from the database which is in the form of byte[] directly to Excel sheet without saving that to physical disk?
Please suggest how to write image byte stream to Excel without saving the image to physical disk?
ranumula
Member
20 Points
23 Posts
Exporting image byte stream to Excel
Jun 21, 2010 12:09 PM|LINK
Hi,
I am working on implementing exporting data to Excel functionality in ASP.Net and as part of that an image stored in the database has to be exported to Excel along with some other content. I am able to write the content to Excel by referring to the required cells. Is it possible to write the image byte stream read from the database which is in the form of byte[] directly to Excel sheet without saving that to physical disk?
Please suggest how to write image byte stream to Excel without saving the image to physical disk?
Thank you,
Raghu
Export image to Excel
singhmanish_...
Participant
894 Points
167 Posts
Re: Exporting image byte stream to Excel
Jul 10, 2010 07:28 AM|LINK
Well i haven't tried what exactly you want to achieve but i managed to render a report content having images from binary format.
I suggest you to use Response object of ASP.Net.
Here is a sample code snippet..
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/excel";
Response.BinaryWrite(byteData); // Writing byte[] array
Response.Flush();
Response.End();
Manish
Please 'Mark As Answer', if one or multiple posts helped you in your problem so that it might be useful for others.
itsmemuthu
Contributor
3743 Points
655 Posts
Re: Exporting image byte stream to Excel
Jul 10, 2010 10:45 AM|LINK
refer this
http://wiki.asp.net/page.aspx/685/export-image-to-excel-using-c/
http://www.aspspider.com/resources/Resource347.aspx
hope this helps..
Muthu
Remember To Click Mark As Answer On the Post That Helps U
M_Sharma
Member
9 Points
6 Posts
Re: Exporting image byte stream to Excel
Sep 20, 2010 10:43 AM|LINK
No you can not export image into excel by .net use third party control :-)
Dylan Cliffo...
Member
8 Points
4 Posts
Re: Exporting image byte stream to Excel
Feb 15, 2013 05:27 AM|LINK
Hi,
you can use this .Net component to insert image byte stream to Excel.
Look at this C# example:
ExcelWorkbook wb = new ExcelWorkbook(); wb.Worksheets.Add("sh1"); wb.Worksheets[0].Cells[0, 0].Value = "Vasya vodit volvo"; ExcelWorksheet Wsh = wb.Worksheets[0]; Wsh.Pictures.Add(new MemoryStream(buf)); //buf is your byte[] array Wsh.Pictures[0].SetPosition(0, 0, 1, 1); wb.WriteXLSX(@"c:\output.xlsx");