Practical Exercises: Spreadsheets, Composite Documents & HTML Conventions: Bold type is used to refer to Buttons and menus on the screen in Word and other applications. This Sans-serif font is used for examples. Italics are used for emphasis. Table of Contents Some Preliminaries .................................................................................................................... 2 Excel Spreadsheet ...................................................................................................................... 3 Introduction ............................................................................................................................ 3 Exercise X1 – Creating a Spreadsheet .................................................................................... 3 Exercise X2 – Changing the look and style ............................................................................ 4 Exercise X3 – Adding Formulae ............................................................................................ 4 Exercise X4 – Adding a Row to a Spreadsheet ...................................................................... 5 Exercise X5 – Making a Graph of the Data ............................................................................ 5 Exercise X6 – Multiple Sheets ............................................................................................... 5 Exercise X7 – Dynamic Linking ............................................................................................ 6 More Advanced Excel Functions – see p.12 .......................................................................... 6 Advanced Word Techniques ...................................................................................................... 7 Exercise W1 – Building a Word Template ............................................................................. 7 Exercise W2 – Updating Normal.dot ..................................................................................... 7 Exercise W3 – Inserting a Table of Contents ......................................................................... 8 Exercise W4 – Inserting Cross-References ............................................................................ 9 Composite Documents ............................................................................................................. 10 Exercise C1 – Producing a Spreadsheet ............................................................................... 10 Exercise C2 – Making a Graph of the Data .......................................................................... 10 Exercise C3 – Making a Drawing......................................................................................... 10 Exercise C4 – Adding a Picture to the Document ................................................................ 10 Exercise C5 – Adding a Table to the Document .................................................................. 11 Exercise C6 – Adding a Graph to the Document ................................................................. 11 Exercise C7 – Adding an Object .......................................................................................... 11 More Advanced Excel: Exercise X8 – Currency Converter .................................................... 12 Databases .................................................................................................................................. 13 Definitions ............................................................................................................................ 13 Basic database management techniques ............................................................................... 13 Access Databases ..................................................................................................................... 14 Exercise A1 – Setting up a Database .................................................................................... 14 Exercise A2 – Creating Queries ........................................................................................... 14 Exercise A3 – Database with two tables .............................................................................. 14 Exercise A4 – Database + Mail Merge Exercise 1 ............................................................... 15 Flat File Database Management Exercises using MS Excel .................................................... 17 Exercise D1 – Manipulating a simple Excel “database” ...................................................... 17 Exercise D2 – Mail-merging from an Excel table ................................................................ 19 Results for Module BS1904 – Computer Applications ........................................................ 19 Editing Internet Web Pages ...................................................................................................... 20 Exercise – Working with HTML Source .............................................................................. 20 References ................................................................................................................................ 20 BS1904 (2008) Practical Exercises Page 1 Some Preliminaries You are advised to work using Windows Explorer, so that you can navigate easily to the piece of work that is of interest, and get Windows to open it with the appropriate application. At home, it’s easy to start Windows Explorer – just hold down the Windows key and press E. That won’t work in College, as the function of the Windows key has been inhibited on student accounts to stop people leaving machines locked and thus keeping others off a machine that’s really not in use. To get round this, you should add a shortcut to your desktop: 1. Right-click the Start button, and select “Explore” – this will start Explorer on your Start menu 2. Make sure Explorer is not full-screen, and that you can see a bit of desktop 3. Click on Programs in the Left pane, then on Accessories 4. Find Explorer in the Right pane 5. Using the Right mouse button, drag the object on to the desktop (if you drag with the left button, Explorer will vanish from your Accessories menu) 6. When you release it, you’ll get chance to create a shortcut on the desktop 7. Finally, right-click anywhere on the desktop background, and sort the icons as you wish. Stop Windows from hiding useful information It’s very confusing not to be able to see the file extension. For example, you can end up with multiple files that all seem to be called fred but three of them are really fred.docx, fred.doc and fred.dot, and two more are fred.html and fred.htm (worse still, the last two even have the same icon and description shown in a details view). Unfortunately, this is the default state of Windows, and you need to change it to avoid problems later, particularly with HTML. Please go into Windows Explorer and do the following: Pull down Tools Select Folder Options.., and then choose the View tab. Find the check-box that says “Hide extensions for known file types” and uncheck it. Click OK to apply the change and close the dialogue. This change will give you added information in Word, Excel, and other applications. You may have to repeat this process if your UC Winchester account has to be reset for any reason. Getting the best out of Windows Explorer The remaining settings in Explorer are down to personal preference – there are some people who actually like scrolling through a window full of large icons without dates or sizes! However, I find the following layout best in most situations. View the folders in the left-hand pane (press the Folders button if the pane is a blue mess); Change the View to Details – that way you can see date, time, and other details; Sort into a sequence that suits you – I find descending order of date best, as it puts the stuff you last worked on right at the top; Finally, to make sure that you get the same view next time, save these settings: BS1904 (2008) Practical Exercises Page 2 Pull down Tools Select Folder Options.., and then choose the View tab Press the Apply to all folders button Say Yes on the dialogue asking you to confirm. This will become your default view. Excel Spreadsheet Introduction A spreadsheet is essentially a computerized calculator that allows many calculations to be made at the same time. These calculations may be linked (or independent), and can be combined in complex ways to carry out sophisticated modelling applications. The spreadsheet started life as a manual tool in Finance, but didn’t enter common use until the first computer version – VisiCalc. Most of the skills you’ve practised on Word are equally applicable to Excel. Selection, Cutting, Copying, Pasting, and format operations are general to all “well-behaved” Windows applications. Microsoft® Excel uses the notebook metaphor, which lets you group related subjects, and then select one of them using a tab. “Right-clicking” almost anywhere in Excel will bring up a context-sensitive menu that usually offers most of the facilities you’re likely to want at that point. Exercise X1 – Creating a Spreadsheet 1. Open Excel (from the Start menu). 2. Save it – give it a name you can remember (like supermkt.xls) in a suitable folder (you may want to create a new folder using the tool in the “Save As” dialogue). 3. Select a cell for data entry. You’ll see a border round it, and anything you type will appear at the top of the spreadsheet. 4. Move to another cell, either with the mouse, or by pressing the cursor keys. 5. Enter the supermarket spreadsheet as shown below, starting with the Item heading in cell C6 and the Supermarket names in cells D6 through G6 (D6:G6). Leave row 7 blank and enter products and costs in cells C8:G10 It doesn’t matter much if you don’t put entries in exactly these cells, but if you don’t, it will invalidate the cell addresses given in subsequent instructions. Item Tea Coffee Sugar Waitrose 1.4 1.45 0.9 Tesco Sainsbury 1.2 1.56 1.09 1.25 1.5 1.21 Asda 1.15 1.5 1.2 6. Many of the following operations require you to select a group of cells. Do this by clicking on the cell at one corner of the group, and dragging the mouse cursor to the opposite corner of the group. When you release the mouse button, all the cells in the group will be in highlighted, except for the first, which has a border round it (this is the one that’ll be changed by any typing you do). Clicking any cell outside the group removes the selection. Practise selecting groups of cells. 7. Save the spreadsheet as supermkt.xls (you should first create a samples folder in My Documents). You can then recover what you’ve typed, regardless of any later errors or BS1904 (2008) Practical Exercises Page 3 power-failures. As everywhere in computing, it’s important to Save whenever you are ready to commit what you’ve done. Exercise X2 – Changing the look and style 1. Change the number format by selecting the cells containing the numbers (D8:G10), clicking the right mouse button to bring up a context-sensitive menu, and selecting Format Cells to work on the format of the block of cells you had selected. In the Category column, select Currency, and leave the number of decimal places as two. Click OK to apply the changes. 2. Ensure that the number entries are selected (as above), and align the numbers centrally in the cells using the Formatting toolbar. If you can’t see this toolbar, pull down the View menu and make it visible. The alignment buttons consist of a series of horizontal lines – not surprisingly, central alignment has these lines centered on the button. 3. Select the names heading the columns (C6:G6). Click the B button to make them bold. 4. With these cells still selected, increase the point size of the using the font item on the toobar. 5. If a name is now wider than its cell, widen the cell by placing the mouse cursor in the column identifier row (marked A, B, C… beneath the spreadsheet title bar) and position the cursor across the boundary separating the column from the one on its right. When the cursor changes to a double-headed arrow, click and drag the cursor to the right to widen the cell. Repeat this action for the other columns as necessary. 6. See if you can find another way to do this (hint: select the columns, then pull down the Format menu). 7. Select the names and change their background colour by invoking Format Cells and choosing the Patterns tab 8. Select all cells in the table (C6:G10) and expand the row height by pulling down the Format menu and selecting Row then Height, and changing the height to 20. Click OK to apply the change. Exercise X3 – Adding Formulae 1. First calculate the total cost of items from the Waitrose Supermarket. Move the cursor to cell C12, two rows below the final item (Sugar) in the first column of the table. Type the word Total. 2. Begin to create the formula for summing the cost of items in the first column. There’s a short-cut for this, using the big Sigma () on the tool-bar. Select the cell where you want the total to appear (D12). Next press the Sigma, and Excel will generate a formula containing =SUM(D8:D10). SUM is a function that adds up the cells listed in its argument (the stuff inside parentheses). Note the dotted line that appears round the cells being added up – you can change them by dragging with the mouse. Accept the formula by clicking on the green tick near the top of the sheet. Check that the answer makes sense. 3. Next click on D12 to find how it was done. In the entry box, you’ll see the formula =SUM(D8:D11) You could have typed this in yourself, or just typed the name of the function, =SUM(, and then entered the range by dragging across the relevant cells with the mouse. 4. Try an alternative method of entry to work out the total in the Tesco column. 5. Next select one of the cells containing a total, and press the Copy button. 6. Select the two cells that don’t yet have totals, then press the Paste button. Check that the values make sense, then look at the formulae that have been entered into them. Note that the BS1904 (2008) Practical Exercises Page 4 column letters were modified when you copied the formula. This is a very powerful feature of spreadsheets. 7. Add a column to the table to calculate the average cost of an item across all the supermarkets. For this purpose, use the formula: =AVERAGE(start_cell_reference:end_cell_reference) where you determine the actual start and end cell references, e.g. E8:H8 for an average in I8. Do not type the words shown in the script font! 8. Provide averages for each item (row). Exercise X4 – Adding a Row to a Spreadsheet 1. Click on the row number to the left of the Coffee cell (C9); this selects the entire row. Right-click to bring up a context menu, and click on Insert; a new row will be inserted. Note: if you had just selected a cell, rather than the whole row, Excel would have needed to find out what you wanted to insert. It does this by opening an Insert dialogue box, which allows you to insert columns or rows. 2. Inspect the cells containing formulae, and note how these have been updated to reflect the fact you have inserted within a range. 3. Enter Biscuits in this column and the prices 1.06, 0.99, 1.25 and 1.05 in the cost columns (D9:G9). Note how the column totals have automatically changed to reflect these insertions. 4. Add the average title cell, and adjust the alignment of names and numbers as necessary. Exercise X5 – Making a Graph of the Data 1. To draw a graph, you must first select the data to be plotted, including the names (in this case, products and store names). Select the required data (block C6:G11), omitting the Totals. Click on the Graph tool in the Toolbar. Work through the Chart Wizard to construct a column or bar chart. It’s probably best to put the graph immediately below your table of figures. 2. Change one or more entries in the table to see how the graph immediately reflects the change. 3. Experiment with different chart types, and try to change colours and fonts. 4. Next create a new chart, making sure that the supermarket names are the categories. Change Chart Type to Stacked Bar, and select the type that makes the height represent absolute value (there’s another type where all data groups are scaled so the total height is constant – that’s how you show relative values without needing a whole lot of pie-charts). 5. You may find that the X-axis labels won’t fit in the graph area, because it’s too small. If so, move the graph below the table of figures, then use the sizing handles to stretch it. Exercise X6 – Multiple Sheets Download the file at http://www.winchester.ac.uk/bm/courses/bs1904/bs1904ss.xls and save it in a folder of “My Documents.” It’s safest to quit Internet Explorer at this point1, and open your saved Excel file. Note that it contains four sheets, and click on the tabs to see them all. 1 If you start editing the spreadsheet in Internet Explorer, many things don’t work properly. BS1904 (2008) Practical Exercises Page 5 Rename the first sheet “TaxCalc” (second should be “Interest” and the third “Dividends”). Go into “Interest” and fill in the missing date for quarterly interest payments from the National Wetmonster bank (just make up a plausible date). You’ll find that dates can be entered in many different formats, but will always appear like the other dates. So for August 31st, you can enter “31 aug” or “31-8” or “31/8/03”. Work out how to make the year display as well (hint: Format the cells and look on the Number tab). This should explain why most spreadsheets don’t have a problem working with dates beyond 1999. Now fix up the dates for the dividend payments, which are approximately half-yearly. Copy the group of three “Total” numbers from Interest, and paste them into the TaxCalc sheet. Note that you get an error – Why might that be? Undo your last action to get rid of the error and borders. Instead of doing an ordinary paste, which tries to apply formulae, try again using Paste Special. One of the radio buttons is Value – if you select this, then only the values are copied across, and no error arises. Do this for the totals on the Dividends sheet as well. Now you can compute total income and tax already paid (make up a salary if you wish). Next try changing one of the payments on the Interest or Dividends sheet – note that the total changes on that sheet, but there’s no effect on the TaxCalc sheet; effectively, you just pasted in a snapshot of how the sheet looked at that moment of pasting. Exercise X7 – Dynamic Linking It’s unusual to want a snapshot, generally we want anything that uses a value from a spreadsheet to get hold of the latest value. So redo the copy, but when you’re ready to paste the data into TaxCalc sheet, pull down the Edit menu and select Paste Special. Note the various options available, then press the Paste Link button. Finally, change some of the payments on the Interest or Dividends sheets, and note that the TaxCalc sheet changes to reflect the changed source data. More Advanced Excel Functions – see p.12 BS1904 (2008) Practical Exercises Page 6 Advanced Word Techniques These are the activities conducted in the lectures of weeks 3 and 4. Exercise W1 – Building a Word Template The template used to hold default settings for Word is called Normal.dot and is usually located in your account’s profile area on the C: drive2. That’s fine at home, where you always use the same machine. On campus, though, your profile is loaded to the machine when you log on, and doesn’t get saved until you log off, so there is a risk of losing things if the machine crashes before (or even during) log-off. I therefore recommend that you store templates on your “My Documents”. When you open Word, it automatically accesses Normal.dot, so anything there is used as a default in your new document. This has the irritating side-effect that Normal.dot is “in use” and can’t be overwritten. So it’s important to do the following without starting Word. Find your existing Normal.dot The most simple way to do this is to use the Search facility in Windows Explorer to find on the C-drive (you’ll probably have to tell it to show system folders and hidden files. Copy it to a new folder on My Documents – Templates is a good name. Make sure it’s Normal.dot itself you copy, not just a shortcut to it. 1. Next, right click My Documents\Templates\Normal.dot and select Open. Almost uniquely in Windows, this does not do the same as double-clicking, but starts Word to edit the template. 2. Pull down Tools and Select Options. Choose the File Locations tab, and click on User Templates. This will probably point to the folder you found on the C-drive. 3. Press the Modify button and change the path to your new Templates folder in My Documents. If the server is called “Rodney” and your account is “f.bloggs”, the folder will be \\Rodney\f.bloggs$\Docs\Templates. 4. While you’re in Options, you should also skip ahead and select the Print tab, where you should check Update Fields. This will ensure that all fields (including tables of contents) are updated before you commit anything to paper. It’ll save you money later. 5. You are now ready to improve Word’s defaults. Exercise W2 – Updating Normal.dot Start by Saving what you’ve done so far, then do the following. 1. Pull down File and select Page Setup. Make the margins smaller so you don’t consume so much paper. 2cm top and bottom, and 2.5 on each side are ample. 2. Pull down Format and select Styles and Formatting. This will give you a task pane on the right. 3. Find Normal among the styles shown, and select Modify from the list that appears when you click on the right of the Normal box. You can immediately fix up the font and justification to your liking – 12-point Times New Roman left-justified is probably what it is, and that’s fine for anything you’re likely to do for the Business School. 4. Now press the Format button and select Paragraph. Add some “Spacing before” so that there will be vertical space in front of each paragraph. I recommend 8 or 9 points. You can 2 for example: C:\Documents and Settings\Fred\Local Settings\Application Data\Microsoft\Templates\ BS1904 (2008) Practical Exercises Page 7 also set any tabs you want at this point, or come back to do it later. Click on OK twice, and your changes will be effected. Save the file (normal.dot) again. 5. Next fix up the Heading styles to your liking. Headings tend to look better if you use a larger point-size of the body font (e.g. Times New Roman), but it’s your choice. Make Heading 1 (only) into a chapter heading by going into Paragraph and selecting the Line and Page Breaks tab. Check Page break before so chapter headings always start at the top of a page. Save your template again when you’ve done this. 6. Add a footer (or header if you prefer) by going in through the View menu. Suggested contents are as follows: On the left, Insert a Field such as Title from the Document Information category (there will be no obvious effect unless you’ve filled in the title under File Properties, but it’s still worth doing). Alternatively, you may prefer to enter a date. The most useful is the save date, which will be updated when you modify and save the document, but not when you open it. To do this, Insert Field and pick the Date and Time category. Select SaveDate and choose the format you want. Remember that numeric formats cause confusion in multinational businesses, so something like 3 Nov 2007 is to be preferred to 3/11/2007 (which means the 11th of March to an American). Press the Tab key to get to the middle of the footer. Insert the page number. The best way to do this is via the Insert Auto Text feature of the Headers and Footers toolbar, which includes the very useful “Page X of Y” entry. Finally tab to the end of the footer. Insert your name. Again, the best place to get that from is the Author field of Document Information. Another useful field is the name of the file. This makes it easy to find the source from a print-out. You can always go for a two-line footer if you need more than three items, but you’ll probably only want to do this when writing formal documents. 7. It may be helpful to include a word in the template, so you can be sure it worked – you can always delete the word later. For example, you could put “hello” in there. 8. Save the file again, then close Word. 9. Check that it all worked by opening Word and looking at the styles defined. They and the footer should match what you did to Normal.dot. If you put a word in the template, you should see it in the new document. Exercise W3 – Inserting a Table of Contents Do this with a document, not with a template. Using the Insert Reference menu, you can insert an automatic Table of Contents that shows headings and the page on which they appear. You can choose the layout of the table, and pick which levels of heading should be shown. Try this with an existing document. Ideally this should be one of your own, but you can download http://www2.winchester.ac.uk/bm/courses/bs1904/BS1904w6.doc if you don’t have a suitable document. You can modify the TOC1 to TOCn styles to give the spacing and layout you like. If you check the Add to Template box of Update Style, your choices will apply in future. BS1904 (2008) Practical Exercises Page 8 A hint about headings in Upper-case If you like your headings in upper-case, you can achieve this without their appearing that way in the table of contents. Just modify the font in the heading style, checking the “All caps” or “Small caps” box. You can then type the text as you want it to appear in the Contents, but the heading itself will be displayed in CAPITALS or in SMALL CAPITALS. Exercise W4 – Inserting Cross-References Cross-references are a special class of field that you insert with the Insert Reference menu. The idea is to allow you to say something like “see Exercise W2 – Updating Normal.dot on p.7” and know that it will be adjusted if the heading or page number should change. By default, all headings and numbered items can be the target, and you can choose to show the text, or the page number, or the item number. If you check Insert as hyperlink, someone reading the document on-screen will be able to go directly to the referenced item. You can insert any combination of the forms of cross-reference. If you want to refer to a piece of text that isn’t numbered or a heading, you can turn it into a Bookmark. Just select the text, pull down Insert, and select Bookmark. Then you can refer to it; for example, “Press the Modify button on p.7”. BS1904 (2008) Practical Exercises Page 9 Composite Documents So far, you have created Word documents containing text, and Excel spreadsheets containing numbers and graphs. Real business reports usually need to contain a mixture of both these, often with drawings or images as well. Windows is excellent at letting you copy objects from one program to another, and these exercises use this facility to create composite documents. Exercise C1 – Producing a Spreadsheet Open the Supermarket spreadsheet if you’ve still got it (use Windows Explorer, of course). Otherwise you’ll need to start Excel and make a new with the following contents: Item Tea Biscuits Coffee Sugar Waitrose 1.4 1.06 1.45 0.9 Tesco Sainsbury 1.2 1.25 0.99 1.25 1.56 1.5 1.09 1.21 Asda 1.15 1.05 1.5 1.2 Exercise C2 – Making a Graph of the Data If you haven’t already got a graph in your spreadsheet, make one by selecting all the table’s text and numerical entries. Click on the Graph tool in the Toolbar. Create a bar graph of the selected data. Exercise C3 – Making a Drawing You can use any drawing application you like, including the Draw facility within Microsoft Office. An alternative is to use Paint, or download a drawing from the Internet. 1. Press the Start button, select Programs, then Accessories, then Paint. 2. Draw something simple, such as two boxes linked by a line. 3. Exit from Paint, saving your drawing as mypic.bmp Exercise C4 – Adding a Picture to the Document 1. Open Word and type some text. 2. Place the cursor under the text, and use Insert Picture.. from File to import mypic.bmp Your drawing will appear to the left of the column, or in the middle. 3. Click anywhere on the drawing; the cursor will change, after which you can slide the drawing to where you want it on the page. What you’re doing is moving the “anchor” – usually the corner of the picture, which is connected to a particular piece of text. That’s why you were advised to type some text first. 4. Re-size the drawing by placing the mouse pointer over one of the “sizing handles” around the drawing. The pointer will turn into a double-arrow, which you can use to enlarge or shrink the picture. Note that handles at the corners preserve the aspect ratio (relation between height and width), while those on the sides, top and bottom change the shape of the picture. 5. Right-click on the drawing. This produces a menu that lets you position or edit the figure (double-clicking the drawing puts you directly into Format or Edit, depending on the type of picture). Try out the options. You would normally anchor a drawing to a paragraph that described it, if text and drawing are closely related. If not, the best thing is to give it a BS1904 (2008) Practical Exercises Page 10 caption (like “Figure 1”) and anchor it to the page. Check the Wrap Text Around Box check-box unless you want text to continue over the drawing. A common convention is to position large figures at the head of a page to avoid breaking up the flow of the text. Exercise C5 – Adding a Table to the Document 1. Open a spreadsheet, such as the Supermarket price-list. Select the data you wish to include, and copy it to the clipboard. 2. Return to Word, and place the cursor where you want to insert the table. You now have a choice of whether to copy the current values in the table, or to track later changes to these values. Do both to see the effect: 3. Use Edit Paste to get the current values. The result will be a Word Table. It is possible that the columns may be somewhat messed up, but do not try to fix them yet, as it’s probably more efficient to do this and the next table together. 4. Use Edit Paste Special, then check Paste Link to create a logical connection between your document and the spreadsheet. The effect looks the same at present. This is another example of ‘DDE’ – Dynamic Data Embedding. 5. Word “understands” details of what Excel places on the clipboard, so is able to include all the properties of the selected spreadsheet cells, including colour and layout. Now return to Excel and change one of the values; you might try changing the number format between Fixed format and UK currency. Note that the linked table in Word reflects the change, while the Pasted one does not (it is ‘static’). Exercise C6 – Adding a Graph to the Document 1. Return to Excel and select a Graph (create one if necessary). Use Edit Copy or the Copy button to place the graph on the clipboard. 2. Return to Word and insert the graph using the Edit Pull-down. Are you given the chance to Link it? 3. Practise moving these embedded objects around your document. Exercise C7 – Adding an Object An alternative way to create compound documents is by including the other components as “objects.” Use Insert Object and follow the menu that is offered. Note that you can insert the object as an icon, giving you the equivalent of a footnote – double-clicking the icon brings up the application that created the object, for example, a spreadsheet. Optional: Try dragging and dropping an object from Windows Explorer. BS1904 (2008) Practical Exercises Page 11 More Advanced Excel: Exercise X8 – Currency Converter Based on Exercise 14 from Knight: Personal Computing for Business, pp.179-80, which is very similar to Exercise 7 in Knight: Computing for Business (1999), pp.137-39. Set up a template (reusable worksheet) for Simpson’s Travel to use in handling foreign exchange. This will work out the amount to be paid to the customer when the agency buys foreign currency, and prints a payslip to confirm the transaction. The following information needs to be shown: Country, name of currency, rate of exchange, number of units being bought, converted value, commission (2%, minimum £2.50), and how much is due to the customer. You should put the commission numbers into cells and give them names (saves work if they change) – the numbers are already on the sheet you’ll download, but you need to pick names. When you’ve finished, only the Country and number of units will be open to be filled in (the yellow cells below); everything else will be calculated. The data on Country, currency and exchange-rate will be held in a vertical look-up table. The following approach will achieve what’s needed: a) Download the sheet from http://www2.winchester.ac.uk/bm/courses/bs1904/currency.xls b) Open it in Excel, then make the column widths appropriate. 1 2 3 4 A B Simpson’s Travel Foreign Exchange: Buying C D E F G Country Rate Number Bought Converted Value Less Commission Total to Customer Currency 5 c) Leave cells A5 and B5 blank for the moment, and put some “pretend" values into C5 and D5; I suggest 1.5 and 30. d) In E5, enter a formula to work out the sterling value, so long as D5 isn’t zero. A suitable formula is =IF(D5=0,0,D5/C5) e) In F5, enter a formula for the commission (the MAX function is probably easier than IF). f) In G5, put a formula to display E5-F5 (unless it’s negative!). g) Format the sterling cells as currency (£xx.yy) and the foreign currency as xx.yy. h) Set up a Currency Look-up table lower down the sheet. First column is name of country (Eur, NZ, USA etc.); second is name of currency (Euro, $NZ, $US…); third is exchange rate (like 1.4383, 2.679 …). What does VLOOKUP demand about the sequence of countries? i) When a customer offers currency, the name of the country is put into A5. j) B5 and C5 are then obtained from the table using the VLOOKUP function. Assuming the table runs from A9:C18, a suitable formula for currency name would be: =IF(A5=0,0,VLOOKUP(A5, $A$16:$C$30,2)) – can you simplify it by using the name of the lookup table? k) The number of foreign currency units offered will be entered into D5, and the exchange-rate computed in C5 will then be applied to complete the calculations. l) Work out how you can “protect” the cells that users should not type into, and develop a way you can make clear which ones they should enter data in. 3 Currency.xls on the BS1904 web site contains figures taken on 3 Nov 2008 from http://www.xe.com/ucc/ BS1904 (2008) Practical Exercises Page 12 Databases Definitions A database is an organized collection of related information or data, prepared for quick retrieval. It can be as simple as an address book that lists a few dozen names and phone numbers, or as complex as a parts inventory. Once your database is set up, you can search it for specific types of data such as individual account records, sort it by data categories such as postcodes, and arrange it alphabetically and numerically. Databases can be used for mass mailings and reports, too. In a database file, all the data for a particular entry is called a record, and each item of information within a record is called a field. Each record should contain the same number of fields, and each field should contain the same type of information or remain empty. Flat files: single table files consisting of records (rows) and fields (columns) of data (e.g. mailing lists). Relational databases: data organized in multiple “relations,” usually called tables (e.g. customers, goods, suppliers, stocks and orders). Basic database management techniques Adding / removing fields and / or records. Modifying field names and records. Sorting records: rearranging them in alphabetical or numerical order (ascending or descending). Searching the database: finding the records that contain an exact match for information you specify. Filtering / querying the database: limiting the records displayed to those that match criteria you specify. Creating forms. Creating reports. Viewing the database from different aspects: listing the records (in a table where rows are records and columns are fields); displaying individual records on a form; viewing records selected by a query (looking at the data ‘through a filter’), either on a list, or on a form; displaying summarised and organized database information in a report, based either on all records, or on a subset of records selected by a query. Popular database managers for the PC: Microsoft Access, Works DB, Open Office. Heavier-duty DBMSs that run on PCs: SQL Server, Personal Oracle, Personal DB2. BUT: A spreadsheet like MS Excel can also be used for limited flat file database management, and you can even do some report-making with the Mail Merge Tool in MS Word. BS1904 (2008) Practical Exercises Page 13 Access Databases Exercise A1 – Setting up a Database Start Microsoft Access, and create a new table – call it Garages. You’ll need to use the Design View to make sure that the fields have the right name and characteristics. For example, the field called “Make” needs to contain text data up to 32 characters long. You’ll need to think about “Year” – unless you need to do arithmetic with it, treat it as text; if you define it as a number, then the leading zero would get dropped from “03” in the new century. “Price” should be currency – find out how to round to the nearest pound. When you’ve created the basic database, you can fill it with the data below – or import the data from a spreadsheet you’ll find on the web-site. MAKE Mercedes C280 Elegance Triumph TR6 BMW Z3 Porsche 993 Coupe Mercedes E200 Classic Aston Martin Ferrari 255 Spider Audi A3 1.8SE Porsche Turbo S Lotus Elise Rover 216S Metro 1.1L Rover 216SL Maestro Clubman Volvo 440GL Renault 19GTX Fiat Uno 45 Montego 1.6LX Rover 220i Coupe Rover 620 GSi Metro 1.4GS YEAR 96 73 96 96 97 89 96 98 98 97 89 93 93 91 90 90 92 91 92 93 93 PRICE 25995 20495 16995 56995 23995 79995 92950 19950 127950 21750 4295 7295 10995 4995 5995 5995 4750 5495 13995 18750 7595 GARAGE M G G B B M G B M G B G B B G G B B B G B You can then go ahead and complete Exercises 1(a) to 1(d) in Knight (1999) pages 196-200. Exercise A2 – Creating Queries See Knight (1999) pages 201-205, exercises 2-4. Exercise A3 – Database with two tables See pages 220-222 from Knight (1999) on copy annotated by Eric. Do exercises 7(a)-(d) and 7(f) and 7(e) if you have time. BS1904 (2008) Practical Exercises Page 14 Exercise A4 – Database + Mail Merge Exercise 1 Start with the database you built in Exercise A3 for managing seminars during a conference, and send a letter to each delegate, confirming his or her seminar booking. The database contained two tables: Delegates: This lists people attending the conference, with a Title, surname, initials, company name, 3-part address and telephone number. There is also a unique key of delegate ref. The table can be linked to the seminars table, joining the tables through the seminar ref of the seminar the delegate is booked on. Seminars: Shows seminar reference, title, start and end dates, and price. You are advised to use dates in the current year to save typing. If you didn’t import my data, you may need to extend the database first, restructuring names to avoid nasties like “Dear Marghanita Laski” (she’d bin your letter unread) You need to create a query linking these tables, containing all the fields needed in the form letter you’re generating, which involve getting some fields from each table. The tables are joined by the SeminarRef value. Next open Word, and use the Mail Merge Wizard (on Tools menu) to create your master document. This will end up something like the following (where words in diamond brackets are the merge fields). <title> <initials> <surname> <company> <address1>, <Address2> <address3> 07 Mar 16 Dear <title> <surname>, Your reservation for Session <seminar_ref> Thank you for booking a place on <seminar_name> (<seminar_ref>) at a cost of <fee>. I look forward to seeing you at this event at 9 am on <from>. I am confident that you will find this seminar an informative experience. Yours sincerely, Ian Smoothie Knowing that you are going to use the database to write letters has certain impacts on the required data structure – for example, you needed to split up the person’s name so that title and surname can be used in a salutation, while the full name is used in the address. Knight’s example originally had just a “delegate name” that’s not split up, which would make this very difficult. The product of your work should be a series of letters of the form: BS1904 (2008) Practical Exercises Page 15 Mr J Brown Harlesdon Electronics Station Road Welwyn SG69FR 07 Mar 16 Dear Mr Brown, Your reservation for Session S03 Thank you for booking a place on Selling to Europe (S03) at a cost of £95. I look forward to seeing you at this event at 9 am on 26/07/08. I am confident that you will find this seminar an informative experience. Yours sincerely, Ian Smoothie Challenge: Find out how to print the “from” date in the form 27 July 2008. The best I’ve found so far is to toggle the field codes and then modify them in line with advice from http://www.gmayor.com/formatting_word_fields.htm BS1904 (2008) Practical Exercises Page 16 Flat File Database Management Exercises using MS Excel Summary of basic DB techniques in Excel: Note: For the following exercises, to “show” the Excel program where your “database” starts, ALWAYS select the cell which contains the first field name (i.e. the upper left corner cell of the database range). Sorting Data in a List Data / Sort / Sort By / Then By... / Ascending or Descending Order Filtering Data in a List: Data / Filter / Autofilter / Custom... Data / Filter / Show All Data / Filter / Advanced Filter / Criteria Range... Summarizing Data in a List Using a Pivot Table: (Pivot Tables are interactive worksheet tables used to analyse and summarise data from an existing list or table.) Start the PivotTable Wizard (from the Data menu, select: Pivot Table) Specify the Type of Source Data Specify the Location of the Source Data Create a Pivot Table Layout Select the Worksheet Destination and Display Options Exercise D1 – Manipulating a simple Excel “database” Start MS Excel and create the following “database” about your books, entering each field (Author, Title, Publisher, Published, Price) in a new column, and each record in a new row. N.B. Don’t leave any empty rows or columns in between. Author Fleming, I. Wells, H.G. Dahl, R. Bronte, E. Orwell, G. Title Diamonds Are Forever The War of the Worlds Kiss Kiss Wuthering Heights Nineteen Eighty-Four Publisher Macmillan Macmillan Penguin Penguin Penguin Published 1964 1975 1962 1951 1970 Price £1.50 £2.50 £0.30 £1.00 £0.25 Step 1: On a new worksheet, enter the field names for the database Step 2: enter the data of the records Step 3: sort the records on different fields (from the Data menu, choose Sort / Sort By... / Then By... ) in Ascending or Descending order Step 4: find a specific record (e.g. an author) (from the Data menu, choose Filter/AutoFilter...) Step 5: to get all records back, from the Data menu, select Filter / Show All Step 6: add a new record (a book of your choice) using a “Form” from the Data menu Step 7: query/filter the database by various criteria. E.g., answer the following questions: which books were published after 1965? (Published is greater than 1965) BS1904 (2008) Practical Exercises Page 17 which books were published by Penguin? (Publisher is equal to Penguin) which books were published by Penguin and cost less than 1.00 pound? (Publisher is equal to "Penguin" AND Price is less than 1) Before you can use an “Advanced Filter” from the Data / Filter menu, you need to enter the criteria into a blank range on the spreadsheet. This will become the so-called “Criteria Range” to which one has to refer to in the dialog box. For example: Author Fleming, I. Wells, H.G. Dahl, R. Bronte, E. Orwell, G. Title Diamonds Are Forever The War of the Worlds Kiss Kiss Wuthering Heights Nineteen Eighty-Four Publisher Macmillan Macmillan Penguin Penguin Penguin Published 1964 1975 1962 1951 1970 Publisher Penguin Price £1.50 £2.50 £0.30 £1.00 £0.25 Price <1 In this case the “Criteria Range” is: $C$9:$E$10, which you can enter into the dialog box by simply dragging the mouse over it. N.B.: If you have two criteria to set, enter them on the same row to match both, or on separate rows to match either one or the other. Step 8: Using a Pivot Table, create a report or summary (see below) showing how many items are there in your library and the total value of your books. (From the Data menu, choose Pivot Table and follow the steps suggested by the Wizard. When prompted, drag the “Title” and “Price” fields into the “Data” area..., then in the next stage, enter cell $A$10 as the starting cell.) Data Count of Title Sum of Price Total 5 5.55 Step 9: create another report (using a Pivot Table) which shows your books” titles, publishers and publishing years, and gives summaries about the groups. Count of Title Publisher Published Macmillan Macmillan Total Title 1964 1975 Diamonds Are Forever 1 0 1 Kiss Kiss 0 0 0 Nineteen Eighty-Four 0 0 0 The War of the Worlds 0 1 1 Wuthering Heights 0 0 0 Grand Total 1 1 2 BS1904 (2008) Penguin 1951 0 0 0 0 1 1 Practical Exercises Penguin Grand Total Total 1962 0 1 0 0 0 1 1970 0 0 1 0 0 1 0 1 1 0 1 3 1 1 1 1 1 5 Page 18 Exercise D2 – Mail-merging from an Excel table The objective of this exercise is to generate a letter to each of a class of students, giving them the end-of-semester results for a module (in this case, it’s the first-ever Introduction to Computing with names changed and results jumbled up). Start with the spreadsheet you can download from the course web-site at: http://www.winchester.ac.uk/bm/courses/BS1904/ (there’s a list of materials near the bottom). You’ll notice that the spreadsheet has a few lines of title information, then a line of column headings, followed by a line of results for each student. These are followed by yet more special lines, which have no part in your letters. Select the area you want to use in the merge (A3:M23) and give it a name (for example, Results) in the name box. This will save much effort later To create the letters: Use Word to update the letter something like what follows, omitting all the italicized bits for the time being – these are the places where you’ll insert fields from the spreadsheet. You can save typing by starting with MailMergeX.doc from the web-site. Use Tools/Letters and Mailings and the Mail Merge Wizard to obtain a data-source in the spreadsheet. If you didn’t name the relevant area of the spreadsheet with a row of field-names at the top, this will be quite a pain. It’s best to go back to Excel and name the area.4 If you click the “More items” link at step 4 of the wizard, you’ll find that the Insert Merge Field box offers the column headings, which is useful. Insert the ones that are needed to produce the bits shown in italics in letters like this one: Queen Alfreda’s College Internal Memorandum 07 March 2016 To Mr Adrian Able Dear Adrian, Results for Module BS1904 – Computer Applications Examination Part I Q1 Q2 Q3 Q4 Q5 Total 34 11 «Q2» 13 «Q4» 10 95% Assignment 76% Overall result: 86% Yours sincerely, X Aminah With Office 97, the option to select a range of cells doesn’t work (though the Help implies it’s meant to), so you need to name a range, or set the Print Area to be the range that’s wanted (select the block, then do File/Print Area). Save the spreadsheet, and return to Word. Open the data source again, this time limiting the source to its print area. 4 BS1904 (2008) Practical Exercises Page 19 Editing Internet Web Pages Most good web pages are created by starting from an already-good page, and changing the contents to convey the message you want to get across. Exercise 2 is an introduction to this process. It’s very rare that you actually need to start from scratch and generate the <html> tag and other structural elements. If you do, then it can sometimes help to use one of the WYSIWYG HTML editors, or a tool like Microsoft Word. Another place these can be useful is for creating tables. Exercise – Working with HTML Source This exercise needs four files from the same site on the web as above. Please copy them to your machine with their original names, to save confusion with the instructions below. The files are http://www.winchester.ac.uk/bm/courses/samples/topdoc.html, and (in the same location) broken.html and fixed.html plus a graphical image, img.gif. Start Windows Explorer and Notepad (Start; Programs; Accessories; Notepad), then start the browser on topdoc.html and try to fix up the deliberate errors I’ve introduced into the file it links to: broken.html. The desired appearance is shown on the following page. First open the file in Notepad by dragging it from Windows Explorer into the Notepad window. Look for tags starting <x and change them back to the correct tags; each character of the tag has been replaced with an x, so its length is unchanged. Notepad has a menu that helps you find things. The text of the files should contain all the hints you need to understand all the HTML included in them. If you get really stuck, you can cheat by looking at the source of fixed.html, but this won’t help you learn. This exercise demonstrates a workable way of getting started on the web. You capture a page that uses the structures you want, then look at the source and copy the HTML that does what’s needed. Most of the common structures are explained in the examples provided. References Knight, Jane (1999) Computing for Business (Financial Times). BS1904 (2008) Practical Exercises Page 20