SpreadsheetLauncher.ImportList Method

Applies to: SharePoint Foundation 2010

Imports a list to the SharePoint site and returns the URL for the new list.

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

Parameters

expression

An expression that returns a SpreadsheetLauncher object.

List

A String that contains the name of the list to create.

Title

A String that contains the description of the list to create. An empty string means a description is not displayed on the Create Page..

QuickLaunch

true if a link to the default view page of the new list is added to the Quick Launch bar; otherwise false.

URL

A String that contains absolute URL for Owssvr.dll, which is located on the server in the following directory:

Local_Drive\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI

Return Value

A String that contains the URL.

Remarks

The user is automatically navigated to this location when the import is complete.

Example

This example uses the SpreadsheetLauncher.ImportList Method 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>