Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3 return File action causes intermittent Excel program error
    primarykey
    data
    text
    <p>I have a problem that closely relates to this problem <a href="https://stackoverflow.com/questions/5063742/microsoft-excel-error-there-was-a-problem-sending-the-command-to-the-program">Microsoft Excel Error: &quot;There was a problem sending the command to the program.&quot;</a> whereby opening Excel gives <code>There was an error sending a command to the program</code> error.</p> <p>However, rather than the file existing and being opened or shortcutted-to, <strong>I am using MVC3</strong> with an action that generates a bunch of data, <strong>generates an excel file</strong> (using <a href="http://npoi.codeplex.com/" rel="nofollow noreferrer">NPOI</a>), writes it to a MemoryStream and then chucks that to the browser using the built-in <code>return File(etc)</code> ActionResult, with something akin (but shortened here to aid readability) to this:</p> <pre><code>return File(myMemoryStream, "application/vnd.ms-excel", "filename.xls"); </code></pre> <p>The first time you click the link which fires this action and returns this File - it comes up with the error. if you press ok and try it again it works, and will continue to work... forever</p> <p>Now I know this is potentially something to do with <strong>disabling DDE/plug-ins</strong> or something in Excel - but since I'm generating an excel workbook and dumping it to a memory stream rather than opening something that exists permanently on the file system, <strong>I'm not sure</strong> what options I have to remove the issue.</p> <p>Any suggestions on how to get around it? Perhaps I have the wrong mime-type?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload