AI 函数

AI 函数允许您通过 AI 模型进行翻译(SJS.AI.TRANSLATE)、查询(SJS.AI.QUERY)或文本情感分析(SJS.AI.TEXTSENTIMENT)。

在新窗口中打开示例可以打开设计器 SJS.AI.TRANSLATE 函数可根据指定语言翻译数组。例如: 参数 必需 说明 array Y 要翻译的数组或区域 language Y 指定的目标语言 SJS.AI.QUERY 函数允许根据给定值从 AI 模型查询结果。例如: 参数 必需 说明 prompt Y 你希望 AI 模型执行的操作 array Y 要应用操作的数组或区域 SJS.AI.TEXTSENTIMENT 函数返回文本的情感分析结果(正面、负面或中性)。例如: 参数 必需 说明 array Y 要分析的数组或区域 positive Y 当文本情感为正面时的返回值 negative Y 当文本情感为负面时的返回值 neutral N 当文本情感为中性时的返回值 AI 生成内容免责声明 1. 内容生成风险 本服务利用用户注入的第三方 AI 模型生成输出。由于模型架构和训练数据的固有限制,结果可能包含不准确、遗漏或误导性内容。我们通过提示工程和技术约束优化输出,但无法完全消除因模型缺陷导致的错误风险。 2. 用户验证义务 使用本服务即表示您同意并承诺: 对所有生成内容进行人工核查 不在高风险场景(法律、医疗、金融等)中使用未经验证的输出 因依赖生成内容造成的任何直接或间接损失,均由您自行承担 3. 技术局限性 我们不对以下情况负责: 由第三方模型缺陷或逻辑错误导致的输出失败 容错机制下未能成功恢复错误 当前 AI 技术固有的技术限制 4. 知识产权合规 您需确保: 注入的模型/内容不侵犯第三方权益 不通过本服务处理非法或敏感材料 遵守模型提供方的知识产权协议 5. 协议更新 我们保留根据以下情况修改本条款的权利: 技术进步(如新的 AI 安全协议) 法规变更(如 AI 治理框架更新) 服务架构改进
let spreadNS = GC.Spread.Sheets; let config = GC.Spread.Sheets.Designer.DefaultConfig; window.onload = function () { const spread = createSpreadAndDesigner(); injectAI(spread); initSpread(spread); }; function createSpreadAndDesigner() { const demoHost = document.getElementById("demo-host"); if (window !== top) { const spread = new GC.Spread.Sheets.Workbook(demoHost, { sheetCount: 2 }); return spread; } else { const designer = new GC.Spread.Sheets.Designer.Designer( demoHost, undefined, undefined, { sheetCount: 2 } ); return designer.getWorkbook(); } } function initSpread(spread) { spread.options.allowDynamicArray = true; var sheet = spread.getActiveSheet(); spread.suspendPaint(); spread.suspendCalcService(); const restaurantReviews = [ ["Username", "Review"], [ "Miss Zhang", "The restaurant offers a beautiful ambiance and attentive service, perfect for family gatherings.", ], [ "Mr. Li", "The food is delicious, but the prices are slightly high, which affects the overall value.", ], [ "Mr. Wang", "It was noisy with poor service and slow food delivery, making for a disappointing experience.", ], [ "Emily", "Loved the unique dishes and inviting atmosphere! Definitely planning to come back.", ], [ "Ms. Chen", "Great flavors and a cozy setting, although the waiting time was a bit too long.", ], [ "Mr. Zhao", "A varied menu with mixed results; some dishes were outstanding while others were just average.", ], [ "George", "The service was extremely poor and the food quality subpar, leaving a very negative impression.", ], [ "Miss Liu", "The food was ordinary and the restaurant was too noisy, which detracted from the overall experience.", ], ]; sheet.setArray(0, 0, restaurantReviews); sheet.setColumnWidth(0, 95) sheet.setColumnWidth(1, 700); sheet.setColumnWidth(2, 160); sheet.setColumnWidth(3, 480); sheet.setValue(0, 2, "TEXTSENTIMENT"); sheet.setFormula(1, 2, '=SJS.AI.TEXTSENTIMENT(B2:B9, "Positive", "Negative", "Neutral")'); sheet.setFormula(0, 3, '="The Formula Is " & FORMULATEXT(C2)'); sheet.setFormula(11, 0, '="The Formula Is " & FORMULATEXT(A13)'); sheet.setFormula(12, 0, '=SJS.AI.TRANSLATE(A1:B9, "zh-cn")'); const countries = [ ["Country", "Please give me the capital of the country"], ["China"], ["India"], ["United States"], ["Indonesia"], ["Pakistan"], ["Brazil"], ["Nigeria"], ["Bangladesh"], ["Russia"], ["Japan"], ]; sheet.setFormula(23, 0, '="The Formula Is " & FORMULATEXT(B26)'); sheet.setArray(24, 0, countries); sheet.setFormula(25, 1, "=SJS.AI.QUERY(B25, A26:A35)"); spread.resumeCalcService(); spread.resumePaint(); } function _getElementById(id) { return document.getElementById(id); } function injectAI(spread) { const serverCallback = async (requestBody) => { const response = await fetch(getAIApiUrl(), { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(requestBody) }); if (response.status === 429) { alert('The server is busy, please try again later.'); return; } if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response; }; spread.injectAI(serverCallback); } function getAIApiUrl() { return window.location.href.match(/http.+spreadjs\/SpreadJSTutorial\//)[0] + 'server/api/queryAI'; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="spreadjs culture" content="zh-cn" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-shapes/dist/gc.spread.sheets.shapes.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-charts/dist/gc.spread.sheets.charts.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-print/dist/gc.spread.sheets.print.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-barcode/dist/gc.spread.sheets.barcode.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-pdf/dist/gc.spread.sheets.pdf.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-pivot-addon/dist/gc.spread.pivot.pivottables.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-slicers/dist/gc.spread.sheets.slicers.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-formula-panel/dist/gc.spread.sheets.formulapanel.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-io/dist/gc.spread.sheets.io.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-ai-addon/dist/gc.spread.sheets.ai.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-designer-resources-cn/dist/gc.spread.sheets.designer.resource.cn.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-designer/dist/gc.spread.sheets.designer.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/designer/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div id="demo-host"></div> </div> </body> </html>
body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .sample-tutorial { position: relative; height: 100%; overflow: hidden; display: flex; flex-direction: row; } #demo-host { width: 100%; height: 100%; }