# Page breaks

Insert horizontal / vertical page breaks before specific rows / columns to force Excel to start a new page at that position.

## Function Prototype

```php
horizontalPageBreaks(array $rows): self
verticalPageBreaks(array $cols): self
```

### **array $rows**

> 1-based row numbers. Each value inserts a horizontal break **before** that row.

### **array $cols**

> 1-based column numbers. Each value inserts a vertical break **before** that column.

## Example

```php
$config = [
    'path' => './tests'
];

$fileObject = new \Vtiful\Kernel\Excel($config);
$fileObject = $fileObject->fileName('tutorial.xlsx');

$rows = [];
for ($i = 1; $i <= 100; $i++) {
    $rows[] = ["row{$i}", $i];
}

$filePath = $fileObject->header(['name', 'value'])
    ->data($rows)
    ->horizontalPageBreaks([20, 40, 60, 80]) // New page every 20 rows
    ->verticalPageBreaks([3])                // Page break before column 3
    ->output();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xlswriter-docs.viest.me/english/page-setup/page-breaks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
