Hàm UDF (User-Defined Functions)
DVDAddin cung cấp ~70 hàm Excel tùy chỉnh — dùng như công thức Excel bình thường (=DvdSum(A1:A10)).
Cách dùng
Trong bất kỳ cell nào, gõ = + tên hàm + tham số:
=DvdNumToText(1234567) → "Một triệu hai trăm ba mươi tư nghìn năm trăm sáu mươi bảy"
=DvdDateLunar(A1) → "15/04/Ất Tỵ" (chuyển dương → âm)
=DvdSpillRows(A1:C100, "Hà Nội") → mảng động (spill) chứa các hàng matchingTất cả hàm bắt đầu prefix Dvd (vd: DvdSum, DvdLookup, DvdNumToText) — đảm bảo không xung đột tên với hàm built-in của Excel.
Phân nhóm hàm
Văn bản (DvdTextFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdUpper, DvdLower, DvdProper | Chữ hoa / thường / Mỗi Từ — hỗ trợ tiếng Việt có dấu (khác UPPER built-in). |
DvdRemoveDiacritics(text) | Bỏ dấu tiếng Việt: "Hà Nội" → "Ha Noi". |
DvdJoin(range, separator) | Nối các ô bằng separator (cải tiến TEXTJOIN). |
DvdRegexMatch(text, pattern) | True nếu text match regex. |
DvdRegexReplace(text, pattern, replacement) | Replace bằng regex. |
DvdExtractNumbers(text) | Trích các số từ text. |
DvdReverseText(text) | Đảo ngược chuỗi. |
DvdRomanToArabic(roman) | "MMXXVI" → 2026. |
DvdArabicToRoman(num) | 2026 → "MMXXVI". |
Số học và Tiền tệ (DvdMoneyAndMath.cs)
| Hàm | Mô tả |
|---|---|
DvdNumToText(num) | 1234 → "Một nghìn hai trăm ba mươi tư đồng". |
DvdNumToTextEN(num) | 1234 → "One thousand two hundred thirty four". |
DvdRound(value, mode) | Round với mode "up", "down", "nearest", "banker". |
DvdFormatVnd(num) | 1234567 → "1.234.567 đ". |
DvdFormatUsd(num) | 1234.56 → "$1,234.56". |
Ngày tháng (DvdDateTimeFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdWorkdays(start, end, holidays) | Số ngày làm việc (loại trừ T7, CN, holidays). |
DvdAddWorkdays(start, days, holidays) | Cộng N ngày làm việc. |
DvdMonthDiff(start, end) | Số tháng giữa 2 ngày. |
Âm lịch (DvdLunarCalendar.cs)
| Hàm | Mô tả |
|---|---|
DvdToLunar(date) | Dương → âm: "15/04/Ất Tỵ". |
DvdToSolar(lunarDate) | Âm → dương. |
Vùng (Range) (DvdRangeFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdSumVisible(range) | Tổng các ô VISIBLE (sau AutoFilter), khác SUM. |
DvdCountVisible(range) | Đếm ô visible. |
DvdLastNonEmpty(range) | Cell cuối cùng không trống. |
DvdFirstNonEmpty(range) | Cell đầu tiên không trống. |
DvdMaxByDate(rangeData, rangeDate) | Lấy giá trị tại ngày max. |
Tra cứu (Lookup) (DvdLookupFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdVLookupAll(needle, range, col) | Trả tất cả match (khác VLOOKUP chỉ trả first). |
DvdXLookup2D(rowKey, colKey, table) | XLOOKUP 2 chiều. |
DvdRangeByName(name) | Get range theo Named Range. |
Spill (mảng động) (DvdSpillFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdSpillFilter(range, condition) | Filter rows match condition → spill. |
DvdSpillUnique(range) | Unique values (khác UNIQUE built-in, hỗ trợ multi-column). |
DvdSpillSort(range, col, asc) | Sort spill. |
Shape (DvdShapeFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdShapeText(shapeName) | Text trong shape. |
DvdShapeFillColor(shapeName) | Màu fill của shape (hex). |
DvdShapePosition(shapeName, prop) | Lấy Top/Left/Width/Height. |
Mạng (Network) (DvdNetworkFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdHttpGet(url) | GET request, trả body text. |
DvdParseJson(text, path) | Đọc field JSON theo dotted path. |
AI (DvdAIFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdAskGemini(prompt) | Hỏi Gemini, trả text. Cell-level AI assistant. |
Giải thích (Explain) (DvdExplainFunctions.cs)
| Hàm | Mô tả |
|---|---|
DvdExplain(cell) | AI giải thích công thức trong cell. |
DvdExplainEN(cell) | English version. |
Auto-Hide / Auto-Show (DvdAutoHide.cs)
| Hàm | Mô tả |
|---|---|
DvdAutoHideRows(condition) | Ẩn/hiện hàng theo điều kiện (volatile). |
Dịch (Translate)
| Hàm | Mô tả |
|---|---|
DvdTranslateGoogle(text, from, to) | Dịch qua Google miễn phí. |
DvdTranslateGemini(text, from, to) | Dịch qua Gemini (cần API key). |
DvdTranslateChatGPT(text, from, to) | Dịch qua OpenAI/Groq/Cerebras. |
OCR (OcrLegacy.cs)
| Hàm | Mô tả |
|---|---|
DvdOcr(filePath) | OCR file ảnh → text. |
DvdOcrPdf(pdfPath, page) | OCR 1 trang PDF. |
Lưu ý
Volatile functions
Một số hàm là volatile — Excel tính lại mỗi khi BẤT KỲ cell nào thay đổi. Volatile functions:
DvdAutoHideRowsDvdHttpGet(nếu URL chứa{{timestamp}})
Volatile functions làm chậm workbook. Tránh dùng số lượng lớn (>100 cells).
Tính async
Các hàm gọi network (DvdHttpGet, DvdAskGemini, DvdTranslate*, DvdOcr*) chạy async — trả #GETTING_DATA ngay → resolve khi response về.
Nếu workbook có nhiều UDF async, có thể giới hạn concurrency để tránh rate limit:
DvdTranslate*dùng SemaphoreSlim(10) — tối đa 10 request song song.DvdHttpGetkhông giới hạn.
License gating
| Hàm | Free | Activated/Trial |
|---|---|---|
| Hàm text/number/date (local-only) | ✓ | ✓ |
DvdTranslateGoogle | ✓ | ✓ |
DvdTranslateGemini, DvdTranslateChatGPT, DvdAskGemini, DvdExplain*, DvdOcr* | ✗ (trả #LICENSE!) | ✓ |
Sample workbook
DVD Addin → ribbon → Mẫu Hồ sơ → mở file demo có sẵn các UDF.