Project 4
In this project you need to demonstrate all your knowledge about WSH. You need to write a script that reads a text
file and converts it to either Excel, Word, or HTML format. This script also needs to connect a network printer and
print the file to the printer if needed.
This script should take one unnamed argument and a set of named arguments. The unnamed argument is a text file
that has the following format: each line of the file contains the name of a student and grades of the student.
fields separated by tabulation symbols. If one or more grades are missed, then you may encounter two or more
sequential tabs. Here is an example of a file
Smith, Bob 87 94 78 23 78
Miller, David 94 78 68 87
Gold, Sam 78 87 68 86
Li, Sheng 99 99 86 68 80
Your script should start Excel and read the whole file into the excel table. The very first row of the table should
contain names of the columns ("Name Exam1 Exam2 Exam3 Exam4 Exam5 Sum"). Please add the Sum column at the end of
the table and also add the last row that should contain the average value of each column. You script should also make
the table looking good. For example the file above should look like
The named arguments are:
- out - [required] the name of the output file. Just the name, not the extension.
- format [optional] can be of the three choices: Excel, Word, or HTML.
- If the format is equal to Excel, you don't need to do anything extra but save the file.
- If the format is equal to HTML, you need to save this file in the HTML format.
- If the format is equal to Word, you need to save this file as usual excel file, open MS Word, load this
excel into the Word document, and save it as a word document.
The default value is Excel.
- print - [optional] boolean argument. If this argument is set, you need to print the Excel file before
exiting the Excel application.
- nwprn - [optional] a string argument containing a name of a network printer. If this argument is given,
you script needs to connect this network printer and make it to be a default one before printing.
If the script is not given enough arguments, it should use ShowUsage() method of the WScript.Arguments
object. That means, of course, that you need to write your script as WSF file and specify all the arguments
of the script inside the <runtime> tag.
- You may use either JScript or VBScript for this project or both.
- You have to use try...catch statements to handle all possible errors.
- You should not think that the input file has exactly 4 lines. It may have any number of lines.
- You should not think that students have exactly 5 exams. They may have more that 5 or less.
Due day is Sunday, May 2, 2004 at 11:59pm.