@gui-chat-plugin/spreadsheet 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/dist/core/definition.d.ts +7 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/plugin.d.ts +11 -0
- package/dist/core/samples.d.ts +5 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/core.cjs +1 -0
- package/dist/core.js +257 -0
- package/dist/engine/calculator.d.ts +21 -0
- package/dist/engine/date-parser.d.ts +34 -0
- package/dist/engine/date-utils.d.ts +31 -0
- package/dist/engine/engine.d.ts +134 -0
- package/dist/engine/evaluator.d.ts +36 -0
- package/dist/engine/formatter.d.ts +20 -0
- package/dist/engine/functions/date.d.ts +6 -0
- package/dist/engine/functions/financial.d.ts +4 -0
- package/dist/engine/functions/index.d.ts +14 -0
- package/dist/engine/functions/logical.d.ts +4 -0
- package/dist/engine/functions/lookup.d.ts +4 -0
- package/dist/engine/functions/mathematical.d.ts +4 -0
- package/dist/engine/functions/statistical.d.ts +4 -0
- package/dist/engine/functions/text.d.ts +4 -0
- package/dist/engine/index.d.ts +13 -0
- package/dist/engine/parser.d.ts +45 -0
- package/dist/engine/registry.d.ts +49 -0
- package/dist/engine/types.d.ts +53 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +9 -0
- package/dist/style.css +1 -0
- package/dist/vue/Preview.vue.d.ts +8 -0
- package/dist/vue/View.vue.d.ts +13 -0
- package/dist/vue/index.d.ts +23 -0
- package/dist/vue.cjs +97 -0
- package/dist/vue.js +18283 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @gui-chat-plugin/spreadsheet
|
|
2
|
+
|
|
3
|
+
A spreadsheet plugin for [MulmoChat](https://github.com/receptron/MulmoChat) - a multi-modal voice chat application with OpenAI's GPT-4 Realtime API.
|
|
4
|
+
|
|
5
|
+
## What this plugin does
|
|
6
|
+
|
|
7
|
+
This plugin provides a full-featured spreadsheet component with:
|
|
8
|
+
|
|
9
|
+
- Excel-like cell editing with formula support
|
|
10
|
+
- Mathematical functions (SUM, AVERAGE, MIN, MAX, etc.)
|
|
11
|
+
- Text functions (CONCATENATE, LEFT, RIGHT, MID, etc.)
|
|
12
|
+
- Date functions (TODAY, NOW, DATE, YEAR, MONTH, DAY, etc.)
|
|
13
|
+
- Logical functions (IF, AND, OR, NOT, etc.)
|
|
14
|
+
- Lookup functions (VLOOKUP, HLOOKUP, INDEX, MATCH)
|
|
15
|
+
- Financial functions (PMT, PV, FV, NPV, IRR)
|
|
16
|
+
- Multi-sheet support
|
|
17
|
+
- Excel file import/export (.xlsx)
|
|
18
|
+
- Cell formatting and styling
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
yarn add @gui-chat-plugin/spreadsheet
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Vue Implementation (for MulmoChat)
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
// In src/tools/index.ts
|
|
32
|
+
import SpreadsheetPlugin from "@gui-chat-plugin/spreadsheet/vue";
|
|
33
|
+
|
|
34
|
+
const pluginList = [
|
|
35
|
+
// ... other plugins
|
|
36
|
+
SpreadsheetPlugin,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
// In src/main.ts
|
|
40
|
+
import "@gui-chat-plugin/spreadsheet/style.css";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Core Only (Framework-agnostic)
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { pluginCore, TOOL_NAME } from "@gui-chat-plugin/spreadsheet";
|
|
47
|
+
// or
|
|
48
|
+
import pluginCore from "@gui-chat-plugin/spreadsheet";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Package Exports
|
|
52
|
+
|
|
53
|
+
| Export | Description |
|
|
54
|
+
|--------|-------------|
|
|
55
|
+
| `@gui-chat-plugin/spreadsheet` | Core (framework-agnostic) |
|
|
56
|
+
| `@gui-chat-plugin/spreadsheet/vue` | Vue implementation with UI components |
|
|
57
|
+
| `@gui-chat-plugin/spreadsheet/style.css` | Tailwind CSS styles |
|
|
58
|
+
|
|
59
|
+
## Supported Functions
|
|
60
|
+
|
|
61
|
+
### Mathematical
|
|
62
|
+
`SUM`, `AVERAGE`, `MIN`, `MAX`, `COUNT`, `COUNTA`, `ABS`, `ROUND`, `FLOOR`, `CEILING`, `POWER`, `SQRT`, `MOD`, `RAND`, `RANDBETWEEN`, `PI`
|
|
63
|
+
|
|
64
|
+
### Text
|
|
65
|
+
`CONCATENATE`, `LEFT`, `RIGHT`, `MID`, `LEN`, `UPPER`, `LOWER`, `PROPER`, `TRIM`, `SUBSTITUTE`, `REPLACE`, `TEXT`, `VALUE`, `FIND`, `SEARCH`, `REPT`
|
|
66
|
+
|
|
67
|
+
### Date & Time
|
|
68
|
+
`TODAY`, `NOW`, `DATE`, `YEAR`, `MONTH`, `DAY`, `HOUR`, `MINUTE`, `SECOND`, `WEEKDAY`, `DAYS`, `EDATE`, `EOMONTH`, `WORKDAY`, `NETWORKDAYS`, `DATEDIF`
|
|
69
|
+
|
|
70
|
+
### Logical
|
|
71
|
+
`IF`, `AND`, `OR`, `NOT`, `TRUE`, `FALSE`, `IFERROR`, `IFNA`, `IFS`, `SWITCH`, `XOR`
|
|
72
|
+
|
|
73
|
+
### Lookup
|
|
74
|
+
`VLOOKUP`, `HLOOKUP`, `INDEX`, `MATCH`, `OFFSET`, `INDIRECT`, `ROW`, `COLUMN`, `ROWS`, `COLUMNS`, `TRANSPOSE`
|
|
75
|
+
|
|
76
|
+
### Statistical
|
|
77
|
+
`MEDIAN`, `MODE`, `STDEV`, `STDEVP`, `VAR`, `VARP`, `LARGE`, `SMALL`, `RANK`, `PERCENTILE`, `QUARTILE`, `CORREL`, `COUNTIF`, `COUNTIFS`, `SUMIF`, `SUMIFS`, `AVERAGEIF`, `AVERAGEIFS`
|
|
78
|
+
|
|
79
|
+
### Financial
|
|
80
|
+
`PMT`, `PV`, `FV`, `NPV`, `IRR`, `RATE`, `NPER`, `IPMT`, `PPMT`, `SLN`, `DB`, `DDB`
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Install dependencies
|
|
86
|
+
yarn install
|
|
87
|
+
|
|
88
|
+
# Start dev server (http://localhost:5173/)
|
|
89
|
+
yarn dev
|
|
90
|
+
|
|
91
|
+
# Build
|
|
92
|
+
yarn build
|
|
93
|
+
|
|
94
|
+
# Type check
|
|
95
|
+
yarn typecheck
|
|
96
|
+
|
|
97
|
+
# Lint
|
|
98
|
+
yarn lint
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
MIT
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreadsheet Tool Definition (Schema)
|
|
3
|
+
*/
|
|
4
|
+
import type { ToolDefinition } from "gui-chat-protocol";
|
|
5
|
+
export declare const TOOL_NAME = "presentSpreadsheet";
|
|
6
|
+
export declare const TOOL_DEFINITION: ToolDefinition;
|
|
7
|
+
export declare const SYSTEM_PROMPT = "Use presentSpreadsheet whenever the user needs a spreadsheet-style table, multi-step math, or dynamic what-if analysis\u2014do not summarize in text. Build LIVE sheets where every cell is an object {\"v\": value, \"f\": format}. For formulas, set \"v\" to a string starting with \"=\" (e.g., {\"v\": \"=B2*1.05\", \"f\": \"$#,##0.00\"}). For dates, use date strings like \"01/15/2025\" or date formulas like \"=TODAY()\" or \"=DATE(2025,1,15)\". The spreadsheet auto-parses common date formats (MM/DD/YYYY, YYYY-MM-DD, DD-MMM-YYYY) into date serial numbers for calculations. Date arithmetic works: \"=B2-TODAY()\" calculates days between dates. Never pre-calculate; let the spreadsheet compute using cell refs, functions (SUM, AVERAGE, IF, TODAY, DATE, DATEDIF, etc.), and arithmetic. Standard formats: \"$#,##0.00\" currency, \"#,##0\" integer, \"0.00%\" percent, \"0.00\" decimal, \"MM/DD/YYYY\" date, \"DD-MMM-YYYY\" date, \"YYYY-MM-DD\" ISO date. Format is optional for plain text/numbers.";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreadsheet Plugin - Core (Framework-agnostic)
|
|
3
|
+
*
|
|
4
|
+
* This module exports the core plugin logic without UI components.
|
|
5
|
+
* Import from "@anthropic/guichat-plugin-spreadsheet" or "@anthropic/guichat-plugin-spreadsheet/core"
|
|
6
|
+
*/
|
|
7
|
+
export type { SpreadsheetCell, SpreadsheetSheet, SpreadsheetToolData, SpreadsheetArgs, } from "./types";
|
|
8
|
+
export { TOOL_NAME, TOOL_DEFINITION, SYSTEM_PROMPT, executeSpreadsheet, pluginCore, } from "./plugin";
|
|
9
|
+
export { samples } from "./samples";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreadsheet Plugin Core (Framework-agnostic)
|
|
3
|
+
*
|
|
4
|
+
* Contains the plugin logic without UI components.
|
|
5
|
+
* Can be used by any framework (Vue, React, etc.)
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolPluginCore, ToolContext, ToolResult } from "gui-chat-protocol";
|
|
8
|
+
import type { SpreadsheetToolData, SpreadsheetArgs } from "./types";
|
|
9
|
+
export { TOOL_NAME, TOOL_DEFINITION, SYSTEM_PROMPT } from "./definition";
|
|
10
|
+
export declare const executeSpreadsheet: (_context: ToolContext, args: SpreadsheetArgs) => Promise<ToolResult<SpreadsheetToolData, never>>;
|
|
11
|
+
export declare const pluginCore: ToolPluginCore<SpreadsheetToolData, never, SpreadsheetArgs>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreadsheet Plugin Types
|
|
3
|
+
*
|
|
4
|
+
* Plugin-specific types only.
|
|
5
|
+
* Common types are imported from gui-chat-protocol.
|
|
6
|
+
*/
|
|
7
|
+
export interface SpreadsheetCell {
|
|
8
|
+
v: string | number;
|
|
9
|
+
f?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface SpreadsheetSheet {
|
|
12
|
+
name: string;
|
|
13
|
+
data: Array<Array<SpreadsheetCell>>;
|
|
14
|
+
}
|
|
15
|
+
export interface SpreadsheetToolData {
|
|
16
|
+
sheets: SpreadsheetSheet[];
|
|
17
|
+
}
|
|
18
|
+
export interface SpreadsheetArgs {
|
|
19
|
+
title: string;
|
|
20
|
+
sheets: SpreadsheetSheet[];
|
|
21
|
+
}
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a="presentSpreadsheet",n={type:"function",name:a,description:"Display an Excel-like spreadsheet with formulas and calculations.",parameters:{type:"object",properties:{title:{type:"string",description:"Title for the spreadsheet"},sheets:{type:"array",description:"Sheets to render as spreadsheet tabs. Each sheet includes a name and 2D array of cells (rows x columns).",items:{type:"object",properties:{name:{type:"string",description:"Sheet name (e.g., 'Sales Q1', 'Summary')"},data:{type:"array",description:`Rows of cells. Each cell is an object with 'v' (value) and 'f' (format). Use Excel-style A1 notation in formulas: columns are letters (A, B, C...), rows are 1-based numbers (1, 2, 3...). Values can be text, numbers, dates, or formulas. Examples: [{"v": "Product"}, {"v": 2024, "f": "#,##0"}, {"v": "01/15/2025", "f": "MM/DD/YYYY"}, {"v": "=B2*1.05", "f": "$#,##0.00"}]. Format codes: '$#,##0.00' (currency), '#,##0' (integer), '0.00%' (percent), '0.00' (decimal), 'MM/DD/YYYY' (date), 'DD-MMM-YYYY' (date), 'YYYY-MM-DD' (ISO date).`,items:{type:"array",description:"Row of cells. Each cell is an object with value and format.",items:{type:"object",description:"Cell object with value and optional format. If value is a string starting with '=', it's treated as a formula.",properties:{v:{oneOf:[{type:"string"},{type:"number"}],description:"Cell value. Can be text, number, date, or formula (string starting with '='). Examples: 'Revenue', 1500000, '01/15/2025', '=SUM(A1:A10)', '=B2-TODAY()'. Date strings like '01/15/2025' are automatically parsed to date serial numbers."},f:{type:"string",description:"Optional format code for displaying the value. Common formats: '$#,##0.00' (currency), '#,##0' (integer), '0.00%' (percent), '0.00' (decimal), 'MM/DD/YYYY' (date), 'DD-MMM-YYYY' (date), 'YYYY-MM-DD' (ISO date)"}},required:["v"]}}}},required:["name","data"]}}},required:["title","sheets"]}},o=`Use ${a} whenever the user needs a spreadsheet-style table, multi-step math, or dynamic what-if analysis—do not summarize in text. Build LIVE sheets where every cell is an object {"v": value, "f": format}. For formulas, set "v" to a string starting with "=" (e.g., {"v": "=B2*1.05", "f": "$#,##0.00"}). For dates, use date strings like "01/15/2025" or date formulas like "=TODAY()" or "=DATE(2025,1,15)". The spreadsheet auto-parses common date formats (MM/DD/YYYY, YYYY-MM-DD, DD-MMM-YYYY) into date serial numbers for calculations. Date arithmetic works: "=B2-TODAY()" calculates days between dates. Never pre-calculate; let the spreadsheet compute using cell refs, functions (SUM, AVERAGE, IF, TODAY, DATE, DATEDIF, etc.), and arithmetic. Standard formats: "$#,##0.00" currency, "#,##0" integer, "0.00%" percent, "0.00" decimal, "MM/DD/YYYY" date, "DD-MMM-YYYY" date, "YYYY-MM-DD" ISO date. Format is optional for plain text/numbers.`,v=async(d,r)=>{const{title:s}=r;let{sheets:t}=r;if(typeof t=="string")try{t=JSON.parse(t),console.warn("Sheets was provided as a string and has been parsed to an array")}catch(e){throw new Error(`Invalid sheets format: sheets must be an array, not a string. Parse error: ${e instanceof Error?e.message:String(e)}`)}if(!Array.isArray(t)||t.length===0)throw new Error("At least one sheet is required. Sheets must be an array of sheet objects.");for(const e of t)if(!e.name||!e.data||e.data.length===0)throw new Error(`Invalid sheet: ${e.name||"unnamed"}. Each sheet must have a name and data array.`);return{message:`Created spreadsheet: ${s}`,title:s,data:{sheets:t},instructions:"Acknowledge that the spreadsheet has been created and is displayed to the user."}},i={toolDefinition:n,execute:v,generatingMessage:"Creating spreadsheet...",waitingMessage:"Tell the user that the spreadsheet was created and will be presented shortly.",isEnabled:()=>!0,systemPrompt:o},l=[{name:"Simple Budget",args:{title:"Monthly Budget",sheets:[{name:"Budget",data:[[{v:"Category"},{v:"Amount"}],[{v:"Income"},{v:5e3,f:"$#,##0.00"}],[{v:"Rent"},{v:-1500,f:"$#,##0.00"}],[{v:"Utilities"},{v:-200,f:"$#,##0.00"}],[{v:"Food"},{v:-600,f:"$#,##0.00"}],[{v:"Transport"},{v:-300,f:"$#,##0.00"}],[{v:"Total"},{v:"=SUM(B2:B6)",f:"$#,##0.00"}]]}]}},{name:"Sales Report",args:{title:"Q1 Sales Report",sheets:[{name:"Sales",data:[[{v:"Product"},{v:"Jan"},{v:"Feb"},{v:"Mar"},{v:"Total"}],[{v:"Widget A"},{v:1200},{v:1350},{v:1500},{v:"=SUM(B2:D2)"}],[{v:"Widget B"},{v:800},{v:920},{v:1100},{v:"=SUM(B3:D3)"}],[{v:"Widget C"},{v:450},{v:480},{v:520},{v:"=SUM(B4:D4)"}],[{v:"Total"},{v:"=SUM(B2:B4)"},{v:"=SUM(C2:C4)"},{v:"=SUM(D2:D4)"},{v:"=SUM(E2:E4)"}]]}]}},{name:"Loan Calculator",args:{title:"Loan Calculator",sheets:[{name:"Calculator",data:[[{v:"Loan Amount"},{v:25e4,f:"$#,##0"}],[{v:"Interest Rate"},{v:.065,f:"0.00%"}],[{v:"Term (Years)"},{v:30}],[{v:""},{v:""}],[{v:"Monthly Payment"},{v:"=PMT(B2/12, B3*12, -B1)",f:"$#,##0.00"}],[{v:"Total Interest"},{v:"=B5*B3*12-B1",f:"$#,##0.00"}]]}]}},{name:"World Population",args:{title:"世界人口(上位10)",sheets:[{name:"世界人口(上位10)",data:[[{v:"順位"},{v:"国・地域"},{v:"人口(概数)",f:"#,##0"},{v:"上位10合計に占める割合"},{v:"世界人口に占める割合"}],[{v:1,f:"#,##0"},{v:"インド"},{v:1428627e3,f:"#,##0"},{v:"=C2/$C$12",f:"0.00%"},{v:"=C2/$C$13",f:"0.00%"}],[{v:2,f:"#,##0"},{v:"中国"},{v:1425671e3,f:"#,##0"},{v:"=C3/$C$12",f:"0.00%"},{v:"=C3/$C$13",f:"0.00%"}],[{v:3,f:"#,##0"},{v:"アメリカ合衆国"},{v:334e6,f:"#,##0"},{v:"=C4/$C$12",f:"0.00%"},{v:"=C4/$C$13",f:"0.00%"}],[{v:4,f:"#,##0"},{v:"インドネシア"},{v:277e6,f:"#,##0"},{v:"=C5/$C$12",f:"0.00%"},{v:"=C5/$C$13",f:"0.00%"}],[{v:5,f:"#,##0"},{v:"パキスタン"},{v:24e7,f:"#,##0"},{v:"=C6/$C$12",f:"0.00%"},{v:"=C6/$C$13",f:"0.00%"}],[{v:6,f:"#,##0"},{v:"ナイジェリア"},{v:219e6,f:"#,##0"},{v:"=C7/$C$12",f:"0.00%"},{v:"=C7/$C$13",f:"0.00%"}],[{v:7,f:"#,##0"},{v:"ブラジル"},{v:216e6,f:"#,##0"},{v:"=C8/$C$12",f:"0.00%"},{v:"=C8/$C$13",f:"0.00%"}],[{v:8,f:"#,##0"},{v:"バングラデシュ"},{v:172e6,f:"#,##0"},{v:"=C9/$C$12",f:"0.00%"},{v:"=C9/$C$13",f:"0.00%"}],[{v:9,f:"#,##0"},{v:"ロシア"},{v:146e6,f:"#,##0"},{v:"=C10/$C$12",f:"0.00%"},{v:"=C10/$C$13",f:"0.00%"}],[{v:10,f:"#,##0"},{v:"メキシコ"},{v:13e7,f:"#,##0"},{v:"=C11/$C$12",f:"0.00%"},{v:"=C11/$C$13",f:"0.00%"}],[{v:""},{v:"合計(上位10)"},{v:"=SUM(C2:C11)",f:"#,##0"},{v:""},{v:""}],[{v:""},{v:"世界推定人口(例)"},{v:805e7,f:"#,##0"},{v:""},{v:""}]]}]}}];exports.SYSTEM_PROMPT=o;exports.TOOL_DEFINITION=n;exports.TOOL_NAME=a;exports.executeSpreadsheet=v;exports.pluginCore=i;exports.samples=l;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
const s = "presentSpreadsheet", n = {
|
|
2
|
+
type: "function",
|
|
3
|
+
name: s,
|
|
4
|
+
description: "Display an Excel-like spreadsheet with formulas and calculations.",
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
title: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "Title for the spreadsheet"
|
|
11
|
+
},
|
|
12
|
+
sheets: {
|
|
13
|
+
type: "array",
|
|
14
|
+
description: "Sheets to render as spreadsheet tabs. Each sheet includes a name and 2D array of cells (rows x columns).",
|
|
15
|
+
items: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
name: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Sheet name (e.g., 'Sales Q1', 'Summary')"
|
|
21
|
+
},
|
|
22
|
+
data: {
|
|
23
|
+
type: "array",
|
|
24
|
+
description: `Rows of cells. Each cell is an object with 'v' (value) and 'f' (format). Use Excel-style A1 notation in formulas: columns are letters (A, B, C...), rows are 1-based numbers (1, 2, 3...). Values can be text, numbers, dates, or formulas. Examples: [{"v": "Product"}, {"v": 2024, "f": "#,##0"}, {"v": "01/15/2025", "f": "MM/DD/YYYY"}, {"v": "=B2*1.05", "f": "$#,##0.00"}]. Format codes: '$#,##0.00' (currency), '#,##0' (integer), '0.00%' (percent), '0.00' (decimal), 'MM/DD/YYYY' (date), 'DD-MMM-YYYY' (date), 'YYYY-MM-DD' (ISO date).`,
|
|
25
|
+
items: {
|
|
26
|
+
type: "array",
|
|
27
|
+
description: "Row of cells. Each cell is an object with value and format.",
|
|
28
|
+
items: {
|
|
29
|
+
type: "object",
|
|
30
|
+
description: "Cell object with value and optional format. If value is a string starting with '=', it's treated as a formula.",
|
|
31
|
+
properties: {
|
|
32
|
+
v: {
|
|
33
|
+
oneOf: [{ type: "string" }, { type: "number" }],
|
|
34
|
+
description: "Cell value. Can be text, number, date, or formula (string starting with '='). Examples: 'Revenue', 1500000, '01/15/2025', '=SUM(A1:A10)', '=B2-TODAY()'. Date strings like '01/15/2025' are automatically parsed to date serial numbers."
|
|
35
|
+
},
|
|
36
|
+
f: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "Optional format code for displaying the value. Common formats: '$#,##0.00' (currency), '#,##0' (integer), '0.00%' (percent), '0.00' (decimal), 'MM/DD/YYYY' (date), 'DD-MMM-YYYY' (date), 'YYYY-MM-DD' (ISO date)"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: ["v"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
required: ["name", "data"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
required: ["title", "sheets"]
|
|
51
|
+
}
|
|
52
|
+
}, o = `Use ${s} whenever the user needs a spreadsheet-style table, multi-step math, or dynamic what-if analysis—do not summarize in text. Build LIVE sheets where every cell is an object {"v": value, "f": format}. For formulas, set "v" to a string starting with "=" (e.g., {"v": "=B2*1.05", "f": "$#,##0.00"}). For dates, use date strings like "01/15/2025" or date formulas like "=TODAY()" or "=DATE(2025,1,15)". The spreadsheet auto-parses common date formats (MM/DD/YYYY, YYYY-MM-DD, DD-MMM-YYYY) into date serial numbers for calculations. Date arithmetic works: "=B2-TODAY()" calculates days between dates. Never pre-calculate; let the spreadsheet compute using cell refs, functions (SUM, AVERAGE, IF, TODAY, DATE, DATEDIF, etc.), and arithmetic. Standard formats: "$#,##0.00" currency, "#,##0" integer, "0.00%" percent, "0.00" decimal, "MM/DD/YYYY" date, "DD-MMM-YYYY" date, "YYYY-MM-DD" ISO date. Format is optional for plain text/numbers.`, v = async (i, a) => {
|
|
53
|
+
const { title: r } = a;
|
|
54
|
+
let { sheets: t } = a;
|
|
55
|
+
if (typeof t == "string")
|
|
56
|
+
try {
|
|
57
|
+
t = JSON.parse(t), console.warn(
|
|
58
|
+
"Sheets was provided as a string and has been parsed to an array"
|
|
59
|
+
);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Invalid sheets format: sheets must be an array, not a string. Parse error: ${e instanceof Error ? e.message : String(e)}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (!Array.isArray(t) || t.length === 0)
|
|
66
|
+
throw new Error(
|
|
67
|
+
"At least one sheet is required. Sheets must be an array of sheet objects."
|
|
68
|
+
);
|
|
69
|
+
for (const e of t)
|
|
70
|
+
if (!e.name || !e.data || e.data.length === 0)
|
|
71
|
+
throw new Error(
|
|
72
|
+
`Invalid sheet: ${e.name || "unnamed"}. Each sheet must have a name and data array.`
|
|
73
|
+
);
|
|
74
|
+
return {
|
|
75
|
+
message: `Created spreadsheet: ${r}`,
|
|
76
|
+
title: r,
|
|
77
|
+
data: { sheets: t },
|
|
78
|
+
instructions: "Acknowledge that the spreadsheet has been created and is displayed to the user."
|
|
79
|
+
};
|
|
80
|
+
}, l = {
|
|
81
|
+
toolDefinition: n,
|
|
82
|
+
execute: v,
|
|
83
|
+
generatingMessage: "Creating spreadsheet...",
|
|
84
|
+
waitingMessage: "Tell the user that the spreadsheet was created and will be presented shortly.",
|
|
85
|
+
isEnabled: () => !0,
|
|
86
|
+
systemPrompt: o
|
|
87
|
+
}, d = [
|
|
88
|
+
{
|
|
89
|
+
name: "Simple Budget",
|
|
90
|
+
args: {
|
|
91
|
+
title: "Monthly Budget",
|
|
92
|
+
sheets: [
|
|
93
|
+
{
|
|
94
|
+
name: "Budget",
|
|
95
|
+
data: [
|
|
96
|
+
[{ v: "Category" }, { v: "Amount" }],
|
|
97
|
+
[{ v: "Income" }, { v: 5e3, f: "$#,##0.00" }],
|
|
98
|
+
[{ v: "Rent" }, { v: -1500, f: "$#,##0.00" }],
|
|
99
|
+
[{ v: "Utilities" }, { v: -200, f: "$#,##0.00" }],
|
|
100
|
+
[{ v: "Food" }, { v: -600, f: "$#,##0.00" }],
|
|
101
|
+
[{ v: "Transport" }, { v: -300, f: "$#,##0.00" }],
|
|
102
|
+
[{ v: "Total" }, { v: "=SUM(B2:B6)", f: "$#,##0.00" }]
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: "Sales Report",
|
|
110
|
+
args: {
|
|
111
|
+
title: "Q1 Sales Report",
|
|
112
|
+
sheets: [
|
|
113
|
+
{
|
|
114
|
+
name: "Sales",
|
|
115
|
+
data: [
|
|
116
|
+
[{ v: "Product" }, { v: "Jan" }, { v: "Feb" }, { v: "Mar" }, { v: "Total" }],
|
|
117
|
+
[{ v: "Widget A" }, { v: 1200 }, { v: 1350 }, { v: 1500 }, { v: "=SUM(B2:D2)" }],
|
|
118
|
+
[{ v: "Widget B" }, { v: 800 }, { v: 920 }, { v: 1100 }, { v: "=SUM(B3:D3)" }],
|
|
119
|
+
[{ v: "Widget C" }, { v: 450 }, { v: 480 }, { v: 520 }, { v: "=SUM(B4:D4)" }],
|
|
120
|
+
[{ v: "Total" }, { v: "=SUM(B2:B4)" }, { v: "=SUM(C2:C4)" }, { v: "=SUM(D2:D4)" }, { v: "=SUM(E2:E4)" }]
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: "Loan Calculator",
|
|
128
|
+
args: {
|
|
129
|
+
title: "Loan Calculator",
|
|
130
|
+
sheets: [
|
|
131
|
+
{
|
|
132
|
+
name: "Calculator",
|
|
133
|
+
data: [
|
|
134
|
+
[{ v: "Loan Amount" }, { v: 25e4, f: "$#,##0" }],
|
|
135
|
+
[{ v: "Interest Rate" }, { v: 0.065, f: "0.00%" }],
|
|
136
|
+
[{ v: "Term (Years)" }, { v: 30 }],
|
|
137
|
+
[{ v: "" }, { v: "" }],
|
|
138
|
+
[{ v: "Monthly Payment" }, { v: "=PMT(B2/12, B3*12, -B1)", f: "$#,##0.00" }],
|
|
139
|
+
[{ v: "Total Interest" }, { v: "=B5*B3*12-B1", f: "$#,##0.00" }]
|
|
140
|
+
]
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "World Population",
|
|
147
|
+
args: {
|
|
148
|
+
title: "世界人口(上位10)",
|
|
149
|
+
sheets: [
|
|
150
|
+
{
|
|
151
|
+
name: "世界人口(上位10)",
|
|
152
|
+
data: [
|
|
153
|
+
[
|
|
154
|
+
{ v: "順位" },
|
|
155
|
+
{ v: "国・地域" },
|
|
156
|
+
{ v: "人口(概数)", f: "#,##0" },
|
|
157
|
+
{ v: "上位10合計に占める割合" },
|
|
158
|
+
{ v: "世界人口に占める割合" }
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
{ v: 1, f: "#,##0" },
|
|
162
|
+
{ v: "インド" },
|
|
163
|
+
{ v: 1428627e3, f: "#,##0" },
|
|
164
|
+
{ v: "=C2/$C$12", f: "0.00%" },
|
|
165
|
+
{ v: "=C2/$C$13", f: "0.00%" }
|
|
166
|
+
],
|
|
167
|
+
[
|
|
168
|
+
{ v: 2, f: "#,##0" },
|
|
169
|
+
{ v: "中国" },
|
|
170
|
+
{ v: 1425671e3, f: "#,##0" },
|
|
171
|
+
{ v: "=C3/$C$12", f: "0.00%" },
|
|
172
|
+
{ v: "=C3/$C$13", f: "0.00%" }
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
{ v: 3, f: "#,##0" },
|
|
176
|
+
{ v: "アメリカ合衆国" },
|
|
177
|
+
{ v: 334e6, f: "#,##0" },
|
|
178
|
+
{ v: "=C4/$C$12", f: "0.00%" },
|
|
179
|
+
{ v: "=C4/$C$13", f: "0.00%" }
|
|
180
|
+
],
|
|
181
|
+
[
|
|
182
|
+
{ v: 4, f: "#,##0" },
|
|
183
|
+
{ v: "インドネシア" },
|
|
184
|
+
{ v: 277e6, f: "#,##0" },
|
|
185
|
+
{ v: "=C5/$C$12", f: "0.00%" },
|
|
186
|
+
{ v: "=C5/$C$13", f: "0.00%" }
|
|
187
|
+
],
|
|
188
|
+
[
|
|
189
|
+
{ v: 5, f: "#,##0" },
|
|
190
|
+
{ v: "パキスタン" },
|
|
191
|
+
{ v: 24e7, f: "#,##0" },
|
|
192
|
+
{ v: "=C6/$C$12", f: "0.00%" },
|
|
193
|
+
{ v: "=C6/$C$13", f: "0.00%" }
|
|
194
|
+
],
|
|
195
|
+
[
|
|
196
|
+
{ v: 6, f: "#,##0" },
|
|
197
|
+
{ v: "ナイジェリア" },
|
|
198
|
+
{ v: 219e6, f: "#,##0" },
|
|
199
|
+
{ v: "=C7/$C$12", f: "0.00%" },
|
|
200
|
+
{ v: "=C7/$C$13", f: "0.00%" }
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
{ v: 7, f: "#,##0" },
|
|
204
|
+
{ v: "ブラジル" },
|
|
205
|
+
{ v: 216e6, f: "#,##0" },
|
|
206
|
+
{ v: "=C8/$C$12", f: "0.00%" },
|
|
207
|
+
{ v: "=C8/$C$13", f: "0.00%" }
|
|
208
|
+
],
|
|
209
|
+
[
|
|
210
|
+
{ v: 8, f: "#,##0" },
|
|
211
|
+
{ v: "バングラデシュ" },
|
|
212
|
+
{ v: 172e6, f: "#,##0" },
|
|
213
|
+
{ v: "=C9/$C$12", f: "0.00%" },
|
|
214
|
+
{ v: "=C9/$C$13", f: "0.00%" }
|
|
215
|
+
],
|
|
216
|
+
[
|
|
217
|
+
{ v: 9, f: "#,##0" },
|
|
218
|
+
{ v: "ロシア" },
|
|
219
|
+
{ v: 146e6, f: "#,##0" },
|
|
220
|
+
{ v: "=C10/$C$12", f: "0.00%" },
|
|
221
|
+
{ v: "=C10/$C$13", f: "0.00%" }
|
|
222
|
+
],
|
|
223
|
+
[
|
|
224
|
+
{ v: 10, f: "#,##0" },
|
|
225
|
+
{ v: "メキシコ" },
|
|
226
|
+
{ v: 13e7, f: "#,##0" },
|
|
227
|
+
{ v: "=C11/$C$12", f: "0.00%" },
|
|
228
|
+
{ v: "=C11/$C$13", f: "0.00%" }
|
|
229
|
+
],
|
|
230
|
+
[
|
|
231
|
+
{ v: "" },
|
|
232
|
+
{ v: "合計(上位10)" },
|
|
233
|
+
{ v: "=SUM(C2:C11)", f: "#,##0" },
|
|
234
|
+
{ v: "" },
|
|
235
|
+
{ v: "" }
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
{ v: "" },
|
|
239
|
+
{ v: "世界推定人口(例)" },
|
|
240
|
+
{ v: 805e7, f: "#,##0" },
|
|
241
|
+
{ v: "" },
|
|
242
|
+
{ v: "" }
|
|
243
|
+
]
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
];
|
|
250
|
+
export {
|
|
251
|
+
o as SYSTEM_PROMPT,
|
|
252
|
+
n as TOOL_DEFINITION,
|
|
253
|
+
s as TOOL_NAME,
|
|
254
|
+
v as executeSpreadsheet,
|
|
255
|
+
l as pluginCore,
|
|
256
|
+
d as samples
|
|
257
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreadsheet Calculator
|
|
3
|
+
*
|
|
4
|
+
* Core calculation engine with circular reference detection and cross-sheet support
|
|
5
|
+
*/
|
|
6
|
+
import type { SheetData, CalculatedSheet } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* Calculate formulas in a single sheet
|
|
9
|
+
*
|
|
10
|
+
* @param sheet - Sheet data to calculate
|
|
11
|
+
* @param allSheets - All sheets for cross-sheet references
|
|
12
|
+
* @returns Calculated sheet with formulas evaluated
|
|
13
|
+
*/
|
|
14
|
+
export declare function calculateSheet(sheet: SheetData, allSheets?: SheetData[]): CalculatedSheet;
|
|
15
|
+
/**
|
|
16
|
+
* Calculate all sheets in a workbook
|
|
17
|
+
*
|
|
18
|
+
* @param sheets - Array of sheets to calculate
|
|
19
|
+
* @returns Array of calculated sheets
|
|
20
|
+
*/
|
|
21
|
+
export declare function calculateWorkbook(sheets: SheetData[]): CalculatedSheet[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date Parsing Utilities
|
|
3
|
+
*
|
|
4
|
+
* Parse various date string formats into Excel serial numbers.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Check if a string looks like a date
|
|
8
|
+
*
|
|
9
|
+
* @param str - String to check
|
|
10
|
+
* @returns true if string matches common date patterns
|
|
11
|
+
*/
|
|
12
|
+
export declare function isDateLike(str: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Parse a date string into Excel serial number
|
|
15
|
+
*
|
|
16
|
+
* Supports formats:
|
|
17
|
+
* - MM/DD/YYYY, M/D/YYYY
|
|
18
|
+
* - DD/MM/YYYY (when day > 12)
|
|
19
|
+
* - YYYY-MM-DD, YYYY/MM/DD (ISO format)
|
|
20
|
+
* - DD-MMM-YYYY, D-MMM-YYYY
|
|
21
|
+
* - MMM D, YYYY, MMMM D, YYYY
|
|
22
|
+
*
|
|
23
|
+
* @param dateStr - String that might contain a date
|
|
24
|
+
* @param preferDDMMYYYY - Prefer DD/MM/YYYY over MM/DD/YYYY for ambiguous dates (default: false)
|
|
25
|
+
* @returns Serial number or null if not a valid date
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDate(dateStr: string, preferDDMMYYYY?: boolean): number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Get default date format based on parsed date
|
|
30
|
+
*
|
|
31
|
+
* @param originalStr - Original date string
|
|
32
|
+
* @returns Appropriate format code
|
|
33
|
+
*/
|
|
34
|
+
export declare function getDefaultDateFormat(originalStr: string): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Date Utility Functions
|
|
3
|
+
*
|
|
4
|
+
* Shared utilities for converting between JavaScript Date objects and Excel serial numbers.
|
|
5
|
+
* Excel stores dates as sequential serial numbers so they can be used in calculations.
|
|
6
|
+
* January 1, 1900 is serial number 1.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Convert JavaScript Date to Excel Serial Number
|
|
10
|
+
*
|
|
11
|
+
* @param date - JavaScript Date object
|
|
12
|
+
* @returns Excel serial number (days since Dec 30, 1899)
|
|
13
|
+
*/
|
|
14
|
+
export declare const dateToSerial: (date: Date) => number;
|
|
15
|
+
/**
|
|
16
|
+
* Convert Excel Serial Number to JavaScript Date
|
|
17
|
+
*
|
|
18
|
+
* @param serial - Excel serial number
|
|
19
|
+
* @returns JavaScript Date object
|
|
20
|
+
*/
|
|
21
|
+
export declare const serialToDate: (serial: number) => Date;
|
|
22
|
+
/**
|
|
23
|
+
* Month names for formatting
|
|
24
|
+
*/
|
|
25
|
+
export declare const MONTH_NAMES_SHORT: string[];
|
|
26
|
+
export declare const MONTH_NAMES_FULL: string[];
|
|
27
|
+
/**
|
|
28
|
+
* Day names for formatting
|
|
29
|
+
*/
|
|
30
|
+
export declare const DAY_NAMES_SHORT: string[];
|
|
31
|
+
export declare const DAY_NAMES_FULL: string[];
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpreadsheetEngine - Main API
|
|
3
|
+
*
|
|
4
|
+
* High-level interface for spreadsheet calculations
|
|
5
|
+
*/
|
|
6
|
+
import type { SheetData, CalculatedSheet, EngineOptions, SpreadsheetCell } from "./types";
|
|
7
|
+
/**
|
|
8
|
+
* SpreadsheetEngine - Main calculation engine class
|
|
9
|
+
*
|
|
10
|
+
* Provides a clean API for calculating spreadsheet formulas with support for:
|
|
11
|
+
* - Formula evaluation (SUM, AVERAGE, IF, etc.)
|
|
12
|
+
* - Cell references (A1, $B$2, Sheet1!C3)
|
|
13
|
+
* - Cross-sheet references
|
|
14
|
+
* - Number formatting ($#,##0.00, 0.00%, etc.)
|
|
15
|
+
* - Circular reference detection
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const engine = new SpreadsheetEngine();
|
|
20
|
+
* const sheet = {
|
|
21
|
+
* name: 'Sales',
|
|
22
|
+
* data: [
|
|
23
|
+
* [{v: 'Product'}, {v: 'Price'}, {v: 'Qty'}, {v: 'Total'}],
|
|
24
|
+
* [{v: 'Widget'}, {v: 10}, {v: 100}, {v: '=B2*C2'}],
|
|
25
|
+
* ]
|
|
26
|
+
* };
|
|
27
|
+
* const result = engine.calculate(sheet);
|
|
28
|
+
* console.log(result.data); // [['Product', 'Price', 'Qty', 'Total'], ['Widget', 10, 100, 1000]]
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class SpreadsheetEngine {
|
|
32
|
+
private options;
|
|
33
|
+
/**
|
|
34
|
+
* Create a new SpreadsheetEngine
|
|
35
|
+
*
|
|
36
|
+
* @param options - Configuration options
|
|
37
|
+
*/
|
|
38
|
+
constructor(options?: EngineOptions);
|
|
39
|
+
/**
|
|
40
|
+
* Calculate a single sheet
|
|
41
|
+
*
|
|
42
|
+
* Evaluates all formulas in the sheet and applies number formatting.
|
|
43
|
+
* Returns calculated values with formula metadata and any errors.
|
|
44
|
+
*
|
|
45
|
+
* @param sheet - Sheet data with formulas
|
|
46
|
+
* @param allSheets - Optional array of all sheets for cross-sheet references
|
|
47
|
+
* @returns Calculated sheet with evaluated formulas
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* const result = engine.calculate({
|
|
52
|
+
* name: 'Budget',
|
|
53
|
+
* data: [
|
|
54
|
+
* [{v: 'Item'}, {v: 'Amount'}],
|
|
55
|
+
* [{v: 'Revenue'}, {v: 1000}],
|
|
56
|
+
* [{v: 'Expenses'}, {v: 600}],
|
|
57
|
+
* [{v: 'Profit'}, {v: '=B2-B3'}],
|
|
58
|
+
* ]
|
|
59
|
+
* });
|
|
60
|
+
* console.log(result.data[3][1]); // 400
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
calculate(sheet: SheetData, allSheets?: SheetData[]): CalculatedSheet;
|
|
64
|
+
/**
|
|
65
|
+
* Calculate all sheets in a workbook
|
|
66
|
+
*
|
|
67
|
+
* Evaluates formulas across multiple sheets with support for
|
|
68
|
+
* cross-sheet references (e.g., Sheet1!A1).
|
|
69
|
+
*
|
|
70
|
+
* @param sheets - Array of sheets to calculate
|
|
71
|
+
* @returns Array of calculated sheets
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const results = engine.calculateWorkbook([
|
|
76
|
+
* { name: 'Data', data: [[{v: 100}]] },
|
|
77
|
+
* { name: 'Summary', data: [[{v: '=Data!A1*2'}]] }
|
|
78
|
+
* ]);
|
|
79
|
+
* console.log(results[1].data[0][0]); // 200
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
calculateWorkbook(sheets: SheetData[]): CalculatedSheet[];
|
|
83
|
+
/**
|
|
84
|
+
* Get current engine options
|
|
85
|
+
*
|
|
86
|
+
* @returns Current configuration options
|
|
87
|
+
*/
|
|
88
|
+
getOptions(): Required<EngineOptions>;
|
|
89
|
+
/**
|
|
90
|
+
* Update engine options
|
|
91
|
+
*
|
|
92
|
+
* @param options - Options to update
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* engine.setOptions({ strictMode: true });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
setOptions(options: Partial<EngineOptions>): void;
|
|
100
|
+
/**
|
|
101
|
+
* Create a simple sheet from array data
|
|
102
|
+
*
|
|
103
|
+
* Helper method to create a SheetData object from simple arrays.
|
|
104
|
+
* Automatically converts values to SpreadsheetCell format.
|
|
105
|
+
*
|
|
106
|
+
* @param name - Sheet name
|
|
107
|
+
* @param data - Array of arrays (rows and cells)
|
|
108
|
+
* @returns SheetData object
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const sheet = engine.createSheet('Sales', [
|
|
113
|
+
* ['Product', 'Price', 'Qty', 'Total'],
|
|
114
|
+
* ['Widget', 10, 100, '=B2*C2'],
|
|
115
|
+
* ]);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
createSheet(name: string, data: Array<Array<SpreadsheetCell | string | number>>): SheetData;
|
|
119
|
+
/**
|
|
120
|
+
* Convert calculated sheet data to string array
|
|
121
|
+
*
|
|
122
|
+
* Helper method for testing and output formatting.
|
|
123
|
+
*
|
|
124
|
+
* @param calculated - Calculated sheet
|
|
125
|
+
* @returns 2D array of strings
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const result = engine.calculate(sheet);
|
|
130
|
+
* const stringArray = engine.toStringArray(result);
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
toStringArray(calculated: CalculatedSheet): string[][];
|
|
134
|
+
}
|