介绍
在现代应用程序开发中,文档格式转换是一项常见但复杂的需求。传统解决方案往往存在功能臃肿和界面复杂的问题,增加了开发者的集成难度。Cells Cloud 4.0 通过重新设计其 Conversion 功能,采用极简的 API 设计和单一职责的聚焦,帮助开发者轻松实现无缝的文档格式转换。本文详细介绍了这一创新功能,并演示如何通过低代码方式快速将其集成到您的应用中。
核心功能:Cells Cloud 4.0 转换
- Single-Purpose Focus: 专注于文档转换,不包含无关功能,确保最佳性能
- Minimalist API Design: 通常每次调用只需 2-3 个参数,降低学习曲线
- Comprehensive Format Support: 在 Excel、CSV、PDF、HTML 等常见格式之间实现相互转换,以满足多样化需求
- Low-Code Integration: 只需几行代码即可实现完整功能,显著提升开发效率
- Cloud/Local Support: 无缝处理本地和云端存储的文档,兼容主流云存储平台
关键功能展示
关键场景的代码使用 Python 编写,但也可以使用其他开发语言的 SDK。例如 .Net 示例、Java 示例、Node.js 示例 等。
1. 将 Excel 转换为 PDF
# Convert the EmployeeSalesSummary.xlsx file to Pdf format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.convert_spreadsheet(ConvertSpreadsheetRequest( 'EmployeeSalesSummary.xlsx', 'pdf') , local_outpath = "EmployeeSalesSummary.pdf")
2. 将工作表转换为 PDF
# Convert the "Sales" worksheet in the "EmployeeSalesSummary.xlsx" file to Pdf format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.convert_worksheet_to_image(
ConvertWorksheetToImageRequest(EmployeeSalesSummaryXlsx, "Sales"),
local_outpath="EmployeeSalesSummary_Sales.pdf")
3. 将工作表转换为图像(支持 SVG/PNG/TIFF/JPG 等)
# Convert the "Sales" worksheet in the "EmployeeSalesSummary.xlsx" file to PNG format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.convert_worksheet_to_image(
ConvertWorksheetToImageRequest(EmployeeSalesSummaryXlsx, "Sales", format="png"),
local_outpath="EmployeeSalesSummary_Sales.png")
4. 将工作表表格转换为 JSON
# Convert "Table1" in the "EmployeeSalesSummary.xlsx" file to Json format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.convert_table_to_json(
ConvertTableToJsonRequest(EmployeeSalesSummaryXlsx, "Sales", "Table1"),
local_outpath="EmployeeSalesSummary_Sales_Table.json")
5. 将工作表表格转换为 HTML
# Convert "Table1" in the "EmployeeSalesSummary.xlsx" file to HTML format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.convert_table_to_html(
ConvertTableToHtmlRequest(EmployeeSalesSummaryXlsx, "Sales", "Table1"),
local_outpath="EmployeeSalesSummary_Sales_Table.html")
6. 将工作表范围转换为 JSON
# Convert the "B5:L36" range in the "EmployeeSalesSummary.xlsx" file to Json format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.convert_range_to_json(
ConvertRangeToJsonRequest(EmployeeSalesSummaryXlsx, "Sales", "B5:L36"),
local_outpath="EmployeeSalesSummary_Sales_area.json")
多源支持
Cells Cloud 4.0 不仅处理本地电子表格文件,还能无缝集成云存储。通过与 Aspose Cloud Storage 的集成,它支持包括 Amazon S3、Azure Blob Storage、Google Cloud Storage 和 Dropbox 在内的多种平台。
1. 将云文件导出为 CSV
# Convert the "EmployeeSalesSummary.xlsx" file stored on Aspose Cloud Storage to CSV format.
instance = CellsApi(os.getenv('CellsCloudClientId'), os.getenv('CellsCloudClientSecret'))
instance.export_Spreadsheet_as_format(
ExportSpreadsheetAsFormatRequest(EmployeeSalesSummaryXlsx, "csv", folder="PythonSDK"),
local_outpath="EmployeeSalesSummary.csv")
SDK指南:安装和使用 Aspose.Cells Cloud SDKs
通过我们的多语言 SDK,实现无缝的 Excel/电子表格自动化,简化您的开发工作流。使用这些经过实战检验的安装方法,几分钟即可上手。
综合 SDK 安装矩阵
| 语言 | 包管理器 | 安装命令 | 文档链接 |
|---|---|---|---|
| .NET | NuGet | dotnet add package Aspose.Cells-Cloud |
.NET SDK 快速入门 |
| Java | Maven | mvn repository: https://repository.aspose.cloud/repo/ |
Java SDK 快速入门 |
| Python | pip | pip install asposecellscloud |
Python SDK 快速入门 |
| Node.js | npm | npm i asposecellscloud |
Node.js SDK 快速入门 |
| PHP | Composer | composer require aspose/cells-sdk-php |
PHP SDK 快速入门 |
| Go | Go Modules | go install github.com/aspose-cells-cloud/aspose-cells-cloud-go/v25@latest |
GoLang SDK 快速入门 |
| Ruby | RubyGems | gem install aspose_cells_cloud |
Ruby SDK 快速入门 |
| Perl | CPAN | cpanm AsposeCellsCloud::CellsApi |
Perl SDK 快速入门 |
结论
凭借其 新文档转换功能,Aspose.Cells Cloud 4.0 提供了一个 简洁、高效 且 开发者友好 的文档格式转换解决方案。通过采用 极简 API 设计 并专注于 单一功能,它实现了 低代码集成,并让开发者只需几行代码即可执行格式转换。
结合对 本地和基于云的文档 的支持,以及与 多语言 SDK 的无缝集成,Cells Cloud 4.0 是现代文档处理工作流的理想工具。
FAQ
- Q1: 在 Cells Cloud 4.0 中支持哪些文件格式进行转换?
A: Cells Cloud 4.0 支持在 Excel (XLSX/XLS)、CSV、PDF、HTML、JSON 以及 PNG、JPG、TIFF、SVG 等图像格式之间相互转换。
- Q2: 它是否同时支持云端和本地文件?
A: 是的,Cells Cloud 4.0 支持转换本地文件以及存储在云平台(如 Amazon S3、Azure Blob Storage、Google Cloud Storage 和 Dropbox)中的文件。
- Q3:是否需要复杂的配置或陡峭的学习曲线?
A:不。Cells Cloud 4.0 使用极简的 API 设计——大多数操作仅需 2–3 个参数——显著降低了开发人员的学习曲线。
- Q4:转换过程中原始格式会受到影响吗?
A: 不。转换过程会保留原始文档的样式、公式、图表和格式,以确保输出的保真度。
- Q5: 是否提供免费试用计划?
A: 是的,Aspose.Cells Cloud 提供一个免费计划,包含有限次数的 API 调用,用于测试和开发目的。