Share via


SpreadsheetLauncher Control

A SpreadsheetLauncher control allows a user to import lists from spreadsheets or to verify whether a compatible spreadsheet application is available for list export in Microsoft Windows SharePoint Services. When the page containing a view of the list opens, the EnsureSSImporter function is called, which is defined in the file OWS.JS. This function creates the control on the page as follows:

new ActiveXObject("SharePoint.SpreadsheetLauncher.2")

Note  In the context of an application whose version is earlier than Microsoft Office 2003, 1 is used as the version number.

When Office 2003 is installed on the client computer, this control is defined in the OWSSUPP.DLL file, a dynamic-link library (DLL) that is installed on the client during Office 2003 setup in the Local_Drive:\Program Files\Microsoft Office\OFFICE11 directory.

EnsureImport Method

Verifies that the control that is used for import and export of contacts is present and registered.

Syntax

expression**.EnsureImport**()

expression An expression that returns a SpreadsheetLauncher object.

Example

The following example creates a SpreadsheetLauncher object and verifies its presence and registration. For a complete example that implements this code block, see Code Example for Importing Contacts.

Set objEnsureImport = CreateObject("SharePoint.SpreadsheetLauncher.2")

If IsObject(objEnsureImport) Then
   objEnsureImport.EnsureImport()
End If

GetCLSID Method

Returns a String representing the class identifier (CLSID) for the specified object. Use this value to construct an <OBJECT> tag to which Microsoft Internet Explorer can bind calls.

Syntax

expression**.GetCLSID()**

expression An expression that returns a SpreadsheetLauncher object.

Example

See the following method for an example.

ImportList Method

Imports a list to the SharePoint site and returns a string representing the URL for the new list, to which the user is automatically navigated upon completion of the import.

Syntax

expression**.ImportList**(List, Title, QuickLaunch, URL)

expression An expression that returns a SpreadsheetLauncher object.
List Required String. The name of the list to create.
Title Required String. The description of the list to create. An empty string means a description is not displayed on the Create Page.
QuickLaunch Required String. True if a link to the default view page of the new list is added to the Quick Launch bar.
URL Required String. The absolute URL for Owssvr.dll, which is located on the virtual server in the following directory:

Local_Drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\50\ISAPI

Example

This example uses the ImportList method to import data from a spreadsheet to a SharePoint site. After creating a SpreadsheetLauncher object, the example uses the GetCLSID method to construct an <OBJECT> tag for writing the object to the page.

<SCRIPT language="JavaScript">
SpreadsheetLauncherButton = new ActiveXObject("SharePoint.SpreadsheetLauncher.2");

if (SpreadsheetLauncherButton)  {
   var launcherCLSID = SpreadsheetLauncherButton.GetCLSID();
   var objectTag = '<OBJECT classid="clsid:' + launcherCLSID + '" id="SpreadsheetLauncherObj" style="display:none;"></OBJECT>';

   document.write(objectTag);   }

function DoImportSpreadsheet()  {
   var form = document.frmNewList;
   var resultUrl;

   resultUrl = SpreadsheetLauncherObj.ImportList(form['List'].value," ", false, 'http://STSServer1/_vti_bin/owssvr.dll?CS=109&');
   window.parent.location.assign(resultUrl);
   return false;    }
</SCRIPT>

The previous example assumes the existence of a form such as the following, which calls the DoImportSpreadsheet function and passes several INPUT values to the server.

<FORM name="frmNewList" onsubmit="return DoImportSpreadsheet();">
  <INPUT type="Text" title="Name" name="List" maxLength="255">
  <INPUT type="File" name="SpreadsheetFile" style="behavior: url(#SpreadsheetLauncherObj);">
  <INPUT type="Hidden" name="ListTemplate" value='SpreadsheetImport'>
  <INPUT type="Submit" value="Import">
  <INPUT type="Hidden" name="Project" value="ows">
  <INPUT type="Hidden" name="Cmd" value="NewList">
</FORM>

IqyImportEnabled Method

Returns a Boolean value, true indicating that the specified control supports importing or exporting of Web query (.iqy) files. An .iqy file serves as a wrapper for a Web query and contains metadata for returning the actual list data. This method determines a registered handler for .iqy files, so that the browser starts the appropriate application when the file is downloaded.

Syntax

expression**.IqyImportEnabled**()

expression An expression that returns a SpreadsheetLauncher object.

Example

The following example exports the Contacts list of a SharePoint site to a spreadsheet, using the IqyImportEnabled method to verify that the export is possible.

<SCRIPT language="JavaScript">
function ExportList(using){
   ExporterObj = new ActiveXObject("SharePoint.SpreadsheetLauncher.2");

   if (ExporterObj && ExporterObj.IqyImportEnabled())   {
      window.parent.location.href = using + "&Source=" + window.location.href;  }   }
</SCRIPT>

The onclick attribute of an <A> tag that would call the ExportList function contains a URL such as the following, which uses the Query.iqy file for processing the query:

javaScript:ExportList('http://STSServer1/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=Contacts&View=&CacheControl=1');javascript:return false;