查找、修复、验证:Aspose.Cells Cloud 搜索、替换和断链 API 完全指南 (.NET / Python / Java / cURL)
“我们的 400 本预算工作簿中,哪一本仍然显示 Old Vendor Ltd?” “在此模板中替换所有
{{COMPANY}}占位符。” “我们的报告中是否还有链接指向我们去年已停用的域名?” — 三个截然不同的问题,共享同一个答案: 一个在云端读取并重写电子表格的 REST 调用,无需在任何地方安装 Excel。
电子表格 内容 问题几乎出现在每个数据密集型代码库中:
- Content audit — 查找每个单元格、形状或超链接,查看其中是否提及已弃用的产品名称、旧的办公地址或过时的法律实体;
- Template rendering — 在将工作簿发送给客户之前,填充跨工作表的
{{PLACEHOLDER}}令牌; - Link rot — 检查工作簿中嵌入的 URL 是否仍然可解析,在合规或归档工作批准之前;
- Bulk correction — 修复跨数十个工作表的拼写错误或列值错误,或仅针对单个工作表的某一区域进行修正;
传统选项——在您自己的机器上运行的脚本库、Excel 宏或 Windows 服务器上的 COM 组件——都意味着您是唯一负责托管和扩展电子表格逻辑的人。Aspose.Cells Cloud 将其转化为普通的 REST:发送文件(或仅文件名),获取匹配项——或纠正后的文件——返回。
本文介绍了 Aspose.Cells Cloud 微服务中核心 SearchController 所公开的 API(源代码:src/Aspose.Cells.Cloud.MicroService/Controllers/SearchController.cs),并提供了 cURL 和 C# (.NET) 的可运行示例,以及针对 Python 和 Java 用户的说明。
1. SearchController 能做什么?
SearchController 覆盖 三个功能族,每个在多个 范围 中可用:
| Family | What it does | Mutates the workbook? |
|---|---|---|
| Search | 返回匹配查询的文本项 — 包含它们的工作表以及单元格/形状/超链接位置 | 否 |
| Replace | 替换匹配的文本,然后将更正后的文件流回或保存到云存储 | 是 |
| Broken links | 验证工作簿中每个 http(s) 超链接,并返回那些解析失败的链接 |
否 |
而每个族在 四个作用域 中公开,这正是端点列表变长的地方:
| 范围 | 搜索 | 替换 | 损坏的链接 |
|---|---|---|---|
| 本地文件 → 在线处理(在请求体中上传) | PUT /v4.0/cells/search/content |
PUT /v4.0/cells/replace/content |
PUT /v4.0/cells/search/broken-links |
| 云存储中的整个工作簿 | PUT /v4.0/cells/{name}/search/content |
PUT /v4.0/cells/{name}/replace/content |
PUT /v4.0/cells/{name}/search/broken-links |
| 云存储中的单个工作表 | PUT /v4.0/cells/{name}/worksheets/{worksheet}/search/content |
PUT /v4.0/cells/{name}/worksheets/{worksheet}/replace/content |
PUT /v4.0/cells/{name}/worksheets/{worksheet}/search/broken-links |
| 云存储中的单个范围 | PUT /v4.0/cells/{name}/worksheets/{worksheet}/ranges/{cellArea}/search/content |
PUT /v4.0/cells/{name}/worksheets/{worksheet}/ranges/{cellArea}/replace/content |
PUT /v4.0/cells/{name}/worksheets/{worksheet}/ranges/{cellArea}/search/broken-links |
另外还有两个额外的端点,可导出工作簿中的每个文本项——参见§4:
| 目标 | 端点 |
|---|---|
| 云文件中的所有文本项 | PUT /v4.0/cells/{name}/search/content/all-textitems |
| 本地上传中的所有文本项 | PUT /v4.0/cells/search/content/all-textitems |
实现说明:路由前缀为
v{version:apiVersion}/cells,且此控制器使用[ApiVersion("4.0")],因此实际调用的形式为https://api.aspose.cloud/v4.0/cells/...。此控制器中的所有操作均为PUT—— 即使是只读搜索,也是如此,因为搜索被建模为 对资源提交的操作,而不是可缓存的GET。
两种操作模式以及它们为何重要
控制器装饰每个操作,装饰器会准确告诉您文件来自何处:
[OnlineOperation]— 无状态。您在请求体(multipart)中上传工作簿,服务器在内存中处理,且不会持久化到云存储。非常适合“只想知道文件内容”以及一次性模板化的场景。[CloudFileOperation]— 基于存储。服务器从云存储中获取{name}(可选地在folder=下),完成处理后——对于替换操作——直接将结果写回。不会有任何数据传输到您的机器。
唯一的区别,加上 {worksheet} / {cellArea} 路由段,就是整个思维模型。本文的其余部分仅是细节。
2. 实际上您将解析的响应模型
两个搜索系列返回一个小型、扁平、易于绑定的形状。Search 返回 SearchResponse:
{
"Code": 200,
"Status": "OK",
"TextItems": [
{
"Filename": "Book1.xlsx",
"Worksheet": "Q3 Forecast",
"Position": "Cell:B7",
"Content": "Old Vendor Ltd"
},
{
"Filename": "Book1.xlsx",
"Worksheet": "Q3 Forecast",
"Position": "Shape:TextBox 3",
"Content": "Prepared by Old Vendor Ltd"
}
]
}
断链搜索返回 BrokenLinksResponse:
{
"Code": 200,
"Status": "OK",
"BrokenLinks": [
{
"Filename": "Book1.xlsx",
"Worksheet": "Links",
"Position": "Hyperlink:Sheet1!B4",
"LinkAddress": "https://retired-domain.example.com/report"
}
]
}
有两件事值得立即指出:
-
Position是带标签的位置,而不仅仅是单元格地址。它的前缀为Cell:、Hyperlink:或Shape:,这就是单个平面列表能够告诉你 匹配的是什么类型 的方式。该标签是 “修复单元格 B7” 与 “修复位于 B7 上方的文本框” 之间的区别。 -
两个模型都是自描述的,便于报告 —
Filename和Worksheet在每个项目中都会返回,因此对多个工作簿的扫描可以直接合并为一张审计表,而无需后期处理。
3. 开始之前需要的两件事
- 在 Aspose Cloud Dashboard 注册免费账户,并创建一个应用程序以获取
Client ID和Client Secret(SDK 会自动将它们交换为 JWT——无需自行构建身份验证头)。 - 为您选择的语言安装 SDK:
<!-- .NET -->
<PackageReference Include="Aspose.Cells-Cloud" Version="25.x" />
# Python
pip install asposecellscloud
<!-- Java (Maven) — note: NOT on Maven Central, so the Aspose repo below is required -->
<repositories>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.cloud/repo/</url>
</repository>
</repositories>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cells-cloud</artifactId>
<version>26.8</version>
</dependency>
不需要 SDK 吗?一切都是普通的 REST,所以 cURL 同样适用(见下文)。search/replace/broken-link 系列也可以通过类型化的 SDK 请求模型访问——
SearchSpreadsheetContentRequest、ReplaceContentInRemoteRangeRequest、以及其他——这正是下面的 C# 代码片段使用的方式。
4. 场景 A:在线搜索本地文件(不持久化)
这是 PUT /v4.0/cells/search/content — 上传工作簿,获取匹配项。 没有云存储,无需清理,未留下任何副本。
① cURL
# 1) First, get a token
curl -X POST "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET"
# 2) Find "Old Vendor Ltd" anywhere in a local workbook
curl -X PUT "https://api.aspose.cloud/v4.0/cells/search/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd" \
--data-urlencode "ignoringCase=true" \
-F "file=@Book1.xlsx"
将其限制在单个工作表,或单个工作表的某个区域,可使用另外两个查询参数:
# Only "Q3 Forecast", only the range A1:F40
curl -X PUT "https://api.aspose.cloud/v4.0/cells/search/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd" \
--data-urlencode "worksheet=Q3 Forecast" \
--data-urlencode "cellArea=A1:F40" \
-F "file=@Book1.xlsx"
② C# / .NET
using Aspose.Cells.Cloud.SDK.Api;
using Aspose.Cells.Cloud.SDK.Request;
var cellsApi = new CellsApi("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
// Local file, whole workbook
var request = new SearchSpreadsheetContentRequest(
spreadsheet: "C:/audit/Book1.xlsx", // local file path
searchText: "Old Vendor Ltd",
ignoringCase: true);
SearchResponse response = cellsApi.SearchSpreadsheetContent(request);
foreach (var item in response.TextItems)
{
Console.WriteLine($"{item.Worksheet} | {item.Position} | {item.Content}");
}
// Same call, scoped to one sheet and one range
var scoped = new SearchSpreadsheetContentRequest(
spreadsheet: "C:/audit/Book1.xlsx",
searchText: "Old Vendor Ltd",
ignoringCase: true,
sheetname: "Q3 Forecast",
cellarea: "A1:F40");
请求模型同样公开了
password(打开受保护的工作簿)和regoin(地区/语言设置)——这些可选参数在云存储变体中显示为storageName。请注意,.NET SDK 保持regoin的拼写;Python SDK 将这两个设置称为password和region。
③ Python / Java
Python SDK 包装了相同的端点系列,请求模型字段与 C# 中的字段一一对应,但采用 snake_case 命名方式:
from asposecellscloud.apis.cells_api import CellsApi
from asposecellscloud.requests import (
SearchSpreadsheetContentRequest,
SearchContentInRemoteRangeRequest,
)
instance = CellsApi("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
# Local upload — returned items carry Worksheet / Position / Content
local = instance.search_spreadsheet_content(
SearchSpreadsheetContentRequest(
"Book1.xlsx", "Old Vendor Ltd",
ignoring_case=True, worksheet="Q3 Forecast", cell_area="A1:F40"))
# Range-scoped search of a file already in cloud storage
remote = instance.search_content_in_remote_range(
SearchContentInRemoteRangeRequest(
"Book1.xlsx", "Q3 Forecast", "A1:F40", "Old Vendor Ltd",
ignoring_case=True, folder="Reports"))
for item in remote.text_items:
print(item.worksheet, item.position, item.content)
Java SDK 遵循相同的模式,使用通过 setter 构建的 Request 对象:
import com.aspose.cloud.cells.api.CellsApi;
import com.aspose.cloud.cells.model.SearchResponse;
import com.aspose.cloud.cells.request.SearchContentInRemoteRangeRequest;
public class SearchDemo {
public static void main(String[] args) throws Exception {
CellsApi api = new CellsApi("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
SearchContentInRemoteRangeRequest req = new SearchContentInRemoteRangeRequest();
req.setName("Book1.xlsx");
req.setWorksheet("Q3 Forecast");
req.setCellArea("A1:F40");
req.setSearchText("Old Vendor Ltd");
req.setIgnoringCase(true);
req.setFolder("Reports");
SearchResponse response = api.searchContentInRemoteRange(req);
response.getTextItems().forEach(i ->
System.out.println(i.getWorksheet() + " | " + i.getPosition() + " | " + i.getContent()));
}
}
如果您使用原始 REST,上面的 cURL 就是完整的契约——multipart 字段只需携带文件名,因为服务会根据文件名推断工作簿的名称(从而确定其格式)。
5. 场景 B:搜索已存在于云存储中的文件
当工作簿已经位于 Aspose Cloud Storage 中时,完全跳过下载——服务会直接读取其所在位置:
# Whole workbook
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/search/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd" \
--data-urlencode "ignoringCase=true" \
--data-urlencode "folder=Reports"
# Just one worksheet
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/worksheets/Q3%20Forecast/search/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd"
# Just one range of one worksheet
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/worksheets/Q3%20Forecast/ranges/A1:F40/search/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd"
// Whole workbook in storage
var response = cellsApi.SearchContentInRemoteSpreadsheet(
new SearchContentInRemoteSpreadsheetRequest(
name: "Book1.xlsx",
searchText: "Old Vendor Ltd",
ignoringCase: true,
folder: "Reports"));
// One worksheet
var sheetHits = cellsApi.SearchContentInRemoteWorksheet(
new SearchContentInRemoteWorksheetRequest(
name: "Book1.xlsx",
sheetname: "Q3 Forecast",
searchText: "Old Vendor Ltd",
folder: "Reports"));
// One range
var rangeHits = cellsApi.SearchContentInRemoteRange(
new SearchContentInRemoteRangeRequest(
name: "Book1.xlsx",
sheetname: "Q3 Forecast",
cellArea: "A1:F40",
searchText: "Old Vendor Ltd",
ignoringCase: true,
folder: "Reports"));
为什么使用三个端点而不是一个? 因为路由携带了作用域。整个工作簿端点接受名称和查询;工作表端点接受工作表段;范围端点接受工作表 以及 范围段。它是一种简洁、可缓存的 REST 结构——并且这意味着 “缩小搜索范围” 的参数(
worksheet、cellArea)仅在本地文件端点上存在,在将调用从一个作用域迁移到另一个作用域时值得记住。
6. 场景 C:获取工作簿中的 每个 文本项
有时你没有搜索词——你想要获取全部内容。all-textitems 端点返回工作簿中的 每个 文本项,这样你就可以比较两个修订版,构建翻译词汇表,或提供给索引器:
# Cloud file — every text item
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/search/content/all-textitems" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "folder=Reports"
# Local upload — every text item
curl -X PUT "https://api.aspose.cloud/v4.0/cells/search/content/all-textitems" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@Book1.xlsx"
响应是相同的 SearchResponse 包装,Content 为文件中每个单元格字符串、超链接标题和形状文本填充。这是 “grep the whole workbook” 原语。
7. 场景 D: 替换 — 和两个截然不同的结果
Replace 是 API 分成两部分的地方,这种拆分是有意为之:
| 本地上传 → 下载已校正的文件 | 云文件 → 保存回存储 | |
|---|---|---|
| Endpoint | PUT /v4.0/cells/replace/content |
PUT /v4.0/cells/{name}/replace/content |
| Returns | 一个 文件流(与您上传的格式相同) | CellsCloudResponse { "Code": 200, "Status": "OK" } |
| Storage touched | 无 | 原始文件已 覆盖 |
① 在本地工作簿中替换,流式返回结果
curl -X PUT "https://api.aspose.cloud/v4.0/cells/replace/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText={{COMPANY}}" \
--data-urlencode "replaceText=Northwind Traders" \
-F "file=@template.xlsx" \
-o template-rendered.xlsx
using Aspose.Cells.Cloud.SDK.Request;
var request = new ReplaceSpreadsheetContentRequest(
spreadsheet: "C:/templates/template.xlsx",
searchText: "{{COMPANY}}",
replaceText: "Northwind Traders");
// Option A: get the corrected workbook as a Stream
using Stream corrected = cellsApi.ReplaceSpreadsheetContent(request);
using var outFile = File.Create("C:/templates/template-rendered.xlsx");
corrected.CopyTo(outFile);
// Option B: let the SDK write it for you (.NET overload with an output path)
// cellsApi.ReplaceSpreadsheetContent(request, "C:/templates/template-rendered.xlsx");
这里同样提供了两个范围参数 — sheetname 和 cellarea —,因此您可以在一个工作表中渲染占位符,而无需触及模板的其余部分。
② 在云工作簿中替换,并原位持久化
# Whole workbook, saved back to storage
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/replace/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd" \
--data-urlencode "replaceText=Northwind Traders" \
--data-urlencode "folder=Reports"
# One worksheet
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/worksheets/Q3%20Forecast/replace/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd" \
--data-urlencode "replaceText=Northwind Traders" \
--data-urlencode "folder=Reports"
# One range
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/worksheets/Q3%20Forecast/ranges/A1:F40/replace/content" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "searchText=Old Vendor Ltd" \
--data-urlencode "replaceText=Northwind Traders" \
--data-urlencode "folder=Reports"
// Whole workbook — result saved back into cloud storage
cellsApi.ReplaceContentInRemoteSpreadsheet(
new ReplaceContentInRemoteSpreadsheetRequest(
name: "Book1.xlsx",
searchText: "Old Vendor Ltd",
replaceText: "Northwind Traders",
folder: "Reports"));
// Range-scoped
cellsApi.ReplaceContentInRemoteRange(
new ReplaceContentInRemoteRangeRequest(
name: "Book1.xlsx",
searchText: "Old Vendor Ltd",
replaceText: "Northwind Traders",
worksheet: "Q3 Forecast",
cellarea: "A1:F40",
folder: "Reports"));
就地替换本质上是破坏性的。 云变体会覆盖
{name}—— 不会创建备份副本。对于审计密集的工作流,请保留一个带版本的副本(例如,先上传Book1-2026-09-11.xlsx,然后再替换),或使用本地上传变体并自行存储返回的流。
8. 场景 E:在别人之前发现损坏的链接
链接检查是这里的隐藏功能——它是那种自己编写起来很繁琐、跳过又令人尴尬的东西。所有四个范围都可用;本地文件变体是最快的健全性检查:
# Local workbook, whole file
curl -X PUT "https://api.aspose.cloud/v4.0/cells/search/broken-links" \
-H "Authorization: Bearer $TOKEN" \
-F "file=@Book1.xlsx"
# Cloud workbook, whole file
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/search/broken-links" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "folder=Reports"
# Cloud workbook, one worksheet
curl -X PUT "https://api.aspose.cloud/v4.0/cells/Book1.xlsx/worksheets/Links/search/broken-links" \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "folder=Reports"
var broken = cellsApi.SearchSpreadsheetBrokenLinks(
new SearchSpreadsheetBrokenLinksRequest(
spreadsheet: "C:/audit/Book1.xlsx"));
foreach (var link in broken.BrokenLinks)
{
Console.WriteLine($"{link.Worksheet} {link.Position} -> {link.LinkAddress}");
}
结果是一个可以直接操作的列表:每个条目都指明工作表、位置以及违规的 LinkAddress。
9. 实际扫描的内容是什么?(改变您期望的实现细节)
这是区分工作集成和意外集成的关键部分。阅读 WorkbookExtension.cs 时,搜索会遍历每个工作表中的 三种不同的元素类型:
| 元素类型 | 来源 | 匹配内容 | Position 标记 |
|---|---|---|---|
| 单元格字符串 | worksheet.Cells |
单元格的字符串值 | Cell:A1 |
| 超链接 | worksheet.Hyperlinks |
链接的 地址 以及 其 显示文本 | Hyperlink:Sheet1!B4 |
| 形状 | worksheet.Shapes |
shape.Text — 文本框、标注、标签 |
Shape:TextBox 3 |
以下是值得了解的行为,之前 您进行设计时:
仅搜索字符串单元格。 扫描过滤条件为 CellValueType.IsString。包含 数字、日期 或 布尔值 的单元格会被跳过 —— 因此搜索 2025 不会匹配序列值恰好为 2025 的日期格式单元格。公式计算结果为文本的单元格 会 被匹配,因为它们的值类型是字符串。
大小写敏感是唯一的匹配选项。 ignoringCase 在 InvariantCultureIgnoreCase 和 InvariantCulture 比较之间切换——仅此而已。尽管生成的 API 文档可能暗示了这些功能,但实际上没有完整单词、正则表达式或“匹配整个单元格值”模式。如果您需要这些语义,请获取 all-textitems 清单并在您这边进行过滤。
Replace 是普通的、区分大小写的、字面替换。 Search 的 ignoringCase 标志 在 Replace 上没有等价项 —— 替换路径根本没有不区分大小写的参数。并且这两条代码路径在内部有所不同:对整个工作表的替换会委托给引擎的 Worksheet.Replace(...),而范围限定的替换则遍历该范围,并使用 cell.StringValue.Replace(...) 重写每个字符串单元格。实际后果是:范围限定的替换仅作用于字符串单元格,并且是字面的,而非基于模式的。
超链接匹配报告地址,而不是标题。 当搜索匹配超链接的 显示文本 时,返回的 Content 仍然是 hyperlink.Address。如果您正在渲染一个 “在此找到” 报告,请预期 URL —— 标题不会被回显。
断链检查仅检查 http:// 和 https://。 mailto: 链接、本地文件路径以及内部 #Sheet1!A1 锚点会被完全跳过——它们从未被测试,因此也不会出现在结果中。它还会扫描附加在 形状 和单元格上的超链接,这正是死链接喜欢隐藏的地方。请注意,断链的 Position 是基于原始的 hyperlink.Area 构建的(而不是搜索端点使用的更友好的 Area.ToRangName()),因此不要假设这两个族在渲染位置时完全相同——如果需要稳定的键,请解析 Worksheet + LinkAddress 对。
“Broken” 意味着 “unreachable”,而不是 “wrong status code”。 检查会对每个链接发送 HTTP HEAD 请求,并将 任何 响应——包括 404 或 500——视为可访问;只有当请求 抛出(DNS 解析失败、连接被拒绝、TLS 错误、超时)时才将链接标记为断开。因此请将输出视为 “links that could not be contacted”。如果您实际需要的是 “links that don’t return 2xx”,则需要自行重新检查返回的 LinkAddress 值。
cellArea 被接受但未在 broken-link 端点上应用。 BrokenLinks 实现仅按工作表名称过滤;cell-area 参数已传入但从未使用。实际上,这意味着 .../ranges/A1:F40/search/broken-links 目前的行为与相同工作表的 /worksheet/search/broken-links 相同——链接在整张工作表上进行验证。请相应地限定你的 reports(或按位置过滤返回的列表),而不要假设范围会缩小检查范围。
这些都不是阻碍因素——它们是功能在演示中“works in the demo”与在生产环境中可预测行为之间的区别。
10. 错误处理与操作说明
控制器记录的合同
| 状态 | 含义 | 常见原因 |
|---|---|---|
| 400 | 错误请求 | 无效的 URL/参数 — 例如格式错误的 cellArea,或缺少 searchText |
| 401 | 未授权 | 身份验证失败或未提供有效凭据 |
| 404 | 未找到 | 源文件在云存储中不可访问 |
| 500 | 服务器错误 | 服务在获取电子表格数据时出现异常 |
在内部,每个操作都会将其工作包装在一个帮助程序(WorkbookElementOperation、UpdateWorkbookElementOperation、UpdateWorkbookElementOperationAndSave)中,该帮助程序捕获失败并将其重新抛出为 CellsApiException 前缀为操作名称 ——例如 SearchContentInRemoteRange Error Message: ...。该操作名称就是您在日志中看到的字符串:
| 操作名称 | 端点系列 |
|---|---|
SearchSpreadsheetContent, SearchContentInRemoteSpreadsheet |
本地/远程搜索 |
SearchContentInRemoteWorksheet, SearchContentInRemoteRange |
受限远程搜索 |
ReplaceSpreadsheetContent |
本地替换(流式结果) |
ReplaceContentInRemoteSpreadsheet, ReplaceContentInRemoteWorksheet, ReplaceContentInRemoteRange |
远程替换(保存结果) |
SearchSpreadsheetBrokenLinks, SearchBrokenLinksInRemoteSpreadsheet, SearchBrokenLinksInRemoteWorksheet, SearchBrokenLinksInRemoteRange |
链接验证 |
SDK 公开的可选参数
除了文档中列出的参数之外,云存储请求模型都包含相同的三个可选设置:
password— 打开受密码保护的工作簿(搜索不需要写入权限,因此只读受保护的文件也能正常工作);storageName— 将目标指向自定义/附加的云存储,而不是默认的(Python:storage_name);regoin— 解释工作簿时使用的区域/语言设置(Python 中写作region)。
身份验证
所有 SDK 都会自动使用 OAuth 2.0 client_credentials 和 JWT 进行身份验证;在使用原始 cURL 时,需先调用一次 /connect/token(参见第 4 节,①)。
11. 为什么选择 Aspose.Cells Cloud 进行搜索和替换?
- ✅ 零本地依赖 — 无需 Office/Excel、COM,也不需要脚本宿主。可从任何语言、任何平台调用(Linux、容器、无服务器);
- ✅ 超越文本搜索 — 单元格、形状和超链接都是一级匹配目标,这正是实际电子表格保存内容的地方;
- ✅ 作用域操作 — 工作簿 / 工作表 / 范围,使您可以在不重新写入 50 MB 文件的情况下修复单个工作表的某个区域;
- ✅ 云原生或无状态 — 已在存储中的文件永不离开;本地上传操作不产生任何持久化;
- ✅ 高保真重写 — 替换通过 Aspose.Cells 引擎应用并重新序列化,因此公式、样式、图表和格式在往返过程中得以保留;
- ✅ 跨 SDK 的统一形态 — cURL、.NET、Python 和 Java 接口一一对应,您在一种语言中复制的模式可直接在其他语言中使用。
立即开始: 在 Aspose Cloud Dashboard 上注册,创建一个应用程序,将您的凭据放入上面的任意代码片段,并指向您自己的工作簿之一——您将在几分钟内拥有一个可运行的内容审计。
觉得有用吗?给它加星标、收藏或分享——并在评论中告诉我们,你在使用工作簿搜索和替换做什么。