Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript / report generation

Status
Not open for further replies.

teash

IS-IT--Management
May 3, 2005
99
US
Hello everyone,

Does anyone have any suggestions that will allow me to dynamically generate a report and print it on one page.

I tried using HTML to code, but the table sizes, and in turn layout changes based on the amount of data that is reported. Basically spuratic behavior.

I also used the word.application object, however when I generate the report on the client side, I do not have access to the server side data. Of course, I could POST it to the client however its sloppy posting thar much data. I also looked into some XMLHttp object that allows access to server data, however it looked more difficult to implement.

If I generate it server side, the word application opens on the server and with a handful of people doing this I don't think this is a valid idea either.

My boss doesn't want to spend money on any active com's, so I am limited to "freeware" and "open source". And these two words seem to be taboo in the ASP world. (I wish it was PHP).









 
Well, this is really an ASP Forum question and not a VBScript Forum question. For example your ASP pages might be written using darned near any supported scripting language (JScript, VBScript, or a third-party add-on language). The issues remain the same.

You can't POST anything to a client, POST is a server request method. Your ASP pages respond to client requests.

You could probably try automating Word on the server side. But this is wrong for numerous reasons, as Microsoft has repeatedly tried to tell people.

INFO: Considerations for Server-Side Automation of Office


You haven't been totally clear about what you want to accomplish though. I'll take a stab at rephrasing and assume you'll post a reply correcting my misunderstandings:

Assumption:

You want a browser client to make a server request, possibly with parameters sent to the server, that will return a nicely formatted printable report based on server-side data.


In such a case here's one thing I'd try:

Provide the client a "report request" page containing an HTML <FORM> with elements in which to specify parameter data and a "Submit" button element.

Set the <FORM>'s TARGET attribute so that the result will be returned in a new browser window, from which the report will be printed or saved to disk by the user.

Set the <FORM>'s ACTION attribute to make a GET/POST request of an ASP page that will produce the report.

Write that ASP page to return a result in RTF markup, setting Response.ContentType to "application/rtf" or something appropriate. Microsoft gives examples where they create an RTF document as a server-side file named <some name>.doc and return a redirect back to the browser window, perhaps to force the browser to try to open it in Word:

How to use ASP to generate a Rich Text Format (RTF) document to stream to Microsoft Word


This might be your best bet, perhaps there are other solutions you can use (like returning plain text with Response.ContentType = "text/plain").

You might even find a nice free component to use that will make it easier to create RTF output. Otherwise consult:

Rich Text Format (RTF) Specification, version 1.6

You culd also create some very simple documents in WordPad, save them as RTF, and then open the saved file in NotePad or something to examine the markup.

I can't imagine how "PHP" is going to make much difference to your problem here though.
 
Thanks for the long reply. I did question rather this was the right forum or not, but I am using VBScript/js for my ASP pages and so my reasoning was to get VBScript oriented answers.

PHP would be nice because there are so many more free code out there so I didn't have to reinvent the wheel.
If you want useful ASP code, your paying!

Your assumptions were correct, this is what I wanted.
More precisely I need to generate a purchase order. Sometimes the order has 1 part, sometimes 10. The word object seemed to be the answer because I could lay out the purchase order and use a "TextReplace" function to look through the document. This is slo I have to loop through the entire document more than 100 times!! And I know there has to be a better way.

I will check into the RTF file format. Maybe this will work.


Thanks again.
 
I don't get why using HTML was a problem for you. Specify the width of your columns to keep the formatting under control. The length would of course scale to fit your data but I would think that would be desireable. If it is not then specify the height of your table cells and before putting data in a cell specify the number of characters you wish to fill in the cell and only put that number of characters in there.

Example:
Code:
[maroon]<%
longtext= "There is a tide in the affairs of men which taken at the flood leads to great fortune."

shorttext= left(longtext,15)
%>[/maroon]

<html>
<body>
<table>
<tr><td width="300">
[maroon]<%
Response.Write shorttext
%>[/maroon]
</td></tr>
</table>
</body>
</html>

I hope you find this post helpful.

Regards,

Mark
 
HTML would be nice, but I guess I lack the advanced knowledge to really get the full use out of HTML.

I need the data to print out on 1 piece of paper. I have limited the purchase order to 10 items, so I can get a "max" length of the html table.

RTF format is a painnnn! Yeah the basics are simple, but images and tables complicate the issue as I have learned.

If I specify the width and height of a cell, they always seem to "adjust" by themselves which is a bit of a problem.
So either I need to limit the data in each cell, or figure out how to stop a table from getting expanding.

So I am not sure which boat I am in. HTML or RTF.



 
Again, specify the table height and width.

If you are nto strong in HTML you should check out w3schools.com for some free training.

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top