We have changed API structure to equally match with .NET version of the product for APIs, features set, performance.
See the release notes of v7.0.0 to know about all the details and check especially, “Notable Changes for the Existing Users” table to know more about the changed APIs set:
1) You may try-catch and handle the main com.aspose.cells.CellsException class and you may use ExceptionType.Exception member now.
2) You may use com.aspose.cells.Cell.getDoubleValue() method that returns double type. Also, you may use Cell.getType() method that returns different CellValueType members for your need.
3), 4) Please use TextAlignmentType instead. The HorizontalAlignmentType and VerticalAlignmentType API is changed/renamed to become TextAlignmentType now, see the document for your reference:
5), 6), 7) See the sample code with comments:
//Instantiate the workbook object
Workbook workbook = new Workbook(“C:\book1.xls”);
//Get Cells collection
Cells cells = workbook.getWorksheets().get(0).getCells();
//Instantiate FindOptions Object
FindOptions findOptions = new FindOptions();
//Create a Cells Area
CellArea ca = new CellArea();
ca.StartRow = 8;
ca.StartColumn = 2;
ca.EndRow = 17;
ca.EndColumn = 13;
//Set cells area for find options
//Set searching properties
findOptions.setSeachOrderByRows(true); //If false then search order would be by columns.
//Find the cell with 0 value
Cell cell = cells.find(0, null, findOptions);
8) Check the following code to see how to set font using new versions.
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(0);
//Accessing the “A1” cell from the worksheet
Cell cell = worksheet.getCells().get(“A1”);
//Adding some value to the “A1” cell
Font font = cell.getStyle().getFont();
//Setting the font name to "Times New Roman"
font.setName(“Times New Roman”);
//Setting font size to 14
//setting font color as Red
//Saving the Excel file
9) No need to use (there is no setFont() method anymore) Style.setFont() method as you only need to get font of the cell’s style and change it according to your need, it will be applied directly. See the document for your complete reference:
10) Please create a Range object as per your desired area. Now, create Style object with your desired style formatting. Lastly, use Range.setStyle() method for your need.
We recommend you to kindly see the online Aspose.Cells for Java documentation for your complete reference (it is up-to-date):
"Also, I regret that the Workbook class is now throwing a lot of untyped java.lang.Exception. This is not very good practice and it is forcing us to catch and guess. Any plan to move back to specialized exceptions?"
Please try our latest version (v7.0.2) in which we have enhanced the Exceptional handling further.
Hope, this helps.