Charts are one of the great mechanisms to visually represent data and when dealing with computational data inside excel files, graphs and charts play a pivotal role in data representation. However, sometimes we stumble upon a situation where we cannot accommodate a chart/graphs within an excel spreadsheet. Consequently, we require a smarter way to represent the data trend, and here’s when sparklines come into action.
- Advantages of using Sparklines in Excel
- How to Get sparkline group description
- Add Sparkline group description
- Update Sparkline group description in Excel
- Steps to delete sparkline group description
- Related Resources
Advantages of using Sparklines in Excel
Sparklines in Excel enable you to see trends and patterns within your data at a glance using minimal real estate on your dashboard. Most of the time, you’ll probably create a group of sparklines — one for each row or column of data. A worksheet can hold any number of sparkline groups. Excel remembers each group, and you can work with the group as a single unit.
The sparkline groups provide a very convenient mechanism to deal with a set of sparklines in certain groups. For example, you can select one sparkline in a group and then modify the formatting of all sparklines in the group. In order to facilitate our users programmatically dealing with excel worksheets, the working with sparkline groups has been further optimized in the latest release version of Aspose.Cells Cloud API.
How to get sparkline group description
The fastest and easiest way to deal with documents is to use Cloud storage. Once you have uploaded the excel worksheet containing the sparkline group, you may easily get details pertinent to the group.
Getting JSON web authentication token
Our Cloud APIs and Cloud Storage are secured and can only be accessed by authorized users. Once you are authorized, you may easily perform read, upload, updated, or delete operations on documents available over cloud storage or available on a local system. In order to get the JWT token,
- First signup for an account over Cloud dashboard
- Then log-in to the Cloud dashboard and click the Applications menu from left
- By default, you will have the First App on the page. Click to open the details
- On the First App details page, you will find your personalized Client ID and Client Secret
- Enter the following command on the command prompt to retrieve your JWT token.
curl -v "https://api.aspose.cloud/connect/token" \ -X POST \ -d "grant_type=client_credentials&client_id=xxxx-xxx-xxx-xxx-xxxx&client_secret=xxxxxxx" \ -H "Accept: application/json"
For further details, please visit JSON Web Token Authentication
curl -X GET "https://api.aspose.cloud/v3.0/cells/Sparkline.xlsx/worksheets/Sheet1/sparklineGroups" \ -H "accept: application/json" \ -H "authorization: Bearer <JWT Token>"
Try using API Reference
- Open API Reference page for Aspose.Cells Cloud
- Authenticate using a Client ID and Client-Server keys
- Access GetWorksheetSparklineGroups API and click the Try it out button
- Provide excel workbook name against name field (which is Sparkline.xlsx in our case)
- Enter the name of the worksheet containing the Sparkline group against sheetName field (Sheet1 in our case)
- Click the Execute button. The details are fetched and displayed under responses section
The response will display all the details related to color, preset, style, Type, LowPointColor, MarkersColor, etc. Please take a look over the following images showing a preview of an excel worksheet containing sparkline groups as well as information rendered in response.
Add Sparkline group description
Aspose.Cells Cloud also provides the capabilities to add Sparkline group description in the excel worksheet. The PostWorksheetSparklineGroup requires name, sheetName, sparklineGroupIndex, sparklineGroup parameters to accomplish this requirement.
Update Sparkline group description in Excel
In order to update a sparkline in Excel, please try using PutWorksheetSparklineGroup API. The API requires the following parameters to fulfill the requirement
- name :- Name of the workbook stored on cloud storage
- sheetName :- Worksheet where you need to add the sparkline
- type :- Sparkline type (Line, Column, Win/Loss)
- dataRange :- The data range which we need to use as a source for sparkline
- isVertical :- Is the sparkline vertical or not
- locationRange :- The location where we need to draw the sparkline
curl -X PUT "https://api.aspose.cloud/v3.0/cells/Sparkline.xlsx/worksheets/Sheet1/sparklineGroups?type=Column&dataRange=B3%3AF9&isVertical=false&locationRange=G3%3AG9" \ -H "accept: application/json" \ -H "authorization: Bearer <JWT Token>"
In the above scenario, the type of sparkline is specified as Column (updated from Line to Column), dataRange is specified as B3:F9, isVertical is specified as False and locationRange is specified as G3:G9.
Steps to delete sparkline group description
Aspose.Cells Cloud also provides a quick mechanism to delete existing sparklines in excel. In order to remove all the sparkline groups, please try using DeleteWorksheetSparklineGroups API. Whereas if we need to remove the sparkline group based on a specific index ID, we need to use DeleteWorksheetSparklineGroup.
curl -X DELETE "https://api.aspose.cloud/v3.0/cells/Sparkline.xlsx/worksheets/Sheet1/sparklineGroups/1" \ -H "accept: application/json" \ -H "authorization: Bearer <JWT Token>"
After successful execution, 200 response code is displayed in response body. The following image shows the removed vertical sparkline group from excel worksheet. Whereas the other horizontal sparkline group remains in worksheet because only index 1 group is removed.
The article has explained the steps to get, create, update, and delete sparklines in excel using REST API. You may also consider reading a related blog Manipulate Charts Pivot Tables and Sparklines using Cloud API. In case you have any related query, please feel free to contact via Free support forum.
The source code of API can also be found over GitHub Free code repository.