<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Louzer</id>
	<title>Apache OpenOffice Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Louzer"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Louzer"/>
	<updated>2026-12-05T00:20:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Structure_of_Spreadsheets&amp;diff=111904</id>
		<title>Documentation/BASIC Guide/Structure of Spreadsheets</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Structure_of_Spreadsheets&amp;diff=111904"/>
		<updated>2009-02-14T09:14:49Z</updated>

		<summary type="html">&lt;p&gt;Louzer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:The Structure of Spreadsheet Documents}}&lt;br /&gt;
{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Spreadsheets&lt;br /&gt;
|NextPage=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;
{{Documentation/Note|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;
&amp;#039;&amp;#039;&amp;#039;Example 1: access by means of the number (numbering begins with 0)&amp;#039;&amp;#039;&amp;#039;&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 = StarDesktop.CurrentComponent&lt;br /&gt;
Sheet = Doc.Sheets (0)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Example 2: access by means of the name&amp;#039;&amp;#039;&amp;#039;&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 = StarDesktop.CurrentComponent&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;: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;
=== Creating, Deleting and Renaming Sheets ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Sheets&amp;lt;/tt&amp;gt; list for a &amp;lt;tt&amp;gt;spreadsheet&amp;lt;/tt&amp;gt; document is also used to create, delete, and rename 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 &amp;#039;&amp;#039;&amp;#039;MySheet&amp;#039;&amp;#039;&amp;#039; 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 = StarDesktop.CurrentComponent&lt;br /&gt;
Sheet = Doc.Sheets(0)&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;getByName&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;insertByName&amp;lt;/tt&amp;gt; methods are 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;
 &lt;br /&gt;
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Structure of Spreadsheets}}&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Louzer</name></author>
	</entry>
</feed>