or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

authentication.mdclient-operations.mddata-access.mdformatting.mdindex.mdspreadsheet-management.mdutilities.mdworksheet-structure.md

worksheet-structure.mddocs/

0

# Worksheet Structure

1

2

Methods for modifying worksheet structure including adding/deleting rows and columns, resizing, freezing, and organizing dimension groups.

3

4

## Capabilities

5

6

### Adding Rows and Columns

7

8

Expand worksheet dimensions by adding rows and columns.

9

10

```python { .api }

11

class Worksheet:

12

def add_rows(rows: int) -> None:

13

"""

14

Add rows to the end of worksheet.

15

16

Parameters:

17

- rows (int): Number of rows to add.

18

19

Returns:

20

None

21

"""

22

23

def add_cols(cols: int) -> None:

24

"""

25

Add columns to the end of worksheet.

26

27

Parameters:

28

- cols (int): Number of columns to add.

29

30

Returns:

31

None

32

"""

33

```

34

35

### Inserting Rows and Columns

36

37

Insert new rows and columns at specific positions with optional data.

38

39

```python { .api }

40

class Worksheet:

41

def insert_row(values: List = None, index: int = 1, value_input_option: str = "RAW",

42

inherit_from_before: bool = False) -> Dict:

43

"""

44

Insert single row at specified position.

45

46

Parameters:

47

- values (List, optional): Values for the new row.

48

- index (int): Position to insert row (1-indexed). Default: 1.

49

- value_input_option (str): "RAW" or "USER_ENTERED". Default: "RAW".

50

- inherit_from_before (bool): Inherit formatting from previous row. Default: False.

51

52

Returns:

53

Dict: Response from insert operation.

54

"""

55

56

def insert_rows(values: List[List] = None, row: int = 1, value_input_option: str = "RAW",

57

inherit_from_before: bool = False) -> Dict:

58

"""

59

Insert multiple rows at specified position.

60

61

Parameters:

62

- values (List[List], optional): 2D array of values for new rows.

63

- row (int): Position to insert rows (1-indexed). Default: 1.

64

- value_input_option (str): "RAW" or "USER_ENTERED". Default: "RAW".

65

- inherit_from_before (bool): Inherit formatting from previous row. Default: False.

66

67

Returns:

68

Dict: Response from insert operation.

69

"""

70

71

def insert_cols(values: List[List], col: int = 1, value_input_option: str = "RAW",

72

inherit_from_before: bool = False) -> Dict:

73

"""

74

Insert columns at specified position with values.

75

76

Parameters:

77

- values (List[List]): 2D array of values for new columns.

78

- col (int): Position to insert columns (1-indexed). Default: 1.

79

- value_input_option (str): "RAW" or "USER_ENTERED". Default: "RAW".

80

- inherit_from_before (bool): Inherit formatting from previous column. Default: False.

81

82

Returns:

83

Dict: Response from insert operation.

84

"""

85

```

86

87

### Deleting Rows and Columns

88

89

Remove rows and columns from worksheet.

90

91

```python { .api }

92

class Worksheet:

93

def delete_rows(start_index: int, end_index: int = None) -> Dict:

94

"""

95

Delete rows from worksheet.

96

97

Parameters:

98

- start_index (int): Starting row index (1-indexed).

99

- end_index (int, optional): Ending row index (1-indexed, exclusive). If None, deletes single row.

100

101

Returns:

102

Dict: Response from delete operation.

103

"""

104

105

def delete_columns(start_index: int, end_index: int = None) -> Dict:

106

"""

107

Delete columns from worksheet.

108

109

Parameters:

110

- start_index (int): Starting column index (1-indexed).

111

- end_index (int, optional): Ending column index (1-indexed, exclusive). If None, deletes single column.

112

113

Returns:

114

Dict: Response from delete operation.

115

"""

116

```

117

118

### Resizing

119

120

Change worksheet dimensions.

121

122

```python { .api }

123

class Worksheet:

124

def resize(rows: int = None, cols: int = None) -> Dict:

125

"""

126

Resize worksheet to specified dimensions.

127

128

Parameters:

129

- rows (int, optional): New number of rows. If None, keeps current row count.

130

- cols (int, optional): New number of columns. If None, keeps current column count.

131

132

Returns:

133

Dict: Response from resize operation.

134

"""

135

```

136

137

### Auto-Resizing

138

139

Automatically adjust row heights and column widths.

140

141

```python { .api }

142

class Worksheet:

143

def rows_auto_resize(start_row_index: int, end_row_index: int = None) -> Dict:

144

"""

145

Auto-resize row heights to fit content.

146

147

Parameters:

148

- start_row_index (int): Starting row index (0-indexed).

149

- end_row_index (int, optional): Ending row index (0-indexed, exclusive). If None, resizes single row.

150

151

Returns:

152

Dict: Response from auto-resize operation.

153

"""

154

155

def columns_auto_resize(start_column_index: int, end_column_index: int = None) -> Dict:

156

"""

157

Auto-resize column widths to fit content.

158

159

Parameters:

160

- start_column_index (int): Starting column index (0-indexed).

161

- end_column_index (int, optional): Ending column index (0-indexed, exclusive). If None, resizes single column.

162

163

Returns:

164

Dict: Response from auto-resize operation.

165

"""

166

```

167

168

### Freezing Rows and Columns

169

170

Freeze rows and columns for scrolling.

171

172

```python { .api }

173

class Worksheet:

174

def freeze(rows: int = None, cols: int = None) -> Dict:

175

"""

176

Freeze rows and/or columns.

177

178

Parameters:

179

- rows (int, optional): Number of rows to freeze from top.

180

- cols (int, optional): Number of columns to freeze from left.

181

182

Returns:

183

Dict: Response from freeze operation.

184

"""

185

```

186

187

### Hiding and Showing

188

189

Control visibility of rows and columns.

190

191

```python { .api }

192

class Worksheet:

193

def hide_rows(start_index: int, end_index: int) -> Dict:

194

"""

195

Hide rows.

196

197

Parameters:

198

- start_index (int): Starting row index (0-indexed).

199

- end_index (int): Ending row index (0-indexed, exclusive).

200

201

Returns:

202

Dict: Response from hide operation.

203

"""

204

205

def hide_columns(start_index: int, end_index: int) -> Dict:

206

"""

207

Hide columns.

208

209

Parameters:

210

- start_index (int): Starting column index (0-indexed).

211

- end_index (int): Ending column index (0-indexed, exclusive).

212

213

Returns:

214

Dict: Response from hide operation.

215

"""

216

217

def unhide_rows(start_index: int, end_index: int) -> Dict:

218

"""

219

Show previously hidden rows.

220

221

Parameters:

222

- start_index (int): Starting row index (0-indexed).

223

- end_index (int): Ending row index (0-indexed, exclusive).

224

225

Returns:

226

Dict: Response from unhide operation.

227

"""

228

229

def unhide_columns(start_index: int, end_index: int) -> Dict:

230

"""

231

Show previously hidden columns.

232

233

Parameters:

234

- start_index (int): Starting column index (0-indexed).

235

- end_index (int): Ending column index (0-indexed, exclusive).

236

237

Returns:

238

Dict: Response from unhide operation.

239

"""

240

```

241

242

### Dimension Grouping

243

244

Create and manage groups of rows or columns.

245

246

```python { .api }

247

class Worksheet:

248

def add_dimension_group(dimension: str, start_index: int, end_index: int) -> Dict:

249

"""

250

Add dimension group (for collapsible sections).

251

252

Parameters:

253

- dimension (str): "ROWS" or "COLUMNS".

254

- start_index (int): Starting index (0-indexed).

255

- end_index (int): Ending index (0-indexed, exclusive).

256

257

Returns:

258

Dict: Response from group creation.

259

"""

260

261

def add_dimension_group_columns(start: int, end: int) -> Dict:

262

"""

263

Group columns in order to hide them in the UI.

264

265

Parameters:

266

- start (int): The start (inclusive) of the group.

267

- end (int): The end (exclusive) of the group.

268

269

Returns:

270

Dict: The response body.

271

"""

272

273

def add_dimension_group_rows(start: int, end: int) -> Dict:

274

"""

275

Group rows in order to hide them in the UI.

276

277

Parameters:

278

- start (int): The start (inclusive) of the group.

279

- end (int): The end (exclusive) of the group.

280

281

Returns:

282

Dict: The response body.

283

"""

284

285

def list_dimension_group_columns() -> List[Dict]:

286

"""

287

List all the grouped columns in this worksheet.

288

289

Returns:

290

List[Dict]: List of the grouped columns.

291

"""

292

293

def list_dimension_group_rows() -> List[Dict]:

294

"""

295

List all the grouped rows in this worksheet.

296

297

Returns:

298

List[Dict]: List of the grouped rows.

299

"""

300

301

def delete_dimension_group_rows(start_index: int, end_index: int) -> Dict:

302

"""

303

Delete row dimension group.

304

305

Parameters:

306

- start_index (int): Starting row index (0-indexed).

307

- end_index (int): Ending row index (0-indexed, exclusive).

308

309

Returns:

310

Dict: Response from group deletion.

311

"""

312

313

def delete_dimension_group_columns(start_index: int, end_index: int) -> Dict:

314

"""

315

Delete column dimension group.

316

317

Parameters:

318

- start_index (int): Starting column index (0-indexed).

319

- end_index (int): Ending column index (0-indexed, exclusive).

320

321

Returns:

322

Dict: Response from group deletion.

323

"""

324

```

325

326

### Worksheet Management

327

328

Update worksheet properties and manage worksheet lifecycle.

329

330

```python { .api }

331

class Worksheet:

332

def update_title(title: str) -> Dict:

333

"""

334

Update worksheet title.

335

336

Parameters:

337

- title (str): New title for the worksheet.

338

339

Returns:

340

Dict: Response from title update.

341

"""

342

343

def update_index(index: int) -> Dict:

344

"""

345

Update worksheet position/index.

346

347

Parameters:

348

- index (int): New index position (0-indexed).

349

350

Returns:

351

Dict: Response from index update.

352

"""

353

354

def copy_to(destination_spreadsheet_id: str) -> Worksheet:

355

"""

356

Copy worksheet to another spreadsheet.

357

358

Parameters:

359

- destination_spreadsheet_id (str): ID of destination spreadsheet.

360

361

Returns:

362

Worksheet: New worksheet instance in destination spreadsheet.

363

"""

364

365

def duplicate(insert_sheet_index: int = None, new_sheet_id: int = None, new_sheet_name: str = None) -> Worksheet:

366

"""

367

Duplicate this worksheet within same spreadsheet.

368

369

Parameters:

370

- insert_sheet_index (int, optional): Position to insert duplicated sheet.

371

- new_sheet_id (int, optional): ID for new sheet.

372

- new_sheet_name (str, optional): Name for new sheet.

373

374

Returns:

375

Worksheet: Duplicated worksheet instance.

376

"""

377

```

378

379

### Data Validation

380

381

Add validation rules to cells and ranges to control data entry.

382

383

```python { .api }

384

class Worksheet:

385

def add_validation(range: str, condition_type: str, values: List[Any],

386

inputMessage: str = None, strict: bool = False, showCustomUi: bool = False) -> Any:

387

"""

388

Add a data validation rule to any given range.

389

390

Parameters:

391

- range (str): The A1 notation of the range to validate.

392

- condition_type (str): The sort of condition to apply.

393

- values (List[Any]): List of condition values.

394

- inputMessage (str, optional): Message to show for the validation.

395

- strict (bool): Whether to reject invalid data or not. Default: False.

396

- showCustomUi (bool): Whether to show a custom UI (Dropdown) for list values. Default: False.

397

398

Returns:

399

Any: The validation response.

400

"""

401

```

402

403

### Structural Properties

404

405

```python { .api }

406

class Worksheet:

407

@property

408

def row_count -> int:

409

"""Number of rows in worksheet."""

410

411

@property

412

def col_count -> int:

413

"""Number of columns in worksheet."""

414

415

@property

416

def frozen_row_count -> int:

417

"""Number of frozen rows."""

418

419

@property

420

def frozen_col_count -> int:

421

"""Number of frozen columns."""

422

```

423

424

Usage examples:

425

426

```python

427

# Add rows and columns

428

worksheet.add_rows(10)

429

worksheet.add_cols(5)

430

431

# Insert rows with data

432

worksheet.insert_rows([

433

['Name', 'Age'],

434

['Alice', 25]

435

], row=1)

436

437

# Delete rows

438

worksheet.delete_rows(5, 10) # Delete rows 5-9

439

440

# Resize worksheet

441

worksheet.resize(rows=100, cols=20)

442

443

# Auto-resize columns to fit content

444

worksheet.columns_auto_resize(0, 5) # Columns A-E

445

446

# Freeze first row and column

447

worksheet.freeze(rows=1, cols=1)

448

449

# Hide columns B and C

450

worksheet.hide_columns(1, 3) # 0-indexed: columns 1-2

451

452

# Create dimension group for rows

453

worksheet.add_dimension_group('ROWS', 5, 10)

454

455

# Update worksheet title

456

worksheet.update_title('Data Sheet')

457

```