337p人体粉嫩胞高清图片,97人妻精品一区二区三区在线 ,日本少妇自慰免费完整版,99精品国产福久久久久久,久久精品国产亚洲av热一区,国产aaaaaa一级毛片,国产99久久九九精品无码,久久精品国产亚洲AV成人公司
網易首頁 > 網易號 > 正文 申請入駐

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.

相關推薦
熱點推薦
瑞幸官宣羅永浩!超大杯廣告笑不活了,網友:只有她能拿捏老羅!

瑞幸官宣羅永浩!超大杯廣告笑不活了,網友:只有她能拿捏老羅!

LOGO研究所
2026-03-23 12:18:30
日媒通知全球:如果中日開戰,中國人會搶著當先鋒,引發高度關注

日媒通知全球:如果中日開戰,中國人會搶著當先鋒,引發高度關注

花寒弦絮
2026-03-23 00:31:50
終于有人管管美國了!美國遇到大麻煩,美國:中美兩國需要攜手

終于有人管管美國了!美國遇到大麻煩,美國:中美兩國需要攜手

福建平子
2026-01-28 10:52:25
中印西山口白刃戰:印度彎刀對上我軍三棱刺,126名印軍無一生還

中印西山口白刃戰:印度彎刀對上我軍三棱刺,126名印軍無一生還

棠棣分享
2026-03-22 00:12:09
房子是上個月掛牌的,心是這個月涼透的!150萬買的,現就這價?

房子是上個月掛牌的,心是這個月涼透的!150萬買的,現就這價?

楠楠自語
2026-03-17 18:29:11
偶遇沈月拍戲,個子不高的情況下胸大真的太吃虧了!

偶遇沈月拍戲,個子不高的情況下胸大真的太吃虧了!

TVB的四小花
2026-03-24 12:22:03
一年暴賺8000億,利潤超蘋果500億,市值突破30萬億,憑什么?

一年暴賺8000億,利潤超蘋果500億,市值突破30萬億,憑什么?

簡易科技
2026-03-18 19:41:51
今日突發!日本自衛隊士兵闖入中國大使館,意圖刺殺中國大使!

今日突發!日本自衛隊士兵闖入中國大使館,意圖刺殺中國大使!

制造科技
2026-03-25 01:49:20
巴薩危機?2億歐亞馬爾被換后發飆 4次怒指弗里克:總針對我 瘋了

巴薩危機?2億歐亞馬爾被換后發飆 4次怒指弗里克:總針對我 瘋了

風過鄉
2026-03-24 07:57:07
高市拿到12年稀土大單就飄了,叫囂反制無效,不料麻煩才開始

高市拿到12年稀土大單就飄了,叫囂反制無效,不料麻煩才開始

瘋狂小菠蘿
2026-03-24 15:55:54
湖南一位28歲女教師徐某,親手把一手好牌打得稀爛

湖南一位28歲女教師徐某,親手把一手好牌打得稀爛

叮當當科技
2026-03-24 15:46:58
千億巨頭尾盤漲停,年內股價翻倍,機構看好算力基建板塊(附股)

千億巨頭尾盤漲停,年內股價翻倍,機構看好算力基建板塊(附股)

21世紀經濟報道
2026-03-24 18:07:29
一圖看懂|為何美軍害怕伊朗布設水雷?

一圖看懂|為何美軍害怕伊朗布設水雷?

澎湃新聞
2026-03-14 07:32:27
伊朗公布美軍基地遭襲前后對比照片

伊朗公布美軍基地遭襲前后對比照片

新京報
2026-03-24 07:23:01
臺海局勢突變!統一大勢已無人可擋

臺海局勢突變!統一大勢已無人可擋

Ck的蜜糖
2026-03-25 01:59:17
送檢4個LV包均為假!消費者:都是在專柜買的,LV專柜回應

送檢4個LV包均為假!消費者:都是在專柜買的,LV專柜回應

福建第一幫幫團
2026-03-24 19:32:34
陳曉和毛曉彤領證了!?

陳曉和毛曉彤領證了!?

八卦瘋叔
2026-03-22 09:40:10
奉陪到底,中方拒邀日本高管參會,日方深感不安,鈍刀子割肉更疼

奉陪到底,中方拒邀日本高管參會,日方深感不安,鈍刀子割肉更疼

鐵錘簡科
2026-03-25 01:00:52
3.5 億歐!砸破足壇天花板,巴薩天才要成巴黎新王?

3.5 億歐!砸破足壇天花板,巴薩天才要成巴黎新王?

瀾歸序
2026-03-24 03:14:27
“2000萬才敢買20萬的車?”網約車司機遇億萬富翁,對話點醒數人

“2000萬才敢買20萬的車?”網約車司機遇億萬富翁,對話點醒數人

一絲不茍的法律人
2026-03-19 15:24:46
2026-03-25 03:11:00
Excel從零到一 incentive-icons
Excel從零到一
0基礎,0成本學習Excel
580文章數 87201關注度
往期回顧 全部

科技要聞

年僅41歲,教育名師張雪峰猝然離世

頭條要聞

張雪峰去世 猝死前身體的3個求救信號別忽視

頭條要聞

張雪峰去世 猝死前身體的3個求救信號別忽視

體育要聞

NBA最強左手射手,是個右撇子

娛樂要聞

張雪峰經搶救無效不幸去世 年僅41歲

財經要聞

特朗普再TACO 可以押注伊朗局勢降級?

汽車要聞

尚界Z7雙車預售22.98萬起 問界M6預售26.98萬起

態度原創

手機
藝術
教育
房產
親子

手機要聞

iQOO Z11手機官宣搭載天璣8500滿血版+最新Monster超核引擎

藝術要聞

300米!非洲最高全鋼混住宅,中國建造又破紀錄!

教育要聞

西湖大學,簽約南洋理工大學

房產要聞

北上廣深二手房集體回暖!三月小陽春行情全面兌現

親子要聞

拍完這條,老母親學會了好多西語單詞

無障礙瀏覽 進入關懷版