How to Add Worksheets to Excel - Insert New Sheets at Specific Locations
Programmatically add worksheets to Excel files with full control over sheet type and location. Insert standard worksheets, chart sheets, or macro sheets at any position in the workbook. RESTful API for automated Excel workbook management and organization.
| Worksheet Type | Description |
|---|---|
| VB | Visual Basic module |
| Worksheet | Worksheet |
| Chart | Chart sheet |
| BIFF4Macro | BIFF4 Macro sheet |
| InternationalMacro | International Macro sheet |
| Other | International Macro sheet |
| Dialog | Dialog worksheet |
Add Worksheet to Spreadsheet API
API Endpoint
PUT http://api.aspose.cloud/v4.0/cells/spreadsheet/add/worksheet
Request Parameters:
| Parameter Name | Type | Path/Query String/HTTPBody | Description |
|---|---|---|---|
| Spreadsheet | File | FormData | Required. The target Excel workbook file (.xlsx, .xls, etc.) to which a new worksheet will be added. |
| sheetType | String | Query | Optional. The type of worksheet to create. Acceptable values include worksheet (default), chartsheet, macroSheet, etc. Determines the functional behavior of the new sheet. |
| position | Integer | Query | Optional. The zero-based index at which to insert the new worksheet. For example, 0 inserts before the first sheet, 2 inserts as the third sheet. If omitted, the sheet is appended at the end. |
| sheetName | String | Query | Optional. The name to assign to the newly created worksheet. Must be unique within the workbook and follow Excel naming rules. If not provided, a default name (e.g., “SheetX”) is generated. |
| outPath | String | Query | Optional. The target directory path in cloud storage where the modified workbook will be saved. If null or omitted, it may save to the same location as the source or a default path. |
| outStorageName | String | Query | Required. The name identifier of your configured cloud storage service (e.g., CompanyOneDrive) where the output file should be written. |
| region | String | Query | Optional. The locale setting (e.g., en-CA) to apply, which can affect default formatting and regional rules in the new worksheet. |
| password | String | Query | Optional. The password required to decrypt and modify a password-protected workbook. Omit if the file is not encrypted. |
Response
[
{
"Name": "ResponseFile",
"DataType": {
"Identifier": "File",
"Reference": "Stream"
}
}
]
Error Codes
- 400 Bad Request: Invalid Aspose.Cells Cloud API URI.
- 401 Unauthorized: Invalid access token. Or invalid client id and secret.
- 404 Not Found: The spreadsheet file not accessible.
- 500 Server Error: The spreadsheet has encountered an anomaly in obtaining calculation data.
Where should we use the Add Worksheet to Spreadsheet API?
- Automated Report Generation System: During the automated financial statement generation process at the end of each month, new work sheets (such as
2024-05) are dynamically created and inserted for the new monthly data, ensuring a clear and orderly workbook structure. - Batch File Template Initialization: When creating standardized documents such as sales quotations and project proposals in batches, an independent analysis or detail work sheet is inserted in the template workbook for each new customer or project.
- Dynamic Expansion of Data Dashboards: When the monitoring dashboard needs to add new data dimensions or analysis modules, new chart work sheets are inserted in real time through API, enabling the dynamic expansion of dashboard functionality.
- Compliance and Audit Document Archiving: During annual audits or compliance checks, new evidence collection sheets are automatically inserted in the audit tracking workbook, creating independent record spaces for each inspection point.
Why should you use the Add worksheet to Spreadsheet API?
- Developer-Friendly: Aspose.Cells Cloud offers SDK libraries in multiple languages, enabling quick development and comes with comprehensive documentation. Compared to building custom chart rendering solutions, this significantly reduces the development workload.
- Reduced Labor Costs: Reduced the need for positions dedicated to document consolidation.
- Pay-per-use: No upfront investment, only pay for API calls actually used.
- Zero Maintenance Costs: No need to maintain servers, update software, or deal with compatibility issues.
- Preserves complex Excel formatting in universally accessible PDF format.
How to Use the Add Worksheet to Spreadsheet API with SDKs
Add Worksheet to Spreadsheet API Specification
The Add Worksheet to Spreadsheet API Specification defines a publicly accessible programming interface and allows 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 add a worksheet to a 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 make API calls to Aspose.Cells web services using various SDKs: