[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to make printable ASP reports

Posted on 2004-11-08
8
Medium Priority
?
308 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:mohaned
8 Comments
 
LVL 30

Expert Comment

by:VirusMinus
ID: 12521906
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
 
LVL 7

Expert Comment

by:suramsureshbabu
ID: 12522112
0
 
LVL 9

Accepted Solution

by:
jmelika earned 500 total points
ID: 12549187
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:abdullah716
ID: 12551296
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
 
LVL 9

Expert Comment

by:jmelika
ID: 12557055
Of course to do that, your IIS web server must have Office (both Word and Excel) installed and ready to go, correct?
0
 
LVL 6

Expert Comment

by:abdullah716
ID: 12557779
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
 

Author Comment

by:mohaned
ID: 12612624
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
 
LVL 9

Expert Comment

by:jmelika
ID: 12617294
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

868 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question