TSService.close

Syntax

close (wbk);

Parameters

wbk. Sets workbook value.

Description

The close method closes the workbook.

Example

To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:

	var closeButt = new PP.Ui.Button({
		ParentNode: document.body, //DOM parent node
		Content: "Close workbook", //title
		Click: PP.Delegate(onClickCloseButt)
		});
	function onClickCloseButt()
	{	
		//Create and display dialog for confirmation of object saving
		if (wbk && wbk.getIsChanged())
		{
			var dialog = new PP.Ui.ConfirmSaveDialog({
				TriState: true,
				ContentAlign: "Left",
				NoButtonClicked: Click,
				OkButtonClicked: Click,
				IsRTL: workbookBox.getIsRTL()
			});
			var md = wbk.getDocumentMetadata();
			var str1 = PP.resourceManager.getString("TSConfirmSaveMessagePart1");
			var str2 = PP.resourceManager.getString("TSConfirmSaveMessagePart2");
			var name = (md && md.obInst && md.obInst.obDesc && md.obInst.obDesc.n) ? md.obInst.obDesc.n : "";
			dialog.setContent(str1 + name + str2);
			dialog.show();
		}										
	}
				
	//Action confirmation handler
	function Click()
	{
		//Close workbook
		tsService.close(wbk);
		//Set an empty data source for the workbook display component
		workbookBox.setSource(null);
		wbk = null;
	}

After executing the example the button named Close Workbook is placed on the HTML page. On clicking the button the workbook will be closed.

See also:

TSService