---
Product: Aspose.Cells
Platform: typescript
Page Type: docs
Canonical URL: https://docs.aspose.org/cells/typescript/developer-guide/working-with-spreadsheet-management
---

# Working with Spreadsheet Management

Manage worksheets, cell values, formulas, styling, data validation, auto-filters, and workbook protection with Aspose.Cells FOSS for TypeScript.

## Managing Worksheets

The `WorksheetCollection` class provides methods for managing worksheets within a workbook. Add new worksheets with `addWorksheet()`, remove with `removeWorksheet()`, and reorder with `moveWorksheet()`.

```typescript
import { Workbook } from "excel-cells";

const workbook = new Workbook();
const sheets = workbook.worksheets;

const sheet2 = sheets.addWorksheet("Sales");
const sheet3 = sheets.addWorksheet("Summary");

sheet2.putValue("A1", "Sales Data");
sheet3.putValue("A1", "Summary Report");

await workbook.save("multi-sheet.xlsx");
```

## Cell Values and Formulas

Write integers, decimals, and strings with `worksheet.putValue()`. Access cells by reference with `getCell2()` or by row/column index with `getCell()`. Set formulas with `cell.setFormula()`.

```typescript
const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

worksheet.putValue("A1", 42);
worksheet.putValue("A2", 3.14159);
worksheet.putValue("A3", "Hello World");

const cellA4 = worksheet.getCell2("A4");
cellA4.setFormula("=SUM(A1:A2)");

await workbook.save("values.xlsx");
```

## Font and Fill Styling

Apply font settings using the `Style` class. Set font name, size, bold, italic, and color. Apply the style to individual cells with `cell.setStyle()`.

```typescript
import { Workbook, Style } from "excel-cells";

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

const style = new Style();
style.setFontName("Arial");
style.setFontSize(14);
style.setBold(true);
style.setItalic(true);
style.setFontColor("FF0000");

const cell = worksheet.getCell2("A1");
cell.putValue("Styled Text");
cell.setStyle(style);

await workbook.save("styled.xlsx");
```

## Data Validation

Add validation rules to cell ranges using `DataValidation`. Specify the validation type (list, number range, or custom) and apply with `worksheet.addDataValidation()`.

```typescript
import { Workbook, DataValidation } from "excel-cells";

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

const validation = new DataValidation();
validation.type = "list";
validation.formula1 = '"Option1,Option2,Option3"';
worksheet.addDataValidation(validation, "B1:B10");

await workbook.save("validated.xlsx");
```

## Auto-Filter

Enable filterable column headers with `worksheet.setAutoFilter()`. Remove filters with `worksheet.removeAutoFilter()`.

```typescript
const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

worksheet.putValue("A1", "Name");
worksheet.putValue("B1", "Age");
worksheet.putValue("C1", "City");
worksheet.putValue("A2", "Alice");
worksheet.putValue("B2", "25");
worksheet.putValue("C2", "New York");

worksheet.setAutoFilter("A1:C4");
await workbook.save("filtered.xlsx");
```

## Hyperlinks

Attach hyperlinks to cells with `cell.setHyperlink()`. Supports URLs, email addresses, and internal sheet references.

```typescript
const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

worksheet.putValue("A1", "Click here");
worksheet.getCell2("A1").setHyperlink("https://www.example.com");

worksheet.putValue("A3", "Send email");
worksheet.getCell2("A3").setHyperlink("mailto:test@example.com");

await workbook.save("hyperlinks.xlsx");
```

## Workbook Protection

Protect workbooks with a password using `workbook.protect()`. Lock individual cells with `style.setLocked(true)`.

```typescript
import { Workbook, Style } from "excel-cells";

const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

worksheet.putValue("A1", "Protected Cell");
const style = new Style();
style.setLocked(true);
worksheet.getCell2("A1").setStyle(style);

workbook.protect(true, "password");
await workbook.save("protected.xlsx");
```

## Column and Row Sizing

Set column widths and row heights to control cell dimensions in the output XLSX file.

```typescript
const workbook = new Workbook();
const worksheet = workbook.worksheets[0]!;

worksheet.putValue("A1", "Wide Column");
worksheet.setColumnWidth(0, 30);
worksheet.setRowHeight(0, 25);

await workbook.save("sized.xlsx");
```

## See Also

- [Aspose.Cells — Enterprise Documentation](https://docs.aspose.com/cells/)