此 REST API 可让您将 Excel 文件中的单个工作表导出为多种不同文件格式。
摘要——使用 Get Worksheet(获取工作表) 端点,以您选择的格式下载工作簿中的单个工作表。
支持导出的格式如下:
| 格式 | 扩展名 | MIME 类型 |
|---|---|---|
| XLS | .xls | application/vnd.ms-excel |
| XLSX | .xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet |
| XLSB | .xlsb | application/vnd.ms-excel.sheet.binary.macroEnabled.12 |
| CSV | .csv | text/csv |
| TSV | .tsv | text/tab-separated-values |
| XLSM | .xlsm | application/vnd.ms-excel.sheet.macroEnabled.12 |
| ODS | .ods | application/vnd.oasis.opendocument.spreadsheet |
| TXT | .txt | text/plain |
| application/pdf | ||
| OTS | .ots | application/vnd.oasis.opendocument.spreadsheet-template |
| XPS | .xps | application/vnd.ms-xpsdocument |
| DIF | .dif | application/x-dif |
| PNG | .png | image/png |
| JPEG | .jpeg | image/jpeg |
| GIF | .gif | image/gif |
| BMP | .bmp | image/bmp |
| WMF | .wmf | image/wmf |
| TIFF | .tiff | image/tiff |
| EMF | .emf | image/emf |
| NUMBERS | .numbers | application/vnd.apple.numbers |
| FODS | .fods | application/vnd.oasis.opendocument.spreadsheet-flat-xml |
安全与身份验证
Aspose.Cells Cloud API 采用安全机制,需使用 基于 JWT 令牌的身份验证。
REST API
GET https://api.aspose.cloud/v3.0/cells/{name}/worksheets/{sheetName}
请求参数
| 参数名称 | 类型 | 位置 | 描述 |
|---|---|---|---|
| name | string | path | 必需。 Excel 文件名。 |
| sheetName | string | path | 必需。 要导出的工作表名称。 |
| format | string | query | 导出工作表的目标文件格式(例如:pdf、png)。 |
| verticalResolution | integer | query | 图像格式(如 PNG、JPEG)的垂直分辨率(DPI)。 |
| horizontalResolution | integer | query | 图像格式的水平分辨率(DPI)。 |
| area | string | query | 要导出的单元格范围(例如:A1:D10)。 |
| pageIndex | integer | query | 工作表分页时要导出的页码索引。 |
| folder | string | query | 存储中源文件所在的文件夹路径。 |
| storageName | string | query | Aspose Cloud 存储空间的名称。 |
OpenAPI 规范 定义了一个公开可访问的编程接口,可让您直接通过网页浏览器执行 REST 调用。
您可使用 cURL 命令行工具轻松访问 Aspose.Cells Web 服务。以下示例展示了如何使用 cURL 调用云 API。
错误处理
API 返回标准 HTTP 状态码。常见响应如下:
| 状态码 | 含义 | 示例 JSON 响应体 |
|---|---|---|
| 200 | 成功——返回工作表数据流。 | { "stream": "..." } |
| 400 | 请求错误——缺少或参数无效。 | { "error": "Invalid format parameter." } |
| 401 | 未授权——JWT 令牌无效或缺失。 | { "error": "Authentication failed." } |
| 404 | 未找到——指定的文件或工作表不存在。 | { "error": "Worksheet not found." } |
| 500 | 服务器内部错误——服务器发生意外情况。 | { "error": "Unexpected error." } |
请在客户端代码中正确处理这些响应,以向用户提供适当的反馈信息。
云 SDK 家族
使用 SDK 是加速开发的最佳方式。SDK 会处理底层细节,让您专注于项目任务。请查阅 GitHub 仓库,获取 Aspose.Cells Cloud SDK 的完整列表。
以下代码示例展示了如何使用多种 SDK 调用 Aspose.Cells Web 服务: