Aspose.Cells Trim Content API – Remove Spaces & Line Breaks from Excel

The PostTrimContent API processes and trims content within a specified range in a spreadsheet. It removes extra spaces, line breaks, and other unnecessary characters from the content of selected cells, making it useful for cleaning data entries and ensuring consistent spreadsheet formatting.

Excel Web API : PostTrimContent

POST https://api.aspose.cloud/v3.0/cells/trimcontent

Authentication – Include a valid Aspose Cloud access token in the request header:

Authorization: Bearer <your_access_token>

Sample Request Body

{
  "trimContentOptions": {
    "range": "A1:C10",
    "trimMode": "All", // Options: All, Leading, Trailing
    "ignoreCase": false,
    "preserveFormula": true
  }
}

Function Description

  • Efficiency – Trims content only within the designated range, saving time and resources by avoiding unnecessary operations on the entire worksheet.
  • Flexibility – Allows users to define the exact cell range to be processed, accommodating various data sets and requirements.
  • Data Integrity – Removes extra spaces and line breaks, helping maintain consistent and reliable data for analysis and reporting.
  • Ease of Use – Simple integration with minimal setup, suitable for both developers and end‑users.

Request Parameters of postTrimContent API

Parameter Name Type Location Description
trimContentOptions Class Body Options that specify how the content should be trimmed (e.g., target range, trim mode).

Response Description

{
  "Filename": "sample.xlsx",
  "FileSize": 123456,
  "FileContent": "base64_encoded_string"
}

Error Handling

HTTP Status Code Description
400 BadRequest Invalid request parameters or malformed JSON.
401 Unauthorized Missing or invalid authentication token.
404 NotFound Specified workbook or range not found.
500 InternalServerError Unexpected server error.

OpenAPI Specification

The OpenAPI Specification defines a publicly accessible programming interface and lets you carry out REST interactions directly from a web browser.

Excel API SDK

Using an SDK is the best way to speed up development. An SDK handles low‑level details, allowing you to focus on your project tasks. Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.

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

Last updated: 2026-03-30