Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

March 2008 - The Excel Team Blog

  • Shadows on Charts and Cells in Excel 2007

    Today's author, Helen Hosein, a Program Manager on the Excel team. Certain shadows created in Excel 2003 look different Excel 2007. In particular, you might notice that your old cell shadows, as well as shadows on things like Chart Titles might look a bit different when you open your workbooks in Excel 2007. This is because Excel treats these as shapes with no fill - a bit like a wire frame. The shadow that it casts is the rectangle of its outline. Only when the frame is filled in, does it cast a whole shadow. Similarly, Excel 2007 just draws a shadow on the border of a shape with no fill, instead of on the whole shape. Since many of you, our customers, miss being able to create these types of shadows, we are assessing the possibility of bringing back this capability in the next version of Excel. For now, though, there are ways to work around this and create great-looking shadows on cells and chart elements in Excel 2007. An Example - Shadows in Excel 2003 vs Shadows in Excel 2007 Two of my very good friends, Rita and Alfie, are thinking of moving to London soon. Man, I'll miss them. They're shopping around for "flats" (they're already learning the lingo) but aren't sure which neighborhoods to consider. Rita, being web savvy, decides to download some of the 2005 rent data from the Greater London Authority and make an Excel chart so she and Alfie can gauge the relative prices. Rita copy/pastes the average rent for a studio in each borough into Excel 2003. She also adds the overall average rent for comparison. To make the overall average stand out, she adds a Cell Shadow to that row. Excel draws a rectangle shape around the selection and adds a shadow to it, giving that row a great effect that draws attention. Now Rita adds her chart of the rents. She likes gray, so she makes the whole chart background that color. Since the shadow looks so good on the summary, she adds a matching shadow to my Chart Title, and sets the Area fill to None so that the chart area color shows through. Once she's done, Rita sends me the workbook to get my opinion. After all, I'm her best friend, and I'm hoping to visit her soon in her new neighborhood. I open her workbook in Excel 2007. Wow! Do you see what I see? Rent in the City of London is really high. The second thing I notice, however, is that the shadows Rita put on "All Boroughs" and on the Chart Title are not quite what Rita might have intended. The good news is that these can be fixed in no time. Chart element shadows in Excel 2007 Remember, when Rita added the shadows to the Chart Title and the Legend, she also set the Area fill to None. Excel 2007 sees these chart elements as empty rectangle frames, since they have no fill. Because of that, the shadows on them look just like a second empty rectangle. The quick, easy fix is just to give them a fill. Step 1 : Right-click on the Chart Title and choose Format Chart Title. Step 2 : On the Fill tab of the Format Chart Title dialog, choose Solid fill. Step 3 : Choose the same color fill as the background (in my case, the same shade of gray that Rita's always on about). Now the Chart Title looks the same as it did in Excel 2003, and it still blends with the Chart Area because I gave it the same fill. I could also have done that by using the Shape Fill menu on the Format tab under Chart Tools on the Ribbon. Cell shadows in Excel 2007 Now the shadows on the chart are fixed, but the cell shadow still doesn't look the way it used to. Fortunately, one of our testers, Jon Adams, wrote a convenient add-in that helps solve this problem. Jon's add-in gives a great example of how you can use VBA to create your own cell shadows. You can download Jon's by clicking the attachment at the bottom of this post. Here's how you install the add-in. Step 1 : Click on the Office button and choose Excel Options. Step 2 : On the left, choose Add-Ins, and under Manage: choose Excel Add-Ins and click Go... Step 3 : An Add-Ins dialog will appear. Click Browse... and choose CellShadows (the file you just downloaded). Step 4 : Now Cellshadows will appear in your list of Add-Ins with a check mark next to it. Click Ok. Once you've installed the CellShadows add-in, you'll notice a new chunk called Cell Shadows on the Insert tab of the Ribbon. The Shadow menu allows you to insert a new cell shadow on your selection, just like you could in Excel 2003, whereas the Convert Cell Shadows button converts your old cell shadows so that they look right in Excel 2007. I want to convert Rita's cell shadow, so I hit the Convert Cell Shadows button. Just like that, Rita's cell shadow is fixed. So how did that work? If you try this yourself, you'll find that if you click on the shadow, you can see that it's actually a group of rectangles. The convertShadows macro looks for all the shapes in the workbook with an offset shadow and no fill, and replaces each of them with a group of two...
  • Setting up Excel Services to Refresh Workbooks When Opened.

    Today's author, Pej Javaheri, a Product Manager on the Excel Services team, talks about one of the more common configuration questions we hear about from customers. One of the challenges in sharing Excel workbooks is ensuring that the right people see the right data. With Excel Services, this has become a lot easier ensuring user's only see the information they are authorized to view and not sharing information that is privileged or out of their scope. With a few simple configuration steps, workbook authors can quickly setup their reports to only display the information that is authorized by user's security privileges. This document describes how to setup SharePoint SharedServices for Excel Services, and how to setup your ODC connection to refresh workbooks on open. Ensure the server has the right permissions to access data connections, and run Excel workbooks on the server. To do this, go to the Shared Administration page of your Shared Services. First, modify the Trusted File Locations to include the locations that you will allow Excel workbooks to be accessed to display on Excel Services. In the Address field, enter the location of where the workbooks are stored. Most likely this will be in a SharePoint Document library. If you want to enable the whole SharePoint site, enter the root address of the SharePoint site, such as http://SharePoint . Under Location , ensure you select Children Trusted if you will be storing workbooks in folders from this location, especially if you are going to enable the whole site. Under External Data, select either "Trusted data connection libraries only", or "Trusted data connection libraries and embedded" to allow Excel Services to refresh data from workbooks that access data through ODC files. If you will be calling User Defined Functions (UDF), then check the box under User-Defined Functions. You may also want to disable the Warn on Refresh option under External Data Click OK to return to the Excel Services Trusted File Locations screen and apply all the changes otherwise a warning dialog box will require users to okay the action before refreshing the workbook in Excel Services. You should have something like this, which identifies the location of the workbooks that will be accessed by Excel Services. You can add as many locations as required for each shared service environment you setup. Next, we need to identify where the data connection libraries are stored for Excel Services to access and refresh data. Go back to the SharedServices administration page, and click Excel Services Trusted Data Connection Libraries, and then click Add Trusted Data Connection Library. Enter the location of the document library that the ODC files are saved in. In this example, I have added the default location under the Reports document library Creating the ODC file in Excel In Excel, select From Other Sources under the Data tab. Select the data source type and then enter the required credentials in the Data Connection Wizard. In the File Name field, select Browse and then type the location of the Trusted Data Connection Library (alternatively, you can save the ODC file locally, and the upload it to the Data Connection Library via SharePoint). If the connection requires specific authentication requirements, or single-sign on select the Authentication Settings and set the appropriate item. Now that you have the connection created, you need to modify the properties of the connection so that it is set to refresh the workbook when it is opened every time. Still in the Data tab, select Properties and then check Refresh data when opening the file. Create your Excel workbook like normal, and then publish to Excel Services. If data is coming from a relational source, publish it in a Pivot Table. And there you have it. Whenever users open the workbook, the data is automatically refreshed using their credentials to access the data source. Read More...
  • SharePoint 2008 Conference Recap

    The BI Blog does a quick recap of the SharePoint 2008 Conference that just passed with particular emphasis on the popularity of the Excel Services session: Dan Parish, from the Microsoft Excel Services team, presented how you can extend the capabilities of Excel Services to a packed room of over 300 with tremendous feedback. Not to worry if you missed that sessions as we will be posting the content that was presented in a separate blog to showcase examples of how you can use Excel Services. Read More...
  • Unusual (but cool!) Uses of Excel

    Many of you who have been using Excel for a long time have most likely seen some of the creative, interesting, and rather unusual uses of Excel that people have conjured up. I'm talking about things like writing the Pac-Man game completely in Excel , stuff you wouldn't expect to see in a critical business application like Excel, but thanks to the ingenuity of spreadsheet hackers we get to see how the power and flexibility of spreadsheets can be put to use. I was reminded of this today when a colleague forwarded me this Slashdot article about someone who used Excel to create a 3D rendering engine (btw, this reminded me of a similar 3D animation engine written by a tester on our team that uses the new OfficeArt rendering platform in Excel 2007), and it got me wondering what other interesting uses have people come up with that I haven't seen before. I've seen a quite a few of these in my time here on the Excel team (we've even posted a couple of our own - check out Conway's Game of Life and Memory ), and I'm sure many of you have too. So let's hear it! Tell me about the interesting, crazy, weird, unusual and cool spreadsheets you've come across or built that you never thought you'd see in Excel. This could be interesting. :) Read More...
  • Handling Workbook Dependencies using Excel Services

    Today's author, Sanjay Kulkarni, a Program Manager on the Excel Services team. We have heard from several customers about scenarios where they have workbook dependencies. So the output of one workbook is used in other workbooks for calculations. The dependencies could be a result of the business model meaning different people in the organization being responsible for the workbooks or it could simply be a way of isolating related logic in different workbooks. In this blog post we will look at a sample way of how these workbook dependencies can be handled by writing a little code using Excel Services Web Services API and SharePoint object model. Note that you will need MOSS 2007 with Excel Services configured to use what is described here. To simplify things let us look at a scenario with two workbooks. At a high level workbook one (Rates.xlsx) has mortgage rates that are refreshed from the database. This workbook also adds the overhead and calculates the retail rate that can be offered to customers. The second workbook (Payments.xlsx) has a list of potential customers and information about them. The idea is to calculate the first workbook to get the retail rates and then use these rates to calculate the mortgage payment for the customers in the second workbook. We will use document properties to pass values from the Rates workbook to the Payment workbook. The Rates workbook has a Pivot Table that has interest rates and a cell that stores the margin. To make the sample work independently we have removed the connection to the external database and instead we get the data from another sheet in the workbook however that can be easily changed. Here is what the Rates workbook looks like. 0.75 Margin above the wholesale rates Values Row Labels Interest Rates Retail Rates 1 Year 4.5 5.25 3 Year 5 5.75 30 Year 5.875 6.625 5 Year 5.25 6 7 Year 5.5 6.25 The Payments workbook has information about the clients, their mortgage as well as cells where the retail mortgage rates can be updated. Mortgage Type Interest Rate 1 Year ARM 5 3 Year ARM 5.5 5 Year ARM 5.75 7 Year ARM 6 30 Year 6.375 Client Name Email Id Loan Type Interest Rate Loan Term in Years Principal Monthly Payment Jack jack@contoso.com 3 Year ARM 5.5 30 $350,000 $1,987.26 Judy judy@contoso.com 5 Year ARM 5.75 30 $400,000 $2,334.29 The following sections describe the steps involved with some code snippets. The complete code and the workbooks can be downloaded at the bottom of this post (see attachments). This is a console application and accepts the margin rate added for overhead as a parameter. We use a fixed constant in the workbook if no margin is specified. To simplify things I have omitted the error handling for the most part. You will definitely need to add robust error handling if you are planning to deploy it for a practical application. First print the margin rate and some initialization if (args.Length > 0) Console .WriteLine( "Margin rate is = " + args[0] + "%" ); // Instantiate the Web service and create a status array object. ExcelService es = new ExcelService(); Status[] outStatus; string ratesWorkbook = "http://server-name/Site/doclib//Rates.xlsx" ; // Set credentials for requests es.Credentials = System.Net.CredentialCache.DefaultCredentials; Now we open the workbook and set the margin rate in the Rates workbook, refresh data and calculate the retail rates. // Open the Rates workbook, get new rates by refreshing the external data and // calculate. string sessionId = es.OpenWorkbook(ratesWorkbook, "" , "" , out outStatus); //Set the input overhead margin rate if specified omcommand line. if (args.Length > 0) { es.SetCellA1(sessionId, "RatesSheet" , "Margin" , args[0]); } // Refresh data and recalculate the workbook. es.Refresh(sessionId, "" ); es.CalculateWorkbook(sessionId, CalculateType.CalculateFull); Now that the retail rates are calculated; we get the retail rates and set them as document properties on the Payments workbook. The advantages of using the document properties for storing values are firstly the properties are associated with the document so if you update the workbook they will still be preserved. Secondly since they are stored by SharePoint the process of calculating rates and payments can be done at different times if needed by the business process. //Get the calculated rates from the workbook double rate1Year, rate3Year, rate5Year, rate30Year; valObj = es.GetCellA1(sessionId, "RatesSheet" , "Rate1Year" , false , out outStatus); rate1Year = Convert .ToDouble(valObj); valObj = es.GetCellA1(sessionId, "RatesSheet" , "Rate3Year" , false , out outStatus); rate3Year = Convert .ToDouble(valObj); valObj = es.GetCellA1(sessionId, "RatesSheet" , "Rate5Year" , false , out outStatus); rate5Year = Convert .ToDouble(valObj); valObj = es.GetCellA1(sessionId, "RatesSheet" , "Rate30Year"...
  • Example file for PivotTable / Data Validation Trick

    Recently I posted an article discussing how PivotTables can be used on Excel Services to mimick the Data Validation feature . The author, Dany Hoter, sent me a copy of the file he used in the example screen shots and I never got around to posting it for our readers. Here's a short description of the example file from Dany: The example implements a scenario of calculating the pricing for car insurance based on the details entered in a form. The form can be collected on paper and entered manually into Excel or collected online and fed into Excel services to perform the calculation. Each value is connected to a numeric value. High values means less risk to insure this car to this driver. More driving experience, safer car, better neighborhood etc. Of course all data is completely fake and does not represent any real data. Each field might have a different number of possible values, some have only Yes/No and some might have 10 different values. All list of values where extended to the last row so to avoid blank appearing as an option for input. We can’t really prevent the user from choosing multiple options or the all option so an error message is displayed when the user does that. The file can be downloaded from here . Read More...
Copyright Excel User Group and the relevant contributors, 2008. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.