syncfusion-dotnet-calculate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSyncfusion dotnet Calculate
Syncfusion dotnet Calculate
Overview
概述
Parses and evaluates formulas using the Syncfusion dotnet Calculate. It generates C# code to enable interactive formula calculation functionality, including expression parsing, dependency resolution, and runtime evaluation of calculated values.
使用Syncfusion dotnet Calculate解析和计算公式。它会生成C#代码以实现交互式公式计算功能,包括表达式解析、依赖项解析和计算值的运行时求值。
Quick Start Examples
快速入门示例
Example 1
示例1
User: "Show me how to Parse and Compute the formulas using the CalcEngine"
Result: C# code generated to for parsed and Computed the formula
用户: "Show me how to Parse and Compute the formulas using the CalcEngine"
结果: 生成用于解析和计算公式的C#代码
Example 2
示例2
User: "Add custom formula to the calculate control to compare two strings"
Result: C# code generated for create custom function
用户: "Add custom formula to the calculate control to compare two strings"
结果: 生成用于创建自定义函数的C#代码
Generate C# Code for the User's Project (default)
为用户项目生成C#代码(默认)
Trigger keywords: "code", "snippet", "how to write", "Program.cs", "show me", "sample", "example code", "generate code for", "NuGet", "add to project", "integrate", "implementation", "usage example", "API example", "compute formula", "evaluate expression", "calculate result", "parse formula", "register variable", "cross-sheet formula", "use CalcQuickBase", "use CalcEngine", "use ICalcData", "compute with cell references", "auto calc", "refresh calculations", "reset keys", "format result", "region settings", "custom function", "user-defined formula", "register function", "LibraryFunctions", "ExcelLikeComputations", "iterative calculation", "suspend calculations", "supported formulas", "list formulas" "ParseAndCompute" "parseAndComputeFormula".
触发关键词: "code", "snippet", "how to write", "Program.cs", "show me", "sample", "example code", "generate code for", "NuGet", "add to project", "integrate", "implementation", "usage example", "API example", "compute formula", "evaluate expression", "calculate result", "parse formula", "register variable", "cross-sheet formula", "use CalcQuickBase", "use CalcEngine", "use ICalcData", "compute with cell references", "auto calc", "refresh calculations", "reset keys", "format result", "region settings", "custom function", "user-defined formula", "register function", "LibraryFunctions", "ExcelLikeComputations", "iterative calculation", "suspend calculations", "supported formulas", "list formulas" "ParseAndCompute" "parseAndComputeFormula".
STEP 1 — Analyze User Request
步骤1 — 分析用户请求
- Read the user’s request and extract the feature keywords.
- If relevant reference/*.md files exist, use them as the only source of truth for generating code.
- If no matching reference file exists, generate code using the samples in references/getting-started.md.
- 读取用户请求并提取功能关键词。
- 如果存在相关的reference/*.md文件,将其作为生成代码的唯一可信来源。
- 如果没有匹配的参考文件,使用references/getting-started.md中的示例生成代码。
STEP 2 — Consent & Destination Gate (MUST ASK BEFORE ANY FILE ACTIONS)
步骤2 — 同意与目标确认(任何文件操作前必须询问)
Before generating or writing anything, ask the user:
I'm ready to generate your Syncfusion Calculate sample.
Where should I place it?
1) Create a new Form file in the skill's "output" folder (recommended for quick tryout)
2) Add or modify an existing file in your project (please provide the full file path; choose append or replace)
3) Say "Just show me the code" to get the snippet here without modifying any files.Rules
- Do NOT proceed until the user selects an option or says "Just show me the code."
- If the user refuses file modifications:
- Only show the C# code in chat
- No file creation or changes
- For Option 2 only: Before generating code, check if the project has the prerequisites from (Prerequisites and Setup Requirements section). If missing, ask user consent and add them.
references/getting-started.md
在生成或写入任何内容前,询问用户:
我已准备好生成你的Syncfusion Calculate示例。
我应该把它放在哪里?
1) 在技能的"output"文件夹中创建一个新的Form文件(推荐用于快速试用)
2) 添加或修改你项目中的现有文件(请提供完整文件路径,选择追加或替换)
3) 回复"Just show me the code"即可在此获取代码片段,无需修改任何文件。规则
- 在用户选择选项或回复"Just show me the code"前不要继续操作。
- 如果用户拒绝修改文件:
- 仅在聊天中展示C#代码
- 不创建或修改任何文件
- 仅针对选项2: 生成代码前,检查项目是否满足(先决条件和设置要求部分)的前置要求。如果缺失,请求用户同意后再添加。
references/getting-started.md
STEP 3 — Generate Code (Strict Reference-Only Rules)
步骤3 — 生成代码(严格仅使用参考内容规则)
- ALWAYS use the sample code structure from the "Minimal code" section in getting-started.md as the base template for Calculate creation.
- Use APIs exactly as shown in references/*.md (e.g., getting-started.md, Xlsio.md).
- Never invent APIs or guess behavior.
- If the feature is not documented in any reference file, inform the user that it is unavailable.
- 始终以getting-started.md中"最小代码"部分的示例代码结构作为创建Calculate功能的基础模板。
- 严格按照references/*.md(例如getting-started.md、Xlsio.md)中的说明使用API。
- 绝不虚构API或猜测行为。
- 如果参考文件中没有记录该功能,告知用户该功能不可用。
STEP 4 — Apply Changes (Only After Consent)
步骤4 — 应用变更(仅在获得同意后)
Option A — Create New File in Skill’s Folder
-
Create a folder namedat the skill root (if it does not already exist).
output/ -
Default filename:
CalculateSample.cs -
If the file already exists, ask: "A file named 'CalculateSample.cs' already exists. Overwrite, append, or use a different name?"
-
Wait for the user’s decision before writing anything.
-
Write the generated C# content.
Option B — Modify a File in the User’s Project
- Ask: "Which file should I modify? Provide the COMPLETE file path (e.g., D:\Project\program.cs)"
- Wait for explicit confirmation.
- If the user only replies with “2” (option number) and no path → ask again.
- Never guess or infer file paths.
- Once confirmed, apply the requested change (overwrite or append).
Option C — Show the Code Only
- Display the generated C# code in chat.
- Do NOT create or modify any files.
选项A — 在技能文件夹中创建新文件
-
在技能根目录创建名为的文件夹(如果不存在)。
output/ -
默认文件名:
CalculateSample.cs -
如果文件已存在,询问: "名为'CalculateSample.cs'的文件已存在。要覆盖、追加还是使用其他名称?"
-
写入任何内容前等待用户决策。
-
写入生成的C#内容。
选项B — 修改用户项目中的文件
- 询问: "我应该修改哪个文件?请提供完整文件路径(例如D:\Project\program.cs)"
- 等待明确确认。
- 如果用户仅回复“2”(选项编号)没有提供路径 → 再次询问。
- 绝不猜测或推断文件路径。
- 确认后应用请求的变更(覆盖或追加)。
选项C — 仅展示代码
- 在聊天中展示生成的C#代码。
- 不创建或修改任何文件。
Code References
代码参考
All templates and feature snippets live in references/*.md. Each file is a focused snippet the agent combines when generating samples.
Flow: Always start with references/getting-started.md (Prerequisites and Setup Requirements section), then merge matched feature snippets. If no feature keywords match, return only the basic sample.
| File | Contents |
|---|---|
| getting-started.md | Prerequisites, NuGet package setup, Program.cs configuration, minimal code examples for CalcQuickBase and ICalcData, cross-sheet references, culture settings, quick reference table |
| calcquickbase.md | ParseAndCompute method, register variables with square bracket notation, compute expressions and built-in formulas, AutoCalc for automatic recalculation, RefreshAllCalculations, ResetKeys method, key properties and methods, indexer-based access |
| ICalcData.md | ICalcData interface implementation, SetValueRowCol/GetValueRowCol methods, WireParentObject method, ValueChanged event, complete implementation example, integration with CalcEngine, cross-sheet references, data grid integration |
| calcengine.md | ParseFormula method, ComputeFormula method, ParseAndComputeFormula method, cross-sheet references with RegisterGridAsSheet and CreateSheetFamilyID, region/culture settings (ParseDecimalSeparator, ParseArgumentSeparator), error strings, supported built-in formulas by category |
| customfunction.md | LibraryFunction delegate, custom function creation, registration with CalcEngine, examples (CustomMin, CustomMax, ApplyDiscount, CalculateGrade, CompoundInterest), RemoveFunction method, managing library functions, error handling, best practices |
| xlsio.md | XlsIO integration, ExcelEngine initialization, enable/disable sheet calculations (EnableSheetCalculations/DisableSheetCalculations), set and compute values at runtime, suspend calculations during bulk updates (CalculatingSuspended), CalculatedValue property, table formulas, complete workflows, error handling |
| overview.md | 400+ predefined functions across categories, supported environments and platforms, non-UI component architecture, formula types supported, function categories reference, typical use cases, integration with XlsIO |
| parse-compute.md | ParseFormula method and RPN conversion, ComputeFormula method for stack-based evaluation, ParseAndComputeFormula combined approach, operator precedence and parsing order, error handling and error strings, formatting computed results (decimal, percentage, currency), performance optimization |
| operators.md | Formula operators and their precedence, supported operators in calculations |
| namedranges.md | Named ranges support for simplifying complex formulas |
| performance.md | Performance optimization techniques and best practices |
所有模板和功能片段都存放在references/*.md中。生成示例时,Agent会组合每个文件中的针对性片段。
流程:始终从references/getting-started.md(先决条件和设置要求部分)开始,然后合并匹配的功能片段。如果没有匹配的功能关键词,仅返回基础示例。
| 文件 | 内容 |
|---|---|
| getting-started.md | 先决条件、NuGet包设置、Program.cs配置、CalcQuickBase和ICalcData的最小代码示例、跨工作表引用、区域性设置、快速参考表 |
| calcquickbase.md | ParseAndCompute方法、使用方括号表示法注册变量、计算表达式和内置公式、用于自动重算的AutoCalc、RefreshAllCalculations、ResetKeys方法、核心属性和方法、基于索引器的访问 |
| ICalcData.md | ICalcData接口实现、SetValueRowCol/GetValueRowCol方法、WireParentObject方法、ValueChanged事件、完整实现示例、与CalcEngine集成、跨工作表引用、数据网格集成 |
| calcengine.md | ParseFormula方法、ComputeFormula方法、ParseAndComputeFormula方法、通过RegisterGridAsSheet和CreateSheetFamilyID实现跨工作表引用、区域/区域性设置(ParseDecimalSeparator、ParseArgumentSeparator)、错误字符串、按分类的支持内置公式列表 |
| customfunction.md | LibraryFunction委托、自定义函数创建、通过CalcEngine注册、示例(CustomMin、CustomMax、ApplyDiscount、CalculateGrade、CompoundInterest)、RemoveFunction方法、库函数管理、错误处理、最佳实践 |
| xlsio.md | XlsIO集成、ExcelEngine初始化、启用/禁用工作表计算(EnableSheetCalculations/DisableSheetCalculations)、运行时设置和计算值、批量更新期间暂停计算(CalculatingSuspended)、CalculatedValue属性、表格公式、完整工作流、错误处理 |
| overview.md | 覆盖各分类的400+预定义函数、支持的环境和平台、非UI组件架构、支持的公式类型、函数分类参考、典型用例、与XlsIO集成 |
| parse-compute.md | ParseFormula方法和RPN转换、用于栈式求值的ComputeFormula方法、ParseAndComputeFormula组合方案、运算符优先级和解析顺序、错误处理和错误字符串、格式化计算结果(小数、百分比、货币)、性能优化 |
| operators.md | 公式运算符及其优先级、计算支持的运算符 |
| namedranges.md | 用于简化复杂公式的命名范围支持 |
| performance.md | 性能优化技术和最佳实践 |
Rules
规则
-
Use Only Reference Snippets
- Generate code exclusively from the Markdown files under `references/
- Do not invent/guess/include any properties, events, API methods, component names, or parameters not present in
references/*.md
-
NO FILE MODIFICATIONS WITHOUT PERMISSION
- Never create or modify files/folders in user workspace without explicit user selection and confirmation.
-
Unsupported Feature Handling
- If the user requests a feature with no corresponding snippet in , respond with:
references/*.mdThat feature is not currently supported by the Syncfusion Calculate Library. - Suggest the closest supported features only if they have snippets
- Explicitly list unsupported items and do not synthesize code for them
- If the user requests a feature with no corresponding snippet in
-
Validation Before Write
- Re-validate before writing that all code blocks originate from files
references/*.md - If validation fails, stop and inform the user
- Re-validate before writing that all code blocks originate from
-
仅使用参考片段
- 仅基于下的Markdown文件生成代码
references/ - 不要虚构/猜测/包含任何中不存在的属性、事件、API方法、组件名称或参数
references/*.md
- 仅基于
-
未经许可不得修改文件
- 未获得用户明确选择和确认前,绝不要在用户工作区创建或修改文件/文件夹。
-
不支持功能的处理
- 如果用户请求的功能在中没有对应片段,回复:
references/*.mdThat feature is not currently supported by the Syncfusion Calculate Library. - 仅当存在对应片段时,才推荐最接近的支持功能
- 明确列出不支持的项,不要为其合成代码
- 如果用户请求的功能在
-
写入前验证
- 写入前重新验证所有代码块都来自文件
references/*.md - 如果验证失败,停止操作并告知用户
- 写入前重新验证所有代码块都来自