Link to home
Start Free TrialLog in
Avatar of mohaned
mohaned

asked on

How to make printable ASP reports

i was developing  project using ASP and SQL Server 2000
, and  i retrieve data from Back-End (SQL) to Front-End(HTML)
and show it in html table.
i want make JUST data in this table to be printable in formatted reports.
Thanx in advance
 and sorry for my english
Avatar of VirusMinus
VirusMinus
Flag of Australia image

you could output the data into a page and display that page in an iframe. Additionally in this iframe you could put a print button via javascrip like this ->  <script>
if (window.print) document.write('<form><input type="button" onClick="window.print()" value="print"></form>');
<script>
Avatar of suramsureshbabu
suramsureshbabu

ASKER CERTIFIED SOLUTION
Avatar of jmelika
jmelika

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this. It will make your ASP page create Word or Excel reports :)

At the top of your ASP page, add these two lines for Word:

<% Response.ContentType = "application/ms-word" %>
<% Response.AddHeader "Content-Disposition", "attachment;filename=myreport.doc" %>

Or these for Excel.

<% Response.ContentType = "application/ms-vndexcel" %>
<% Response.AddHeader "Content-Disposition", "attachment;filename=myreport.xls" %>

Make sure to open new IE windows for changes to take effect.
Of course to do that, your IIS web server must have Office (both Word and Excel) installed and ready to go, correct?
No, office is needed on the client only to view the files (If you don't have office even on your client, you can still download the file and view it on another PC).
Avatar of mohaned

ASKER

May be the simple solution is combination of answer from VirusMinus  and answer from jmelika
but i thought it is an other tools (may be an individual software  ) to prepare and format a report firstly before previewing and printing it.
Mohaned,

It's really all about designing a layout of your table, and displaying your data in them using Response.Write with a loop.  If you're having difficulty with any of those things, feel free to ask for mroe help and we'll be here.

Good luck!
JM