.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Unable to render image to excel

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :ASP.Net

Hi All,

 I have an image loaded in a div element. (This image will be added dynamically thru JS, based on the option selected by the user).

I have a requirement to open this image in Word, Excel and Pdf applications when those icons (given in the page) are clicked, respectively.


                Response.AddHeader("content-disposition", "attachment;filename=ComparisonData.xls");
                Response.Charset = "";
                Response.ContentType = "application/vnd.xls";
                StringWriter stringWrite = new StringWriter();
                HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

The same code works fine to render a gridview in excel, but not an image. I also tried placing the image element in a table tag.

Please advise.

Thanks in advance.



View Complete Post

More Related Resource Links

Excel Services in the 2010a Image -- Excel Servcice in General ( no success)

On the WebApp that hosts the Project service portion of the demo (finweb) has anyone gotten Excel Services to work ?  I get a bunch of internal errors when I attempt to use this service..  I am also having problems getting Excel Service to work (in general) -- are there any particular small animals that need to be sacrificed in order to get Excel Services to work? I'm using Kerberos on a single box ( been through the Kerberos whitePaper) -- On my development server, I am authenticating OK (Fiddler) but the page that is returned ends abruptly before the grid is created. It's not the browser because I can view the samples at WssDemo...   Suggestions -- I've done a couple of re-installs all the back to IIS -  All science is either physics or stamp collecting

render as date in excel

I have a hard coded date in the expression editor and i need to pass the date a formatted as date when it moves from SSRS to Excel.   I have tried to put ="MM/dd/yy" as the date format in the properies of the text box but no luck - so in the expression editor I have ="01/01/01" and it needs to be formatted as a date in excel when it gets there.

Unable to export data to an excel file in grid format!!!

I'm exporting data to an excel sheet from the ojects list. The data is exporting to excel sheet well, but I'm unable to see the grid format for the data. The data is looking with out the rows and columns lines. I think I'm missing to set some property or somethnig ehwn exporting.   Any help would be really appriciated.

Exporting image byte stream to Excel



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,


SSRS 2005 Render Format Excel Issue with Time Field


I have a report that uses a datetime field but gets populated only with the time. So, in SQL db, it gets stored with a default date value of 1899-12-30 12:01:01 with the correct time filled in. Report in SSRS Preview mode displays the value just fine when I use the Time format in Layout mode. I build and deploy and able to view the report in a web browser with no problem displaying the time field. But when I subscribe to the report and choose Excel render format, when I open up the Excel file from the email that was sent, I get negative decimal values. I have tried every possible Time format in SSRS but I get the same result. I also tried just the default and still gives me negative decimal values that show up as ####### in Excel.

Any help will be greatly appreciated. Thanks

Error Message PowerPivot Excel on SharePoint : "Excel was unable to get necessary information about


Hello everybody:

I get the error message “Excel was unable to get necessary information about this cube. The cube might have been reorganized or changed on the server” when I open the excel on the sharePoint site and the PowerPivot Datasource is already refreshed successfully on schedule.

I describe my steps more clearly.

  • Step1. Create Excel pivot tables and charts by using PowerPivot datasource which connects to SQL Server.
  • Step2. Publish Excel to SharePoint site. The Analysis Server will build a PowerPivot cube in "VertiPaq" StorageEngineMode automatically and the cube name including an "uniqueindentifier" in the end.
  • Step3. Schedule PowerPivot refresh plan on SharePoint and the successful result comes out soon. After PowerPivot refreshed the "uniqueindentifier" will be changed to another one automatically.
  • Step4. When I open excel on the SharePoint I will get the error message again. If I click the "ok" then Excel will really Refresh.

Now I have tried two ways:

  1. Locale setting: Doesn't work. It seems not to be the cause of my problem because it won't happen if my excel's datasource is connecting to DB or Cube directly.

    Render Image from FileUpload on Browser




    I am developing a .Net Page that will contain a FileUpload box so a user can upload images to the site. I would like the functionality that when someone chooses a file to upload (before they actually upload the file), they can preview it on the browser. I know I can do this through some javascript magic, but is there anything that can be done using AJAX tools to gain this functionality. Thanks for any help that you can come up with.



Unable to connect Excel 2003 from linked server in sql 2008 64 bit


I was unable to connect to excel 2003 with linked server created in sql server 2008 64 bit. This was working fine with sql server 2005 32 bit.

I know that there no 64 bit drivers for JET drivers, but i am looking for some alternative ways to do the same job.

I dont want to migrate to Excel 2007.

Thanks in advance for all your help.


Unable to open an Excel File in Sharepoint MOSS 2007


I am unable to open an excel file in Sharepoint (MOSS 2007). All other documents work fine. As far as I know there was no change on the Server at all.

Excel found unreadable content in 'stuff.xls'. Do you want to recover the contents of this workgroup? If you trust the source of this workbook , click Yes

When I click YES >> It says "Excel recovered your formulas and cell values, but some data may have been lost." And then a link to an xml file , which reads :

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
  <summary>Errors were detected in file 'http://server_name/Project_name/Shared Documents/abc - def/Phase 5/Track/stuff.xls'</summary>
- <additionalInfo>
  <info>Excel recovered your formulas and cell values, but some data may have been lost.</info>

Now this has resulted in huge loss of data and I can see New numbers in the cells which is very strange!

Is there a way I can get it back ? I do not have a

Unable to save Excel files opened from SharePoint

Hi all!

From time to time users have problem saving excel files that they have opened from a SharePoint document library.

Error message:

"Document could not be saved"

It's not possible to save it localy ither.

Any ideas?


Excel Render - Print Header on Each Page


Hello Microsoft or Forum Members:


This seems like a simple Microsoft Based Reporting System 101 feature...But I can not find out how to do it (among other things that seem like it should work with Microsoft rendering to Microsoft).


How do I make the SSRS 2005 Header for the Report print on each of the pages in excel once it is rendered from SSRS?


All I want is an answer by MSFT that says "YES" it can be done and how or "No" it is not currently available.


I noticed I am not the only one with this type of simple question:

(see this unanswered post)


How to insert Binary Image data from XML To Excel using XSLT


Hi All,

I had created a XSLT which converts the XML file generated from the system to the excel format. The XSLT has the styles required for this transformation.

Now i am told to insert image in one of the excel columns using XSLT. The image is in binary code format in the XML file.

Tried to google but could not found the syntaxes for this. Let me know if anyone has done the image embedding in excel using XSLT.


ASP.met Export image to Excel


Hi there,

How could we Export an image to Excel on top of a gridview, using Respone.Write

Thanks in advance

Unable to Authorize Launch Permissions for missing "Microsoft Excel Application" in DCOM Config



I would like to develop Excel charts programatically using VB .NET and the Microsoft Excel 11.0 Object Library (http://www.beansoftware.com/asp.net-tutorials/generating-excel-reports.aspx).  To accomplish this, I need to authorize the aspnet user on my machine launch permissions on "Microsoft Excel Application" DCOM (http://blog.crowe.co.nz/archive/2006/03/02/589.aspx).  I tried using dcomcnfg.exe to do this, however, I cannot find the "Microsoft Excel Application" DCOM under DCOM Config.

I am developing on a Windows XP (work machine) using Office Excel 2003

Why is the ""Microsoft Excel Application" missing in DCOM Config? More importantly, how can I give aspnet launch privileges to if Microsoft Excel Application DCOM is missing in DCOM Config?



Read Image from excel file Issue


Hello every one.I'm trying to read images from an excel file using OleDbDataReader. My excel file has 6 columns of data, the first 5 are all text but the last is image. While I'm reading the record, It's doing fine on the first 5 columns but return me with a "blank" for the sixth column.

Here is my demonistration code:

  protected void btnImportExcelFile_Click(object sender, EventArgs e)

      string strConn;
      strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
      "Data Source=C:\\exceltest.xls;" +
      "Extended Properties=Excel 8.0;";
      OleDbDataAdapter myCommand = new OleDbDataAdapter("SELECT * FROM Sheet1$]", strConn);

      DataSet myDataSet = new DataSet();
      myCommand.Fill(myDataSet, "Sheet1");
      DataGrid1.DataSource = myDataSet.Tables["Sheet1"].DefaultView;


<asp:Button ID="btnImportExcel

Unable to import from Excel on 64-bit Win 7 workstation to a 32-bit Windows 2003 Server running SQL



I recently moved from Windows XP to Windows 7 on my primary workstation, and since then I'm unable to import from Excel to SQL from any of my SSIS scripts when I run them Locally.  The one instance I'm running into now is importing from Excel 2010 on my system (64-bit Windows 7) to SQL Server 2008 running on 32-bit Windows Server 2003. 

Microsoft SQL Server 2008 (RTM) - 10.0.1600.22 (Intel X86)   Jul  9 2008 14:43:34   Copyright (c) 1988-2008 Microsoft Corporation  Standard Edition on Windows NT 5.2 <X86> (Build 3790: Service Pack 2)

I even tried creating the import through SSMS and saving it as an SSIS script to get the same results.  The only thing I can think of is the change of architecture on my workstation.  I'm running 64-bit Windows 7 and the server is 32-bit Windows Server 2003 and SQL Server 2008.  Below is the Validation text SSIS returns:

Validation has started
[SSIS.Pipeline] Information: Validation phase is beginning.
Progress: Validating - 0 percent complete
[Source - Sheet1$ [1]] Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER.  The AcquireConnection method call to the connection manager "SourceConnectionExcel" failed with error code 0xC00F9304.  There may be error messages posted before this with more

Unable to render grid on view



Hi Friends,
I have problem to bind grid in mvc. When I bind model with simple table then data displayed. But not in grid .
Controller : 
using Telerik.Web.Mvc;
using TIS.Security.ServiceProjet;

namespace TIS.CON.Mahidharpura.Controllers
    public class RoleController : Controller
        RoleManagerService rms = new RoleManagerService();
        public ActionResult Index()
            IList<RoleService> rs = rms.GetRoles();
            return View(rs);


View : 
@model List<TIS.Security.ServiceProjet.RoleService>
    ViewBag.Title = "Index";

@*Simple Table*@

@foreach (var item in Model) { 
            @Html.DisplayFor(modelItem => item.RoleID) 
            @Html.DisplayFor(modelItem => item.RoleName) 


        var grid = new WebGrid(Model, canPage: true, rowsPerPage: 5,selectionFieldName:"SelectedRow" );
        @grid.GetHtml(tableStyle: "webGrid",
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend