Monday, August 24, 2009

Setting up Sharepoint Server Search to index pdf content and to show PDF Icon

  1. Decide the image to be shown for the pdf doc icon and copy it to 12\TEMPLATE\IMAGES (Normally icpdf.gif file)
  2. Open DOCICON.XML which is located in folder 12\TEMPLATE\XML
    1. Under the node <byextension> add the below statement.
      1. <mapping key="pdf" value="imageFileName.gif">
      2. imageFileName.gif is the name of the gif file copied above
      3. Save the XML file.
  3. Go to Sharepoint Central Admin -> Shared Services
    1. Click on file types
      1. Click on the new file type to add the pdf file type. Click ok to add it to the list. And verify that the file extension is populated.
  4. Stop the IIS
  5. Install the Adobe IFilter which can be downloaded from internet (ifilter60.exe).
  6. After successful installation of Abode IFilter restart IIS.
  7. Reset Crawled content (SharedServices -> Search Settings) this is required since it may not re-crawl the older sites even in Full Crawl.
  8. Now need to add the Name column to do this follow the steps
    1. Go to Search Settings -> Metadata property mappings
    2. Add a new Mapped Property for FileLeafRef. Click on the Add Mapping, in the seach text box enter keyword fileleafref and click on find to filter the Select Crawled property to ows_FileLeafRef(Text). Click on ows_FileLeafRef(Text) in the list box to select it and Click OK. Enter the propery name as “Name”
    3. Click Ok to Save it.
    4. Make sure that the newly added property is populated in the list
  9. After Resetting go to Content Sources and Crawl Schedules
  10. Apply a Full Crawl
  11. Wait for the crawl to complete.
  12. Once the crawl is completed the pdf document matching the search criteria will be shown in search results.

Wednesday, August 12, 2009

Using Excel Service hosted using Sharepoint in .Net Application (C#)

An Excel Sheet is created to do a calculation of ADD.
Cell$G$155 is set to function SUM of the values on Cell$G$145 and Cell$G$150 (Instead of the Cell and Row No, the Defined a Name to the Cell and that can be used)
The Above excel is published to an Excel enabled Sharepoint Library.
The above library url has to be set as trusted Url in the Sharepoint Central Admin Excel Services Settings.
Below is how that published excel can be used for calculation from another application (webpart, Console or anyother .Net Application) using C#.
Add the Web Service Reference of the ExcelService first to the application.

ExcelService oExcelServ = new ExcelService();
oExcelServ.Url = SPContext.Current.Web.Url + "/_vti_bin/ExcelService.asmx";
oExcelServ.Credentials = System.Net.CredentialCache.DefaultCredentials;

Status[] Status = null;
String SessionID = null;
string pathWorkBook = @"http://servername/LibraryName/excelFile.xlsx";
SessionID = oExcelServ.OpenWorkbook(pathWorkBook, "en-US", "en-US", out Status);
int val1, val2;

//EXCELSHEETNAME à The Name of the Sheet in the .xlsx file which is published.
//EXCELSHEETNAME!$G$145 à SheetName!$CellAlphabet$RowNo
Status = oExcelServ.SetCellA1(SessionID, "EXCELSHEETNAME", "EXCELSHEETNAME!$G$145", val1);
Status = oExcelServ.SetCellA1(SessionID, "EXCELSHEETNAME", "EXCELSHEETNAME!$G$150", val2);

//Execute the CalculateWorkbook function to trigger Calculation
Status = oExcelServ.CalculateWorkbook(SessionID, CalculateType.CalculateFull);
object result = null;

// Read the result back from the Cell.
result = oExcelServ.GetCellA1(SessionID, "EXCELSHEETNAME", "EXCELSHEETNAME!$G$155", true, out Status);

Tuesday, August 4, 2009

Applying Theme to Login.aspx in Sharepoint

Ever wondered how to have the look and feel of Sharepoint login page based on the theme applied on site collection? I never thought about the importance of that until there was a site collection which had theme applied and forms based authentication enabled. The site was looking beautiful with the theme applied, application and layout pages were having the same look and feel, but when the sign in was clicked all went to the same sharepoint blue look and feel … hmmm it's not that good to see that blue color from a rich theme applied website isn't ?

Applying a theme will change the look and feel of pages which come from _layouts folder as well as the application pages. Login.aspx also resides under _layouts folder in the 12 Hive, but why it is not inheriting the theme?, this was the first question came in to my mind. So on investigating more in the login.aspx and its associated master page simple.master I found a workaround and that is as below.

  1. If the login.aspx is closely looked, we can see that it uses the simple.master page and it misses the tag to inherit the theme (<SharePoint:Theme runat="server"/>).
  2. A new master page named login.master was created by taking a copy of simple.master.
  3. Added the theme server tag under the head html tag.
    1. <HEAD runat="server">

      ….

      <SharePoint:Theme runat="server"/>

      ….

        </HEAD>

  1. Saved the login.master and copied it to LAYOUTS Folder.
  2. Updated the login.aspx to use the login.master.
    1. <%@ Page Language="C#" Inherits="Microsoft.SharePoint.ApplicationPages.LoginPage" MasterPageFile="~/_layouts/login.master" %>
  3. That's it. Go to IE and refresh the login page to see login page with theme applied.
  4. Enjoy !!