title: Creating Spreadsheet from SQL using ASP - Can I attach macros?
body: <p>So I have been using ASP for all of a week now and perhaps this is something that I just can't do, but I am trying to dynamically generate reports from data stored in a SQL database. I am publishing the reports through an ASP document and displaying by specifying Excel for the MIME content type:</p>
  
  <pre><code>    Response.Buffer = TRUE
      Response.ContentType = "application/vnd.ms-excel"
  </code></pre>
  
  <p>Is it at all possible to "attach" macros to the document? I understand I can do basic formatting in the HTML, but I would prefer to import the desired database data and handle it within excel via macros.</p>
  
  <p>EDIT:
  I have several reports I need to generate but for one example:</p>
  
  <ul>
  <li>I want to load retrieved data from the database into a sheet in excel. </li>
  <li>Attach Macro</li>
  <li>Begin Macro: 
  <ol>
  <li>Hide the specified sheet. </li>
  <li>Programatically create new sheets for categories of data. </li>
  <li>Format sheets.</li>
  </ol></li>
  </ul>
  
  <p>The question is not about how to program the macro, just whether or not a macro can be attached and how to achieve this. In regards to alerts upon opening the sheet, if I can attach macros I should, theoretically, be able to suppress those in the Open Workbook event.</p>
  
  <p>EDIT: I believe I can achieve the desired result by using OWC (Office Web Components) (see <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;288130" rel="nofollow">http://support.microsoft.com/default.aspx?scid=kb;EN-US;288130</a>). However, I am not sure if I will be able to install it on our Web Server. Any other suggestions?</p>