1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/*
* Copyright (c) 2005 Cyrille Berger <[email protected]>
* Copyright (c) 2006 Isaac Clerencia <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KROSS_KSPREADCOREKRSSHEET_H
#define KROSS_KSPREADCOREKRSSHEET_H
#include <kspread_sheet.h>
#include <kspread_value.h>
#include <api/class.h>
namespace Kross { namespace KSpreadCore {
class Cell;
/**
* A sheet in a document.
*
* Example (in Ruby) :
* @code
* doc = krosskspreadcore::get("KSpreadDocument")
* sheet1 = doc.sheetByName("Sheet1")
* sheet2 = doc.sheetByName("Sheet2")
* cell1 = sheet1.firstCell()
* while cell1
* colnr = cell1.column()
* rownr = cell1.row()
* cell2 = sheet2.cell(colnr, rownr)
* cell2.setValue( cell1.value() )
* cell1 = cell1.nextCell()
* end
* @endcode
*/
class Sheet : public Kross::Api::Class<Sheet>
{
public:
Sheet(KSpread::Sheet* sheet, KSpread::Doc* doc = 0);
virtual ~Sheet();
virtual const TQString getClassName() const;
private:
/**
* Return the name of the sheet.
*/
const TQString name() const;
/**
* Set the name of the sheet.
*/
void setName(const TQString& name);
/**
* Return the currently maximum defined number of columns.
*/
int maxColumn() const;
/**
* Return the currently maximum defined number of rows.
*/
int maxRow() const;
/**
* Return the first cell. Use the firstCell() and nextCell()
* methods as outlined in the example to iterate only through
* filled cells (aka cells with content).
*
* Example (in Python) :
* @code
* import krosskspreadcore
* doc = krosskspreadcore.get("KSpreadDocument")
* sheet = doc.currentSheet()
* cell = sheet.firstCell()
* while cell:
* print "Cell col=%s row=%s value=%s" % (cell.column(),cell.row(),cell.value())
* cell = cell.nextCell()
* @endcode
*/
Cell* firstCell() const;
/**
* Return the given cell. The first parameter is the column-number
* while the second defines the rownumber. The first cell starts
* with 0,0. If you like to iterate over all cells that have content,
* use the firstCell() and nextCell() methods which is much faster
* cause empty cells are ignored.
*
* Example (in Python) :
* @code
* import krosskspreadcore
* doc = krosskspreadcore.get("KSpreadDocument")
* sheet = doc.currentSheet()
* for colnr in range( sheet.maxColumn() ):
* for rownr in range( sheet.maxRow() ):
* cell = sheet.cell(colnr, rownr)
* if cell.value() != None:
* print "Cell col=%s row=%s value=%s" % (colnr,rownr,cell.value())
* @endcode
*/
Cell* cell(uint col, uint row);
/**
* Add a new row.
*/
bool insertRow(uint row);
/**
* Add a new column.
*/
bool insertColumn(uint col);
/**
* Remove a row.
*/
void removeRow(uint row);
/**
* Remove a column.
*/
void removeColumn(uint col);
private:
KSpread::Sheet* m_sheet;
KSpread::Doc* m_doc;
};
}
}
#endif
|