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
mohanedAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

VirusMinusCommented:
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>
0
suramsureshbabuCommented:
0
jmelikaCommented:
Mohaned,

Best way is to display it in a table format.  Of course it all depends on how you want it to look, etc.  For instance, if your SQL statement pulls 4 fields out of the table, you'd want it to look like this:

<table>
  <tr>
    <td>Field1</td>
    <td>Field2</td>
    <td>Field3</td>
    <td>Field4</td>
<%
' open your DB then run your SQL statement in rs RecordSet
Do Until rs.EOF
  Response.Write "<tr>"
  Response.Write "  <td>"
  Response.Write      rs.Fields("Field1")
  Response.Write "  </td>"
  Response.Write "  <td>"
  Response.Write      rs.Fields("Field2")
  Response.Write "  </td>"
  Response.Write "  <td>"
  Response.Write      rs.Fields("Field3")
  Response.Write "  </td>"
  Response.Write "  <td>"
  Response.Write      rs.Fields("Field4")
  Response.Write "  </td>"
  Response.Write "</tr>"
rs.MoveNext
Loop
%>
</table>

Now you have the table displaying all of your records.  You could have that page opened either in an iFrame like VM suggested, or in a new window <target="NewWindow"> in your form or or whatever you do to start this SQL report process.  You could also implement the javascript to easily print it at the bottom of the page.

Good luck!

Eshta
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

abdullah716Commented:
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.
0
jmelikaCommented:
Of course to do that, your IIS web server must have Office (both Word and Excel) installed and ready to go, correct?
0
abdullah716Commented:
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).
0
mohanedAuthor Commented:
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.
0
jmelikaCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.