<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fstructure_of_spreadsheets</id>
	<title>EN/documentation/basic guide/structure of spreadsheets - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.harlamenkov.ru/index.php?action=history&amp;feed=atom&amp;title=EN%2Fdocumentation%2Fbasic_guide%2Fstructure_of_spreadsheets"/>
	<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/structure_of_spreadsheets&amp;action=history"/>
	<updated>2026-11-11T13:50:34Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/structure_of_spreadsheets&amp;diff=15956&amp;oldid=prev</id>
		<title>Sancho: Основной текст</title>
		<link rel="alternate" type="text/html" href="https://wiki.harlamenkov.ru/index.php?title=EN/documentation/basic_guide/structure_of_spreadsheets&amp;diff=15956&amp;oldid=prev"/>
		<updated>2011-09-02T17:54:36Z</updated>

		<summary type="html">&lt;p&gt;Основной текст&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;section begin=title /&amp;gt;&amp;lt;noinclude&amp;gt;{{DISPLAYTITLE:&amp;lt;/noinclude&amp;gt;The Structure of Spreadsheet Documents&amp;lt;noinclude&amp;gt;}}&amp;lt;/noinclude&amp;gt;&amp;lt;section end=title /&amp;gt;{{BreadCrumbL10n}}&lt;br /&gt;
&lt;br /&gt;
{{Documentation/BASICGuideTOC&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=EN/documentation/basic_guide/spreadsheets&lt;br /&gt;
|NextPage=EN/documentation/basic_guide/rows_and_columns&lt;br /&gt;
|spread=block&lt;br /&gt;
}}&lt;br /&gt;
 &lt;br /&gt;
The document object of a spreadsheet is based on the &amp;lt;idl&amp;gt;com.sun.star.sheet.SpreadsheetDocument&amp;lt;/idl&amp;gt; service. Each of these documents may contain several spreadsheets. In this guide, a table-based document or spreadsheet document is the entire document, whereas a spreadsheet (or sheet for short) is a sheet (table) in the document.&lt;br /&gt;
&lt;br /&gt;
{{VBAnote|Different terminology for spreadsheets and their content is used in VBA and {{OOo}} Basic. Whereas the document object in VBA is called a Workbook and its individual pages Worksheets, they are called SpreadsheetDocument and Sheet in {{OOo}} Basic.}}&lt;br /&gt;
&lt;br /&gt;
== Spreadsheets ==&lt;br /&gt;
&lt;br /&gt;
You can access the individual sheets of a spreadsheet document through the &amp;lt;tt&amp;gt;Sheets&amp;lt;/tt&amp;gt; list.&lt;br /&gt;
&lt;br /&gt;
The following examples show you how to access a sheet either through its number or its name.&lt;br /&gt;
&lt;br /&gt;
'''Example 1: access by means of the number (numbering begins with 0)'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets (0)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|&amp;lt;tt&amp;gt;ThisComponent&amp;lt;/tt&amp;gt; returns the currently active document.&lt;br /&gt;
&lt;br /&gt;
The expression &amp;lt;code&amp;gt;Doc.Sheets(0)&amp;lt;/code&amp;gt; is a Basic simplification of the API call : &amp;lt;code&amp;gt;Doc.getSheets.getByIndex(0)&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
'''Example 2: access by means of the name'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets.getByName(&amp;quot;Sheet 1&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the first example, the sheet is accessed by its number (counting begins at 0). In the second example, the sheet is accessed by its name and the &amp;lt;tt&amp;gt;getByName&amp;lt;/tt&amp;gt; method. &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Sheet&amp;lt;/tt&amp;gt; object that is obtained by the &amp;lt;tt&amp;gt;getByName&amp;lt;/tt&amp;gt; method supports the &amp;lt;idl&amp;gt;com.sun.star.sheet.Spreadsheet&amp;lt;/idl&amp;gt; service. In addition to providing several interfaces for editing the content, this service provides the following properties: &lt;br /&gt;
&lt;br /&gt;
;&amp;lt;tt&amp;gt;IsVisible (Boolean)&amp;lt;/tt&amp;gt;:value True if the spreadsheet is visible.&lt;br /&gt;
;&amp;lt;tt&amp;gt;PageStyle (String)&amp;lt;/tt&amp;gt;:name of the page template for the spreadsheet.&lt;br /&gt;
&lt;br /&gt;
=== Renaming Sheets ===&lt;br /&gt;
&lt;br /&gt;
A sheet provides methods &amp;lt;code&amp;gt;getName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;setName&amp;lt;/code&amp;gt; to read and modify its name. Basic can handle both methods like a property &amp;lt;code&amp;gt;Name&amp;lt;/code&amp;gt;. Here we rename the first sheet of the spreadsheet document.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
 &lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&lt;br /&gt;
Sheet.Name = &amp;quot;First&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Creating and Deleting Sheets ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Sheets&amp;lt;/tt&amp;gt; container of a &amp;lt;tt&amp;gt;spreadsheet&amp;lt;/tt&amp;gt; document is also used to create and delete individual sheets. The following example uses the &amp;lt;tt&amp;gt;hasByName&amp;lt;/tt&amp;gt; method to check if a sheet called '''MySheet''' exists. If it does, the method determines a corresponding object reference by using the &amp;lt;tt&amp;gt;getByName&amp;lt;/tt&amp;gt; method and then saves the reference in a variable in &amp;lt;tt&amp;gt;Sheet&amp;lt;/tt&amp;gt;. If the corresponding sheet does not exist, it is created by the &amp;lt;tt&amp;gt;createInstance&amp;lt;/tt&amp;gt; call and inserted in the spreadsheet document by the &amp;lt;tt&amp;gt;insertByName&amp;lt;/tt&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
&lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
&lt;br /&gt;
If Doc.Sheets.hasByName(&amp;quot;MySheet&amp;quot;) Then&lt;br /&gt;
   Sheet = Doc.Sheets.getByName(&amp;quot;MySheet&amp;quot;)&lt;br /&gt;
Else&lt;br /&gt;
   Sheet = Doc.createInstance(&amp;quot;com.sun.star.sheet.Spreadsheet&amp;quot;)&lt;br /&gt;
   Doc.Sheets.insertByName(&amp;quot;MySheet&amp;quot;, Sheet)&lt;br /&gt;
End If&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;hasByName&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;getByName&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;insertByName&amp;lt;/tt&amp;gt; methods are obtained from the &amp;lt;idl&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/idl&amp;gt; interface as described in [[Documentation/BASIC Guide/API Intro|Introduction to the API]].&lt;br /&gt;
&lt;br /&gt;
The interface  &amp;lt;idl&amp;gt;com.sun.star.sheet.Spreadsheets&amp;lt;/idl&amp;gt; provides a better method to create a new sheet: &amp;lt;code&amp;gt;insertNewByName&amp;lt;/code&amp;gt;.&lt;br /&gt;
It inserts a new sheet with the name specified by the first argument, at the position specified by the second argument.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
 &lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
&lt;br /&gt;
Doc.Sheets.insertNewByName(&amp;quot;OtherSheet&amp;quot;, 2)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The same interface provides methods &amp;lt;code&amp;gt;moveByName&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;copyByName&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;idl&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/idl&amp;gt; interface provides a method to remove a sheet of a given name:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Doc As Object&lt;br /&gt;
 &lt;br /&gt;
Doc = ThisComponent&lt;br /&gt;
&lt;br /&gt;
Doc.Sheets.removeByName(&amp;quot;OtherSheet&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Sancho</name></author>
		
	</entry>
</feed>