Set Margins of Comment or Shape and Specify Formula Fields while Importing Data to Worksheet using Aspose.Cells for Java 18.2

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Aspose.Cells for JavaWe are pleased to announce the release of Aspose.Cells for Java 18.2. This release includes many new features and enhancements along with some critical bug fixes that further improve the overall stability of the APIs. We also recommend our clients to use the powerful Aspose for Java APIs directly in their Maven Projects with simple configurations. Please check the release notes in order to get an idea about what is new and what has been fixed with this revision of Aspose.Cells for Java. Here is a look at the major features in this release.

Set Margins of Comment or Shape inside the Worksheet

Aspose.Cells allows you to set the margins of any shape or comment using the Shape.TextBody.TextAlignment property. This property returns the object of ShapeTextAlignment class which has different properties e.g. TopMarginPt, LeftMarginPt, BottomMarginPt, RightMarginPt etc. that can be used to set the top, left, bottom and right margins. For more detail, please see the following article.

The following code loads the sample Excel file and accesses its shapes one by one and sets their top, left, bottom and right margins.

//Load the sample Excel file
Workbook wb = new Workbook(dirPath + "sampleSetMarginsOfCommentOrShape.xlsx");

//Access first worksheet
Worksheet ws = wb.getWorksheets().get(0);

for(int idx =0; idx<ws.getShapes().getCount(); idx++)
{
	//Access the shape
	Shape sh = ws.getShapes().get(idx);
	
	//Access the text alignment
	ShapeTextAlignment txtAlign = sh.getTextBody().getTextAlignment();

	//Set auto margin false
	txtAlign.setAutoMargin(false);

	//Set the top, left, bottom and right margins
	txtAlign.setTopMarginPt(10);
	txtAlign.setLeftMarginPt(10);
	txtAlign.setBottomMarginPt(10);
	txtAlign.setRightMarginPt(10);	    
}

//Save the output Excel file
wb.save(dirPath + "outputSetMarginsOfCommentOrShape.xlsx");

Specify Formula Fields while Importing Data to Worksheet

You can specify formula fields when you import data into your worksheet using the ImportTableOptions.setFormulas() method. This method takes the Boolean array where the value true means the field is a formula field. For example, if the third field is a formula field, then third value in the array will be true. For more detail, please see the following article.

Specify Maximum Rows of Shared Formula

Aspose.Cells provides the Workbook.Settings.MaxRowsOfSharedFormula property that can be used to specify the maximum rows of the shared formula. The shared formula will be split to several shared formulas if the total rows of shared formula is greater than it. For more detail, please see the following article.

Control External Resources using WorkbookSetting.StreamProvider

Sometime, your Excel file contains external resources e.g. linked images etc. Aspose.Cells allows you to control these external resources using Workbook.Settings.StreamProvider which takes the implementation of IStreamProvider interface. Whenever you will try to render your worksheet containing external resources e.g. linked images, the methods of IStreamProvider interface will be invoked which will enable you to take appropriate actions for your external resources. For more detail, please see the following article.

Filter Defined Names while loading Workbook

Aspose.Cells allows you to filter or remove defined names present inside the workbook. Please use LoadDataFilterOptions.DEFINED_NAMES to load defined names and use ~LoadDataFilterOptions.DEFINED_NAMES to remove them while loading the workbook. Please note, if you will remove defined names, then formulas inside the workbook may break up. For more detail, please see the following article.

Aspose.Cells for Java Resources

The resources, you may need to accomplish your tasks: