> For the complete documentation index, see [llms.txt](https://kythuat.dtechvn.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kythuat.dtechvn.com/phieu-in-nhap-lieu/cau-lenh-format-phieu-in.md).

# CÂU LỆNH FORMAT PHIẾU IN

## 1. Số lượng

* Số lượng ở cột

```csharp
// số lượng ở cột
Replace(Replace(Replace(FormatString('{0:#,0.00;;0.00}',[SoLuong]), ',', ' '),'.',','),' ','.')
```

* Số lượng ở sum cột

```csharp
// Số lượng ở sum cột
Replace(Replace(Replace(FormatString('{0:#,#.00}',sumSum([SoLuong])), ',', ' '),'.',','),' ','.')
```

* Số lượng ở báo cáo

```csharp
// xử lý được: (0,95 thay vì ,95) && (0.00=>trắng)
{0:#,0.00;(#,0.00); }

//Nó được chia làm 3 phần ngăn cách bởi dấu chấm phẩy ;
// tương ứng với: [Số dương] ; [Số âm] ; [Số không]
/*
1. Cấu trúc tổng quát
{0: Phần_Dương ; Phần_Âm ; Phần_Số_Không }

Phần 1: #,0.00 (Dành cho số dương)
#: Ký tự đại diện cho chữ số (Digit placeholder). 
Nếu số không có chữ số ở vị trí đó thì sẽ để trống (không hiện số 0 vô nghĩa ở đầu).
,: Dấu ngăn cách hàng nghìn (Thousand separator).
0.00: Buộc hiển thị ít nhất một chữ số trước dấu phẩy và luôn luôn hiện 2 chữ số thập phân.
Ví dụ: 1234.5 -> 1,234.50

Phần 2: (#,0.00) (Dành cho số âm)
Dấu ngoặc đơn (...): Định dạng này thường dùng trong kế toán tài chính. Thay vì hiện dấu trừ -, số âm sẽ được bao lại trong dấu ngoặc.
Quy tắc hiển thị số bên trong giống hệt phần số dương.
Ví dụ: -1234.5 -> (1,234.50)

Phần 3:   (Dành cho số 0)
Khoảng trắng: Đây là một thủ thuật rất hay trong báo cáo.
Nếu giá trị bằng 0, chương trình sẽ không hiển thị gì cả 
(chỉ hiện một khoảng trắng). 
Điều này giúp báo cáo trông sạch sẽ hơn, người xem không bị rối mắt bởi quá nhiều số 0.
*/
```

## 2. Đơn giá

```
// Đơn giá cột
Replace(Replace(Replace(FormatString('{0:#,#.00}',[DonGia]), ',', ' '),'.',','),' ','.')
```

## 3. Thành tiền việt nam

```
// Thành tiền cột
Replace(Replace(Replace(FormatString('{0:#,#}',[PsNo]), ',', ' '),'.',','),' ','.')
// Thành tiền ở sum cột
Replace(Replace(Replace(FormatString('{0:#,#}',sumSum([PsNo])), ',', ' '),'.',','),' ','.')
```

## 4.KIỂU NGÀY

```
FormatString('{0:dd/MM/yyyy}', [Hansudung])

Trim([VatTu_Ten])+Char(13)+'- Lô sản xuất: '+[losanxuat]+char(13)+'- Hạn dùng: '+ Iif(GetYear([Hansudung])<>1900, FormatString('{0:dd/MM/yyyy}', [Hansudung]) ,'')
```

```sql
Trim([VatTu_Ten])+NewLine()+ ' - Lô sản xuất: ' + Trim([Losanxuat])+     NewLine()+ ' - Hạn sử dụng: '+ Iif(GetYear([Hansudung])<>1900, FormatString('{0:dd/MM/yyyy}',[Hansudung]),' /  /' )
```

```
// công thức object phiếu in
Iif(GetYear([NgayHD])<>1900,[NgayHD] ,'' )
// format string của object để hiển thị kiểu ngay dạng dd/MM/yyyy
{0:dd/MM/yyyy}
// format string của object để hiện thị kiểu thời gian Giờ:Phút
{0:HH:mm}
// ghi chú; 
Nếu dùng Expression: FormatString('{0:HH:mm}', [NgayChungTu])
Nếu dùng Text Format String: {0:HH:mm}
```

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

## 5. Format nhiều loại font chữ trong 1 đoạn text&#x20;

* Với label thì không xử lý được
* Chuyển sang Richtext
* Richtext thì sau khi gõ nội dung gồm: Text + Tên trường + tên biến thì có thể format
  * Bôi đen nội dung và format font đoạn cần xử lý
  * richtext chỉ sử dụng text, cột dữ liệu, biến. Không áp dụng công thức, + chuỗi


---

# 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://kythuat.dtechvn.com/phieu-in-nhap-lieu/cau-lenh-format-phieu-in.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.
