Guys, are you ready? Before we dive into its details: I want you to get an essence of the public release. I am giving you little preview of the new features and other enhancements available in the release for quick reference. I guess you know the valuable usage of MS Excel’s auto-fit rows/cols feature. Yet, you are one step ahead and perform the operation on merged cells by Aspose.Cells. While working in MS Excel IDE, you might not dislike formatted Tables but sometimes you need to convert to raw range. Here comes the library to accomplish these tasks via the APIs. Some of you might also like importing from JSON. So let’s not wait another moment to review the release notes. Do you want to know all exciting features and other enhancements? Here you go.
Autofit Rows for Merged Cells
Autofitting rows is a very common operation which you perform while working with the Excel files. This feature was already there in Aspose.Cells API however many people asked for more control over this operation. To fulfill this requirement we have provided AutoFitMergedCellsType enumerator which contains the following options:
- None: Ignore merged cells.
- FirstLine: Only expands the height of the first row.
- LastLine: Only expands the height of the last row.
- EachLine: Expands the height of each row.
Here is a snapshot of this feature where the effect of one of the options EechLine is shown.
You can test this feature using following sample code.
For more details on this topic please visit here.
Convert Table to Range with Options
Conversion of the table to a range was available earlier. However what if you want to control the formatting of destination range like formatting only the partial output. The good news is that this feature is available now and you don’t need to write extra code to format the output range. We have introduced a new class TableToRangeOptions where LastRow property is available to set the last row to which formatting is copied from the source table. Here is the view of a sample table and converted range which is formatted up to row 5.
Here is a sample code which is used to create the above range.
For detailed information on conversions follow this link.
Import Data from JSON
As you know that JavaScript Object Notation is a common data interchange format which is quite lightweight and can be read by human and machines easily. Now, for example, you get data from some Web API in JSON format and need it to be imported into some Excel file, then Aspose.Cells is there to provide this facility.
JSONUtility class is introduced by Aspose.Cells for this purpose having ImportData method that not only imports data but also performs different conversions and formatting using the JsonLayoutOptions object during the import process. You may try this exciting feature by following article Importing Data from JSON. Here is a sample code to use this feature:
You can see that result is cool as fully formatted Excel file is created without using any extra code to parse the JSON string from any source like Web API. Isn’t it? For example, if you get the following string from Web API, then output Excel file is shown in the image below:
[{“color”: “red”,”value”: “#f00”},{“color”: “green”,”value”: “#0f0”},{“color”: “blue”,”value”: “#00f”},{“color”: “cyan”,”value”: “#0ff”},{“color”: “magenta”,”value”: “#f0f”},{“color”: “yellow”,”value”:”#ff0″},{“color”: “black”,”value”: “#000”}]
Get Range with External Links
Microsoft Excel supports external links for fetching data from different sources. We have provided the option to retrieve these links from the Excel file using Name.GetRefferedAreas method. This method returns ReferredArea which has many useful properties as follows:
- EndColumn: The end column of the area
- EndRow: The end row of the area
- ExternalFileName: Get the external file name if this is an external reference
- IsArea: Indicates whether this is an area
- IsExternalLink: Indicates whether this is an external link
- SheetName: Indicates which sheet this reference is in
- StartColumn: The start column of the area
- StartRow: The start row of the area
You may find details on how to get range with external links for your reference. In the following example, an external file having named range “Names” is linked with the Excel file. We can access this named range in the linked file and display its properties mentioned above.
Keep Separators for Blank Rows During Spreadsheet to CSV Conversion
Many times you convert the Excel sheets to CSV for using it in some other environment or applications. You may need to decide yourself about the separators for blank rows in the spreadsheet while exporting it to CSV. For example, there is a blank row in the source spreadsheet and you want either a blank row in the CSV or have a row with predefined separators. We have provided this feature now and you can get details about this feature here.
For better understanding, have a look at the following image which shows the result of this feature.
Following is a sample code which demonstrates this new feature.
To use these useful features and avail other enhancements, I recommend you to try the release Aspose.Cells for .NET v19.3. And, if you have more time, browse Developers’ Guide for your complete reference on what you can deliver using the rendering extension API. You are always welcome to share your review, concerns or feedback on forums.