> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/huong-dan-cac-action/file-and-folder/write-excel-file.md).

# Write excel file

Write excel file là hành động dùng để ghi hoặc cập nhật một giá trị cụ thể vào một ô dữ liệu xác định trong file Excel (`.xlsx` hoặc `.xls`) dựa trên vị trí hàng và cột được chỉ định.

🎥 Xem thêm video hướng dẫn: [Tại đây](https://youtu.be/EH7olDLAb9c).

#### Tham số cấu hình:

* File Path: Đường dẫn tuyệt đối dẫn đến file Excel cần ghi dữ liệu (Ví dụ: `D:\GPM\data.xlsx`).
* Sheet index: Vị trí của trang tính (sheet) cần ghi dữ liệu, bắt đầu tính từ 0 *(Sheet đầu tiên là `0`, sheet thứ hai là `1`...)*.
* Column Name or Index: Vị trí cột cần ghi dữ liệu. Bạn có thể điền theo hai cách:
  * Theo tên ký tự chữ cái: `A`, `B`, `C`, `D`...
  * Theo số mục chỉ số, bắt đầu tính từ 1 *(Cột A là `1`, cột B là `2`...)*.
* Row Index: Vị trí hàng cần ghi dữ liệu, bắt đầu tính từ 1 *(Hàng 1 là `1`, hàng 2 là `2`...)*.
* Value: Nội dung văn bản (hoặc biến chứa dữ liệu) mà bạn muốn ghi vào ô Excel đó.

#### Ví dụ thực tế: Cập nhật trạng thái tài khoản khớp theo từng dòng của Profile đang chạy

Khi bạn vận hành kịch bản đa luồng (chạy nhiều profile cùng lúc), mỗi profile sẽ được hệ thống GPM Automate gán sẵn các biến hệ thống để nhận diện: biến đường dẫn file Excel cấu hình đầu vào (`$inputExcelFileLocation`) và số thứ tự hàng dữ liệu mà profile đó đang đảm nhiệm (`$inputExcelCurrentRow`).

Giả sử bạn muốn kịch bản sau khi chạy xong bước đăng nhập thành công thì sẽ tự động ghi chữ `"Thành công"` vào cột C (Trạng thái) tương ứng với đúng hàng của profile đó trong file Excel:

* Cách cấu hình:
  * File Path: Truyền vào biến hệ thống `$inputExcelFileLocation`.
  * Sheet index: `0` *(Ghi vào sheet đầu tiên)*.
  * Column Name or Index: `C` *(Cột trạng thái)*.
  * Row Index: Truyền vào biến hệ thống `$inputExcelCurrentRow` *(Hệ thống tự động hiểu hàng tương ứng của từng profile, ví dụ profile 1 chạy hàng 2 sẽ ghi vào hàng 2, profile 2 chạy hàng 3 sẽ ghi vào hàng 3)*.
  * Value: Điền nội dung chuỗi `"Thành công"` (hoặc biến chứa log của bạn).

Kết quả: Kịch bản chạy đến đâu sẽ tự động cập nhật kết quả đồng bộ và chính xác vào file Excel đến đó theo thời gian thực mà không sợ bị ghi đè hay lệch hàng dữ liệu giữa các luồng.

<figure><img src="/files/vvB01fecYmzuAUaIJ0Ak" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/qDSX0lWedjtvTDEe8sw0" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/aL6O0JHG5gkxVPZ0gHTP" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/huong-dan-cac-action/file-and-folder/write-excel-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
