簡介

在現代應用程式開發中,文檔格式轉換是一個既常見又複雜的需求。傳統解決方案通常會遭遇功能過載和複雜介面的問題,增加了開發人員的整合難度。Cells Cloud 4.0 通過重新設計其轉換功能,以最小化的 API 設計和單一目的為重點,解決了這個問題,使開發人員能夠輕鬆實現無縫的文檔格式轉換。本文詳細介紹這一創新功能,並展示如何以低代碼方法快速將其整合到您的應用程式中。

核心功能:Cells Cloud 4.0 轉換

  • 單一目的專注:專注於文件轉換,沒有不相關的功能,確保最佳性能
  • 簡約的 API 設計:通常每次呼叫只需要 2-3 個參數,降低學習曲線
  • 全面格式支持:在 Excel、CSV、PDF、HTML 及其他常見格式之間的互轉,以滿足多樣化需求
  • 低代碼整合:只需少量程式碼即可完成所有功能,顯著提高開發效率
  • 雲端/本地支援:無縫處理本地和雲端儲存的文件,與主要雲端儲存平台相容

關鍵功能展示

關鍵場景的程式碼是用 Python 編寫的,但也可以使用其他開發語言的 SDK。比如 .Net ExamplesJava ExamplesNode.js Examples 等等。

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")

SDKs 指南:安裝和使用 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 Quick Start
Ruby RubyGems gem install asposecellscloud Ruby SDK 快速入門
Perl CPAN cpanm AsposeCellsCloud::CellsApi Perl SDK 快速入門

結論

憑藉其新的文件轉換功能,Aspose.Cells Cloud 4.0 提供了一個簡單、高效且對開發者友好的解決方案來轉換文件格式。通過採用極簡的 API 設計並專注於單一目的的功能,它實現了低代碼集成,並允許開發者僅用幾行代碼執行格式轉換。

結合對本地和雲端文件的支援,以及與多語言 SDK 的無縫整合,Cells Cloud 4.0 是現代文件處理工作流程的理想工具。

常見問題解答

  • 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 調用,用於測試和開發目的。

附加資源