99国产精品欲av蜜臀,可以直接免费观看的AV网站,gogogo高清免费完整版,啊灬啊灬啊灬免费毛片

網易首頁 > 網易號 > 正文 申請入駐

Deepseek嵌入Excel,幫你自動做表格,感覺我要失業了

0
分享至

之前跟大家分享了, 如何將Deepseek嵌入Word,有粉絲就問道如何將Deepseek嵌入到Excel呢?這不,今天方法就來了,跟嵌入Word的使用方法類似



一、使用方法

先來簡單地說下使用的方法,操作非常的簡單,跟嵌入Word類似

首先我們需要先選中對應的數據區域,然后在上方點擊Deepseek,最后會跳出窗口,在窗口中提出問題,等待一段時間后就能得到對應的結果了,下面來看下如何構建這個效果



二、代碼準備

首先需要復制下方的代碼,關鍵點是需要修改API為自己的API,如何獲取API的話,大家可以翻下之前的文章,是需要在Deepseek的官網獲取的。

api_key = "你的api"

在這里將你的api直接替換為deepseek的api秘鑰即可

Function CallDeepSeekAPI(api_key As String, inputText As String) As String
Dim API As String
Dim SendTxt As String
Dim Http As Object
Dim status_code As Integer
Dim response As String
API = "https://api.deepseek.com/chat/completions"
SendTxt = "{""model"": ""deepseek-chat"", ""messages"": [{""role"":""system"", ""content"":""You are a Excel assistant""}, {""role"":""user"", ""content"":""" & inputText & """}], ""stream"": false}"
Set Http = CreateObject("MSXML2.XMLHTTP")
With Http
.Open "POST", API, False
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Authorization", "Bearer " & api_key
.send SendTxt
status_code = .Status
response = .responseText
End With
If status_code = 200 Then
CallDeepSeekAPI = response
Else
CallDeepSeekAPI = "Error: " & status_code & " - " & response
End If
Set Http = Nothing
End Function
Sub DeepSeekExcel()
Dim api_key As String
Dim userQuestion As String
Dim selectedRange As Range
Dim cell As Range
Dim combinedInput As String
Dim response As String
Dim regex As Object
Dim matches As Object
api_key = "你的api"
If api_key = "" Then
MsgBox "請先設置API密鑰", vbExclamation
Exit Sub
End If
On Error Resume Next
Set selectedRange = Selection
On Error GoTo 0
If selectedRange Is Nothing Then
MsgBox "請先選擇要處理的數據區域", vbExclamation
Exit Sub
End If
userQuestion = InputBox("請輸入您的問題(選中的單元格內容將作為處理數據):", "DeepSeek 提問")
If userQuestion = "" Then Exit Sub
Set regex = CreateObject("VBScript.RegExp")
regex.Pattern = """content"":""(.*?)"""
regex.Global = False
regex.MultiLine = True
Application.ScreenUpdating = False
For Each cell In selectedRange
If Trim(cell.Value) <> "" Then
' 組合問題和單元格內容
combinedInput = userQuestion & vbCrLf & vbCrLf & "數據內容:" & vbCrLf & cell.Value
' 轉義特殊字符
combinedInput = Replace(combinedInput, "\", "\\")
combinedInput = Replace(combinedInput, """", "\""")
combinedInput = Replace(combinedInput, vbCrLf, "\n")
combinedInput = Replace(combinedInput, vbCr, "\n")
combinedInput = Replace(combinedInput, vbLf, "\n")
' 調用API
response = CallDeepSeekAPI(api_key, combinedInput)
If Left(response, 5) <> "Error" Then
Set matches = regex.Execute(response)
If matches.Count > 0 Then
Dim outputText As String
outputText = matches(0).SubMatches(0)
' 處理轉義字符
outputText = Replace(outputText, "\""", """")
outputText = Replace(outputText, "\\", "\")
outputText = Replace(outputText, "\n", vbCrLf)
' 寫入右側相鄰單元格
cell.Offset(0, 1).Value = outputText
Else
cell.Offset(0, 1).Value = "解析失敗"
End If
Else
cell.Offset(0, 1).Value = "API錯誤"
End If
End If
Next cell
Application.ScreenUpdating = True
MsgBox "處理完成!", vbInformation
Set regex = Nothing
Set selectedRange = Nothing
End Sub

Function CallDeepSeekAPI(api_key As String, inputText As String) As String Dim API As String Dim SendTxt As String Dim Http As Object Dim status_code As Integer Dim response As String API = "https://api.deepseek.com/chat/completions" SendTxt = "{""model"": ""deepseek-chat"", ""messages"": [{""role"":""system"", ""content"":""You are a Excel assistant""}, {""role"":""user"", ""content"":""" & inputText & """}], ""stream"": false}" Set Http = CreateObject("MSXML2.XMLHTTP") With Http .Open "POST", API, False .setRequestHeader "Content-Type", "application/json" .setRequestHeader "Authorization", "Bearer " & api_key .send SendTxt status_code = .Status response = .responseText End With If status_code = 200 Then CallDeepSeekAPI = response Else CallDeepSeekAPI = "Error: " & status_code & " - " & response End If Set Http = NothingEnd FunctionSub DeepSeekExcel() Dim api_key As String Dim userQuestion As String Dim selectedRange As Range Dim cell As Range Dim combinedInput As String Dim response As String Dim regex As Object Dim matches As Object api_key = "你的api" If api_key = "" Then MsgBox "請先設置API密鑰", vbExclamation Exit Sub End If On Error Resume Next Set selectedRange = Selection On Error GoTo 0 If selectedRange Is Nothing Then MsgBox "請先選擇要處理的數據區域", vbExclamation Exit Sub End If userQuestion = InputBox("請輸入您的問題(選中的單元格內容將作為處理數據):", "DeepSeek 提問") If userQuestion = "" Then Exit Sub Set regex = CreateObject("VBScript.RegExp") regex.Pattern = """content"":""(.*?)""" regex.Global = False regex.MultiLine = True Application.ScreenUpdating = False For Each cell In selectedRange If Trim(cell.Value) <> "" Then ' 組合問題和單元格內容 combinedInput = userQuestion & vbCrLf & vbCrLf & "數據內容:" & vbCrLf & cell.Value ' 轉義特殊字符 combinedInput = Replace(combinedInput, "\", "\\") combinedInput = Replace(combinedInput, """", "\""") combinedInput = Replace(combinedInput, vbCrLf, "\n") combinedInput = Replace(combinedInput, vbCr, "\n") combinedInput = Replace(combinedInput, vbLf, "\n") ' 調用API response = CallDeepSeekAPI(api_key, combinedInput) If Left(response, 5) <> "Error" Then Set matches = regex.Execute(response) If matches.Count > 0 Then Dim outputText As String outputText = matches(0).SubMatches(0) ' 處理轉義字符 outputText = Replace(outputText, "\""", """") outputText = Replace(outputText, "\\", "\") outputText = Replace(outputText, "\n", vbCrLf) ' 寫入右側相鄰單元格 cell.Offset(0, 1).Value = outputText Else cell.Offset(0, 1).Value = "解析失敗" End If Else cell.Offset(0, 1).Value = "API錯誤" End If End If Next cell Application.ScreenUpdating = True MsgBox "處理完成!", vbInformation Set regex = Nothing Set selectedRange = NothingEnd Sub

三、代碼粘貼

在Excel中點擊【開發工具】然后點擊【Visiual Basic】進入編輯窗口,在右側空白區域點擊鼠標右鍵找到插入,找到【模塊】,然后在右側的窗口那里直接粘貼即可

在這里一定記得,API替換為自己的API



四、制作按鈕

需要在右側點擊文件,然后最下放找到【選項】來調出Excel選項,在Excel選項中找到【自定義功能區】

我們需要在左側將類別設置【宏】選中【DEEPSeekExcel】這個宏,然后在右側的窗口中點擊對應的選項卡,最后點擊添加,即可將宏作為按鈕添加到Excel表格中,至此就設置完畢了



五、加載宏

如果想要將這個宏按鈕永久的保留在Excel中是需要使用加載宏的,之前發過,大家可以搜一下

DeepSeek搭配Excel,制作自定義按鈕,實現辦公自動化!

視頻Excel從零到一

特別聲明:以上內容(如有圖片或視頻亦包括在內)為自媒體平臺“網易號”用戶上傳并發布,本平臺僅提供信息存儲服務。

Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.

相關推薦
熱點推薦
逆行撞車起火后續!19歲司機扒窗慘叫,貨車師傅背鍋,輿論一邊倒

逆行撞車起火后續!19歲司機扒窗慘叫,貨車師傅背鍋,輿論一邊倒

界史
2025-04-21 15:18:33
特朗普用關稅,利誘全球圍毆中國,這4國可能倒戈,不能盲目樂觀

特朗普用關稅,利誘全球圍毆中國,這4國可能倒戈,不能盲目樂觀

獵火照狼山
2025-04-21 21:17:46
有趣!之前裝死,季后賽爆發,4戰轟43分50板,京蜜:真的沒想到

有趣!之前裝死,季后賽爆發,4戰轟43分50板,京蜜:真的沒想到

南海浪花
2025-04-22 09:11:25
NBA選秀順序確定:湖勇皆無首輪,太陽首輪確定第九歸火箭

NBA選秀順序確定:湖勇皆無首輪,太陽首輪確定第九歸火箭

懂球帝
2025-04-22 08:57:11
打了22分鐘,0+0+0+0+0!歷史首人!湖人血崩!被以下克上!

打了22分鐘,0+0+0+0+0!歷史首人!湖人血崩!被以下克上!

籃球技巧教學
2025-04-21 11:30:02
住建部一錘定音:樓齡滿24年以上老房子,業主或將發財!

住建部一錘定音:樓齡滿24年以上老房子,業主或將發財!

巢客HOME
2025-04-21 00:37:01
外賣平臺“三國殺”開新局:有騎手轉跑京東稱單價稍高,有商家仍在觀望比較服務質量

外賣平臺“三國殺”開新局:有騎手轉跑京東稱單價稍高,有商家仍在觀望比較服務質量

紅星新聞
2025-04-21 23:35:29
孫道林和王文娟的女兒孫慶原給父母掃墓時的留影

孫道林和王文娟的女兒孫慶原給父母掃墓時的留影

娛你同歡
2025-04-16 20:39:49
專機為啥不選國產C919而選波音747?3大真相讓鍵盤俠破防!

專機為啥不選國產C919而選波音747?3大真相讓鍵盤俠破防!

林子說事
2025-04-20 06:44:35
尷尬!劉國梁想推新人,世乒內部選拔賽:30歲林高遠獲第一

尷尬!劉國梁想推新人,世乒內部選拔賽:30歲林高遠獲第一

三哥搞笑侃球
2025-04-22 03:01:26
4月22日晚晚體育頻道CCTV5、CCTV5+直播表

4月22日晚晚體育頻道CCTV5、CCTV5+直播表

煙潯渺渺
2025-04-22 07:04:20
季后賽打15分鐘被棄用!就這還想取代克萊?巴特勒:看他運球就煩

季后賽打15分鐘被棄用!就這還想取代克萊?巴特勒:看他運球就煩

你的籃球頻道
2025-04-22 08:52:10
大爺辱罵鄰座農民工,事后被抓自曝身份,《北京日報》發聲說得對

大爺辱罵鄰座農民工,事后被抓自曝身份,《北京日報》發聲說得對

辣條小劇場
2025-04-21 02:22:57
俄羅斯專家:中國綜合國力現在太強大了,美國早已錯失良機

俄羅斯專家:中國綜合國力現在太強大了,美國早已錯失良機

健身狂人
2025-04-20 00:16:58
抨擊特朗普屢次施壓,捍衛美聯儲獨立權威,美多名官員力挺美聯儲主席鮑威爾

抨擊特朗普屢次施壓,捍衛美聯儲獨立權威,美多名官員力挺美聯儲主席鮑威爾

環球網資訊
2025-04-22 06:40:13
訂單激增,大量美國客戶向越南工廠施壓,要求在90天內迅速發貨

訂單激增,大量美國客戶向越南工廠施壓,要求在90天內迅速發貨

叮當當科技
2025-04-22 05:35:59
44歲黃宗澤近照曝光!眉毛稀疏、朝天鼻,一股老人味,痞帥感全無

44歲黃宗澤近照曝光!眉毛稀疏、朝天鼻,一股老人味,痞帥感全無

檸檬有娛樂
2025-04-21 09:01:56
4月22日晚間中央五套轉播表-CCTV5,CCTV5+節目單

4月22日晚間中央五套轉播表-CCTV5,CCTV5+節目單

郭錉包工頭
2025-04-22 01:01:37
后續來了!高鐵攔門事件通報細節,女子身份被扒,處罰結果引爭議

后續來了!高鐵攔門事件通報細節,女子身份被扒,處罰結果引爭議

追風小狗
2025-04-21 22:24:05
迪巴拉:梅西和馬拉多納永遠獨一無二,亞馬爾這種高水平球員永遠都有

迪巴拉:梅西和馬拉多納永遠獨一無二,亞馬爾這種高水平球員永遠都有

雷速體育
2025-04-21 23:53:11
2025-04-22 10:35:00
Excel從零到一 incentive-icons
Excel從零到一
0基礎,0成本學習Excel
560文章數 87081關注度
往期回顧 全部

科技要聞

寒武紀一季營收頂一年,能否"平替"英偉達

頭條要聞

牛彈琴:教皇突然去世 很多人問萬斯"你干什么了"

頭條要聞

牛彈琴:教皇突然去世 很多人問萬斯"你干什么了"

體育要聞

不愛踢球的巴西人,成了乒乓球世界冠軍

娛樂要聞

網曝鹿晗關曉彤分手細節 或與結婚有關

財經要聞

沐邦高科危險信號:多筆交易存蹊蹺

汽車要聞

與眾06 新的命名方式意味著新的產品序列即將到來

態度原創

旅游
教育
家居
藝術
時尚

旅游要聞

熱聞|清明假期將至,熱門目的地有哪些?

教育要聞

小學家長群里熱鬧非凡,老師出了這道題,瞬間就變安靜了

家居要聞

黑白紋理 簡約低調空間

藝術要聞

故宮珍藏的墨跡《十七帖》,比拓本更精良,這才是地道的魏晉寫法

沒有不適合穿襯衫的人!只是沒有遇到它

無障礙瀏覽 進入關懷版 主站蜘蛛池模板: 资源县| 淳化县| 贵港市| 鹿邑县| 高碑店市| 原平市| 孝昌县| 北京市| 城市| 莱芜市| 上蔡县| 广州市| 三台县| 盘山县| 涡阳县| 广安市| 安塞县| 罗平县| 赣榆县| 右玉县| 铁岭县| 延边| 康平县| 江山市| 宜春市| 通城县| 紫金县| 利辛县| 香港| 盐城市| 兴隆县| 霸州市| 扎囊县| 松潘县| 长汀县| 奉化市| 靖江市| 子长县| 海宁市| 嘉黎县| 察隅县|