# XLSX 转 CSV - 常规模式

## 应用场景

1. 较多的 xlsx 文件碎片，合并为单一CSV文件，统一处理；
2. xlsx文件新增的速度大于任务处理速度，可异步将文件转为CSV后，使用更高效的工具处理（例如：数据库工具直接导入CSV）；

更多的应用场景等待你去发现...........

## **函数原型**

```php
putCSV(resource $handler): bool
```

### **resource $handler**

> 文件指针必须是有效的，必须指向由 fopen() 或 fsockopen() 成功打开的文件(并还未由 fclose() 关闭)。

## 示例

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

$filePath = $excel->fileName('tutorial.xlsx', 'TestSheet1')
    ->header(['Item', 'Cost'])
    ->data([
        ['Item_1', 'Cost_1', 10, 10.9999995],
    ])
    ->output();

// 写入方式打开，将文件指针指向文件末尾。
$fp = fopen('./tests/file.csv', 'a');

$csvResult = $excel->openFile('tutorial.xlsx')
    ->openSheet()
    ->putCSV($fp);
```


---

# 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/csv/put-csv.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.
