Remove Characters by Position in Excel with Aspose.Cells Cloud API
The RemoveCharactersByPosition API (PUT https://api.aspose.cloud/v4.0/cells/content/remove/characters-by-position) in Aspose.Cells Cloud v4.0 deletes characters from Excel cell ranges by position—supporting first/last N characters, text before/after a substring, or content between two delimiters—while preserving formulas, formatting, and data validation, enabling precise text cleaning for data standardization and batch preprocessing without complex regex.
Overview
Remove unwanted characters from Excel cells based on positional rules. Aspose.Cells Cloud Web API supports five deletion modes: first N characters, last N characters, before/after a substring, or between two delimiters. This enables precise text cleaning without complex regex, ideal for data standardization, log parsing, and batch preprocessing.
Position Modes
The API supports the following position-based removal strategies:
| Mode | Description |
|---|---|
theFirstNCharacters |
Removes the first N characters from each selected cell. |
theLastNCharacters |
Removes the last N characters from each selected cell. |
allCharactersBeforeText |
Deletes all text before the first occurrence of the specified substring. |
allCharactersAfterText |
Deletes all text after the first occurrence of the specified substring. |
BetweenValues |
Removes the substring between two delimiters. Optionally excludes the delimiters themselves using the includingDelimiters parameter (see Options). |
Options
| Option | Type | Description |
|---|---|---|
caseSensitive |
Boolean | Controls case sensitivity for allCharactersBeforeText, allCharactersAfterText, and BetweenValues. Default: false. |
includingDelimiters |
Boolean (not exposed in query params) | Applies only to BetweenValues mode. When false, the delimiter strings themselves are retained; when true, they are removed along with the inner content. (Note: This option is internal to the API service and may be set via SDK or body payload in future versions.) |
The Remove Characters by Position Web API
PUT https://api.aspose.cloud/v4.0/cells/content/remove/characters-by-position
Security and Authentication
The API requires JWT token-based authentication.
-H "Authorization: Bearer {access_token}"
Request Parameters
| Parameter Name | Type | Path/Query String/HTTPBody | Description |
|---|---|---|---|
| Spreadsheet | File | FormData | Upload spreadsheet file. |
| theFirstNCharacters | Integer | Query | Specify removing the first n characters from selected cells. |
| theLastNCharacters | Integer | Query | Specify removing the last n characters from selected cells. |
| allCharactersBeforeText | String | Query | Specify using targeted removal options to delete text that is located before certain characters. |
| allCharactersAfterText | String | Query | Specify using targeted removal options to delete text that is located after certain characters. |
| caseSensitive | Boolean | Query | Affects Substring mode and CustomChars when enabled. |
| worksheet | String | Query | Specify the worksheet of spreadsheet. |
| range | String | Query | Specify the worksheet range of spreadsheet. |
| outPath | String | Query | (Optional) The folder path where the workbook is stored. The default is null. |
| outStorageName | String | Query | Output file Storage Name. |
| region | String | Query | Spreadsheet region/language setting (e.g., en-US, fr-FR). Influences number formatting, date parsing, and locale‑specific behavior. |
| password | String | Query | The password for opening spreadsheet file. |
Note: Only one primary mode (
theFirstNCharacters,theLastNCharacters,allCharactersBeforeText,allCharactersAfterText, orBetweenValues) should be specified per request. Combining modes yields undefined behavior.
Response
[
{
"Name": "ResponseFile",
"DataType": {
"Identifier": "File",
"Reference": "Stream"
}
}
]
Sample response headers
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename="result"
On success, returns the cleaned workbook as a binary stream (Content-Type: application/octet-stream).
HTTP Status Codes
| Code | Meaning | Description |
|---|---|---|
| 200 | OK | The request completed successfully. |
| 400 | Bad Request | The request is malformed or one or more parameters are invalid. |
| 401 | Unauthorized | Authentication failed, or the JWT token is missing or expired. |
| 404 | Not Found | The requested workbook, worksheet, or resource was not found. |
| 413 | Payload Too Large | The uploaded file exceeds the allowed size limit. |
| 500 | Internal Server Error | The server encountered an unexpected error while processing the request. |
Use Cases
- Data Standardization: Strip leading zeros from product codes or country codes from phone numbers.
- Log Parsing: Extract messages by removing timestamps or prefixes (e.g.,
[INFO]). - Filename Organization: Remove uniform date prefixes or suffixes from bulk file lists.
- Structured Text Extraction: Isolate content between delimiters (e.g.,
[id:12345]→12345). - Database Import Prep: Clean imported CSV/Excel fields (e.g., remove trailing commas, leading quotes).
Benefits
- Precision: Position-based logic avoids regex complexity and false positives.
- Batch Efficiency: Apply rules across entire worksheets or ranges in a single request.
- Preservation: Formatting, formulas, and data validation remain intact.
- Developer Experience: Prebuilt SDKs for C#, Java, PHP, Ruby, Node.js, Python, Perl, and Go accelerate integration.
Customers report up to 90% reduction in text-cleaning time for large workbooks compared to manual or spreadsheet-native approaches. (See Aspose.Cells Cloud Case Studies for verified examples.)
How to Use the Remove Characters by Position API with SDKs?
Remove Characters by Position API Specification
The Remove Characters by Position API Specification defines a publicly accessible programming interface and enables you to carry out REST interactions directly from a web browser.
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 use the API with short code.
Please check out the GitHub repository for a complete list of Aspose.Cells Cloud SDKs.
Using an SDK is recommended for production use. The SDK handles authentication, serialization, and error handling.
Explore the full SDK source and examples at GitHub.