# 固定内存模式

## **内存**

最大内存使用量 = 最大一行的数据占用量

## **注意**

固定内存模式下，单元格按行落盘，如果当前操作的行已落盘则无法进行任何修改；

## **函数原型**

```php
constMemory(string $fileName[, string $sheetName = 'Sheet1', bool $enableZip64 = true]);
```

## 提示

WPS 需要关闭 zip64，否则打开文件可能报文件损坏；

该问题已反馈给WPS，修复进度未知，并且该问题在出现在iOS、Mac、Windows等平台，Android平台无异常。

## 示例

### 开启 ZIP64

```php
$config = ['path' => './tests'];
$excel  = new \Vtiful\Kernel\Excel($config);

// ConstMemory 默认开启 ZIP64
$fileObject = $excel->constMemory('tutorial01.xlsx');
$fileHandle = $fileObject->getHandle();

$format    = new \Vtiful\Kernel\Format($fileHandle);
$boldStyle = $format->bold()->toResource();

$fileObject->setRow('A1', 10, $boldStyle) // 写入数据前设置行样式
    ->header(['name', 'age'])
    ->data([['viest', 21]])
    ->output();
```

### 关闭 ZIP64

```php
$config = ['path' => './tests'];
$excel  = new \Vtiful\Kernel\Excel($config);

// 第三个参数 False 即为关闭 ZIP64
$fileObject = $excel->constMemory('tutorial01.xlsx', NULL, false);
$fileHandle = $fileObject->getHandle();

$format    = new \Vtiful\Kernel\Format($fileHandle);
$boldStyle = $format->bold()->toResource();

$fileObject->setRow('A1', 10, $boldStyle) // 写入数据前设置行样式
    ->header(['name', 'age'])
    ->data([['viest', 21]])
    ->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/zhong-wen-jian-ti/memory/fixed-memory.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.
