How to Convert a Spreadsheet Worksheet to CSV Using Aspose.Cells Cloud API

The ConvertWorksheetToCsv endpoint transforms a single worksheet from a local spreadsheet file into a CSV document entirely on the Aspose.Cells Cloud server. By uploading the source file and specifying the target worksheet, developers receive a binary CSV stream without needing to store the file in cloud storage. This API is ideal for automating data extraction, integrating spreadsheet data into downstream systems, and reducing storage overhead.

Prerequisites

Before calling the API, you need:

  • An Aspose Cloud account.
  • A Client ID and Client Secret.
  • An OAuth 2.0 access token (obtainable via the Aspose Cloud token endpoint).

Convert Worksheet to CSV API

Web API

PUT https://api.aspose.cloud/v4.0/cells/convert/worksheet/csv

cURL Sample

curl -X PUT "https://api.aspose.cloud/v4.0/cells/convert/worksheet/csv?worksheet=Sheet1" \
  -H "Authorization: Bearer {access_token}" \
  -F "Spreadsheet=@myWorkbook.xlsx"

Request Parameters

Parameter Name Type Location Required/Optional Description
Spreadsheet File FormData Required Binary file of the source spreadsheet (e.g., .xlsx, .xls). Example: myWorkbook.xlsx.
worksheet String Query Required Name of the worksheet to be converted (case‑sensitive). If omitted, the first worksheet is used. Example: Sheet1.
outPath String Query Optional Target folder path in cloud storage where the generated CSV will be saved. If omitted, the CSV is returned directly in the response stream.
outStorageName String Query Optional Name of the storage service (e.g., Azure, AWS S3) where the output file should be placed. Required only when outPath is used.
fontsLocation String Query Optional Path to a custom fonts folder on the server, allowing the conversion engine to use non‑standard fonts.
region String Query Optional Locale identifier that influences number/date formatting in the CSV (e.g., en-US, fr-FR).
password String Query Optional Password for opening a protected spreadsheet. Must match the encryption password of the source file.

Response

Successful response (200 OK)

  • Content-Type: text/csv or application/octet-stream
  • Headers:
    • Content‑Disposition: attachment; filename="<worksheet>.csv"
    • Content‑Length: <size in bytes>
  • Body: binary stream containing the generated CSV file.

If outPath is supplied, the response body is empty and the CSV is stored at the specified cloud location; the response includes a JSON payload with the storage path.

Error responses follow standard HTTP status codes (400, 401, 404, 500) with a JSON error object:

{
  "code": "ErrorCode",
  "message": "Human‑readable error description"
}

Error Codes

  • 400 Bad Request – Invalid Aspose.Cells Cloud API URI.
  • 401 Unauthorized – Invalid access token, client ID, or client secret.
  • 404 Not Found – The spreadsheet file is not accessible.
  • 500 Server Error – The spreadsheet caused an internal processing error.

When to Use the Convert Worksheet to CSV API?

  • Data Extraction for BI pipelines – Pull a specific worksheet from an Excel report and feed the resulting CSV directly into Power BI or Tableau without intermediate file handling.
  • Automated Invoice Processing – Convert the worksheet containing invoice rows to CSV for fast import into accounting systems.
  • Legacy System Integration – Export worksheet data to CSV for consumption by older applications that only accept delimited text files.
  • On‑the‑fly Reporting – Generate CSV snapshots of live spreadsheet data in a web service, returning the file instantly to the client browser.

Why Use the Convert Worksheet to CSV API?

  • No permanent cloud storage required – The file is streamed directly to the conversion engine and discarded after conversion, saving bandwidth and storage costs.
  • High‑Performance Cloud Execution – Conversion runs on Aspose’s optimized servers, delivering faster results than client‑side libraries.
  • Fine‑grained Control – Select a single worksheet, apply custom fonts, regional formatting, and password protection in one request.
  • Consistent Cross‑Platform Output – Guarantees identical CSV output across .NET, Java, Python, and other SDKs using the same REST endpoint.

How to Use the Convert Worksheet to CSV API with SDKs

Convert Worksheet to CSV API Specification

The Convert Worksheet to CSV API Specification provides a publicly accessible programming interface for executing REST interactions directly from a web browser.

Excel API SDK

Use Aspose.Cells Cloud SDKs

Using the SDK is the fastest way to develop, as it abstracts away the low‑level details, allowing you to merge a spreadsheet into another spreadsheet with short code. Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.

The following code examples demonstrate how to interact with Aspose.Cells web services using various SDKs:

Frequently Asked Questions

Q: What HTTP method and endpoint are used to convert a worksheet to CSV?
A: Send a PUT request to https://api.aspose.cloud/v4.0/cells/convert/worksheet/csv.

Q: How do I authenticate the request?
A: Include an Authorization: Bearer <access_token> header obtained via the Aspose Cloud OAuth 2.0 flow.

Q: Can I save the generated CSV directly to cloud storage?
A: Yes. Provide the outPath (target folder) and optionally outStorageName (storage service) as query parameters. The response will contain a JSON payload with the storage location.

Q: What is the maximum file size supported?
A: The API accepts files up to 100 MB. Larger files may result in a 400 Bad Request error.