DeepSeek + 在线Excel , 打造智能表格新纪元
微信搜一搜【葡萄城社区】关注,了解更多动态
SpreadJS 已经接入 DeepSeek 啦!
相信这段时间,大家都被【DeepSeek】刷屏了。DeepSeek 以其强大的技术能力和创新的解决方案,迅速成为行业焦点,吸引了众多厂商纷纷接入合作。很多使用葡萄城表格技术的开发者们也在问, SpreadJS 能不能接入 DeepSeek 呢?
当然能!本文将介绍 SpreadJS 接入 DeepSeek 的效果和接入方法。有了之前 SpreadJS 接入 ChatGPT 的经验,接入 DeepSeek 更是轻而易举。
SpreadJS 接入 DeepSeek 之后的效果
1.接入之后,先问问是不是 DeepSeek 吧。

确认了,是DeepSeek,没问题。
2.确认之后,使用 DeepSeek 根据单元格数据做动态提问

3.看不懂公式的意思,也问问 DeepSeek 吧

不好意思,没想到DeepSeek认真负责,还给出了示例。Dialog 要弄大点。
4.再试一试用 DeepSeek 生成公式

这次有点过于认真了,如果直接返回公式就可以直接插入单元格了。
5.再和DeepSeek来一点互动
5.1 数据看不懂,看看 DeepSeek 怎么说的。

5.2 怎么创建数据透视表

5.3 说的没错,让他创建吧

透视表都创建了,各种图表也不在话下。
最后,SpreadJS 怎么接入DeepSeek呢
把之前 Demo 里 OpenAI 的地址换成 DeepSeek 的地址,模型改成 DeepSeek 的模型就好啦。主要代码再放一遍,完整工程可以找技术顾问获取。
自定义 DeepSeek 提问函数
// 自定义DeepSeek提问函数
var DeepSeek_Query = function () { };
DeepSeek_Query.prototype = new GC.Spread.CalcEngine.Functions.AsyncFunction('DeepSeek.QUERY', 1, 1, {
description: "向GPT提问,直接返回结果",
parameters: [
{
name: "问题"
}]
});
DeepSeek_Query.prototype.defaultValue = function () { return 'Loading...'; };
DeepSeek_Query.prototype.evaluateAsync = function (context, arg) {
if (!arg) {
return GC.Spread.CalcEngine.Errors.NotAvailable;
} const response = openai.chat.completions.create({
model: modelInfo.model,
messages: [
{ role: "system", content: "You are a helpful excel assistant. " },
{ role: "user", content: arg + ",?只返回结果。" }
],
});
response.then(function (completion) {
let desc = completion.choices[0].message.content;
context.setAsyncResult(desc);
});
};
GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction("DeepSeek.QUERY", new DeepSeek_Query());
设计器公式分析命令
let formulaAnalyze = {
"title":"智能公式分析",
"text":"公式分析",
"iconClass":"ribbon-button-formulaAnalyze",
"bigButton":"=ribbonHeight>toolbarHeight",
"commandName":"formulaAnalyze",
execute: function(designer){
let spread = designer.getWorkbook(),sheet = spread.getActiveSheet();
let formula = sheet.getFormula(sheet.getActiveRowIndex(), sheet.getActiveColumnIndex());
if(formula){
let loading = ElLoading.service({ lock: true, text: "Loading", background: "rgba(0, 0, 0, 0.7)"});
const response = openai.chat.completions.create({
model: modelInfo.model,
messages: [
{ role: "system", content: "You are a helpful assistant. 直接告诉我公式的意义,不用计算结果,答复里不能重复问题。" },
{ role: "user", content: formula + ",这个公式有什么意义?" }
],
});
response.then(function(completion){
loading.close();
let desc = completion.choices[0].message.content;
GC.Spread.Sheets.Designer.showMessageBox(desc, "", GC.Spread.Sheets.Designer.MessageBoxIcon.info)
}).catch(function(){loading.close()});
}
else{
GC.Spread.Sheets.Designer.showMessageBox("单元格没有公式", "提醒", GC.Spread.Sheets.Designer.MessageBoxIcon.warning)
}
}
}
创建透视表Function Calling
let messages = [{"role": "system","content": "你是一个数据透视表分析助手。"},
{
"role": "user",
"content":
`根据表格标题内容和需求描述推荐创建数据透视表需要的行、列和值字段。
表格标题为:
---
${headerList}
---
需求描述:
---
${bindingData.description}
---`
}];
let functions = [{"type": "function",
"function":{
"name": "pivot_talbe_analyze",
"description": "对数据创建数据透视表,返回数据透视表结果",
"parameters": {
"type": "object",
"properties": {
"rowFieldName": {
"type": "string",
"description": "行字段名称"
},
"columnFieldName": {
"type": "string",
"description": "列段名称"
},
"dataFieldName": {
"type": "string",
"description": "值字段名称"
},
},
"required": ["rowFieldName", "dataFieldName"]
},
"strict": true
}}]
try {
var completion = await openai.chat.completions.create({
"model": "qwen-plus",
"messages": messages,
"tools": functions,
"function_call": {"name": "pivot_talbe_analyze"}
});
if(completion.choices[0].message.tool_calls){
let args = JSON.parse(completion.choices[0].message.tool_calls[0].function.arguments);
spread.suspendPaint();
let activeSheetIndex = spread.getActiveSheetIndex();
spread.addSheet(activeSheetIndex);
spread.setActiveSheetIndex(activeSheetIndex);
let newSheet = spread.getSheet(activeSheetIndex);
let pivotTable = newSheet.pivotTables.add(getUniquePivotName(newSheet), pivotRange, 2, 0, GC.Spread.Pivot.PivotTableLayoutType.outline, GC.Spread.Pivot.PivotTableThemes.medium2);
pivotTable.add(args.rowFieldName, args.rowFieldName, GC.Spread.Pivot.PivotTableFieldType.rowField);
if(args.columnFieldName){
pivotTable.add(args.columnFieldName, args.columnFieldName, GC.Spread.Pivot.PivotTableFieldType.columnField);
}
pivotTable.add(args.dataFieldName, "求和项:" + args.dataFieldName, GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum);
spread.resumePaint();
}
}
catch(err){
console.log(err)
}
finally{
}
微信搜一搜【葡萄城社区】关注,了解更多动态
DeepSeek + 在线Excel , 打造智能表格新纪元的更多相关文章
- 手把手带你实现基于 Vite+Vue3 的在线Excel表格系统
今天,葡萄带你了解如何基于Vite+Vue3实现一套纯前端在线表格系统. 在正式开始项目介绍之前,首先咱们首先来介绍一下Vite和Vue3. Vue3 2020年09月18日Vue.js 3.0发布, ...
- LuckySheet一款在线Excel使用心得
1.LuckySheet简介 Luckysheet ,是一款国产的纯JS实现的类似excel的在线表格,功能强大.配置简单.完全开源. 开源地址 https://gitee.com/mengshuke ...
- 基于Vite+React构建在线Excel
Vite是随着Vue3一起发布的一款新型前端构建工具,能够显著的提升前端开发体验,它主要由两部分组成: (1)一个开发服务器,它基于**原生ES模块提供了丰富的内建功能,如速度快到惊人的 模块热更新( ...
- jQuery打造智能提示插件二(可编辑下拉框)
在上一篇 jQuery打造智能提示插件 上改进,增加下拉按钮,修复点击下拉区域外不隐藏BUG 效果 下拉按钮素材: js封装,注意红色部分为BUG修复,然后传入boxwidth不带px: /* /// ...
- [excel玩转表格教程][1G][AVI]
[excel玩转表格教程][1G][AVI] 下载地址 :http://www.fu83.cn/thread-222-1-1.html
- excel技巧--复制带excel侧边的表格
假设要复制出带excel侧边的表格内容,则使用以下步骤: 1.选择要复制的表格: 2.选择“页面布局”->“标题”选项的“打印”打勾: 3.选择“开始”->复制旁的三角选项:复制为图片: ...
- Asp.net C# 遍历Excel中的表格名称
Asp.net C# 遍历Excel中的表格名称 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + " ...
- TestLink在线Excel用例转换xml
[原文链接]:https://blog.tecchen.tech ,博文同步发布到博客园. 由于精力有限,对文章的更新可能不能及时同步,请点击上面的原文链接访问最新内容. 欢迎访问我的个人网站:htt ...
- 想实现多人协作的“在线Excel”?真没那么简单
本文由葡萄城技术团队原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. Excel是我们办公中常用的工具 ,它几乎能为我们处理大部分数据,友好的交互 ...
- 电缆公司如何面对企业改革?MES系统打造智能工厂
项目背景 目前,“互联网+电缆”正在成为电缆行业发展的主流,作为中国领先的大型电缆企业江苏亨通电力电缆有限公司(简称“亨通电缆”)积极响应国家提出的“中国制造2025”号召,实施MES工程项目,启用智 ...
随机推荐
- 2024御网杯信息安全大赛个人赛wp_2024-11-27
MISC题解 题目附件以及工具链接: 通过网盘分享的文件:御网杯附件 链接: https://pan.baidu.com/s/1LNA6Xz6eZodSV0Io9jGSZg 提取码: jay1 --来 ...
- @EnableAutoConfiguration 标签使用
@EnableAutoConfiguration 这个注解的作用是: 从classpath中搜索所有META-INF/spring.factories配置文件然后,将其中org.springframe ...
- node-sass安装问题
前情 最近在开发一个小程序项目,为了开发速度,部分页面使用原有H5,但原有H5需要对小程序做一定兼容适配,发现原有H5项目是个很古老项目. 坑位 在项目启动前,需要执行npm install安装项目依 ...
- openEuler欧拉安装指定版本的nodejs
1. 安装nodejs dnf -y install nodejs npm config set registry https://registry.npmmirror.com -g npm conf ...
- 【报错解决】【Linux】Name or service not known
# 配置文件位置 /etc/sysconfig/network-scripts/ # nano ifcfg-eth0查看网卡配置,确认dns已配置,且网关已配置 在虚拟机中添加临时路由网关(要与物理主 ...
- Springboot上传文件大小限制处理
今天在开发过程中遇到一个文件上传的问题 io.undertow.server.RequestTooBigException: UT000020: Connection terminated as re ...
- arch linux deepin-wine-wechat
https://aur.archlinux.org/packages/deepin-wine-wechat md5sum for WeChatSetup-3.9.0.28.exe should be ...
- TB交易开拓者_趋势跟踪策略_多品种对冲_递进优化回测_A0001188020期货量化策略
如果您需要代写技术指标公式, 请联系我. 龙哥QQ:591438821 龙哥微信:Long622889 也可以把您的通达信,文华技术指标改成TB交易开拓者的自动交易量化策略. 众所周知,投资界有基本面 ...
- Qt音视频开发35-左右通道音量计算和音量不同范围值的转换
一.前言 视频文件一般会有两个声音通道及左右声道,值有时候一样有时候不一样,很多场景下我们需要对其分开计算不同的音量值,在QAudioFormat中可以获取具体有几个通道,如果是一个通道,则左右通道值 ...
- 学习破解一个Android程序
首先编写一个android测试程序 功能:校验用户名和注册码,成功则弹出注册成功提示 以下仅给出关键部分的代码 res/layout/activity_main.xml <?xml versio ...