How to turn getAreas into an ArrayList? - updating deleted method getAreasList()


#1

Hello
I am very new to Java and to Aspose and messing around a bit with our code in order to trying to figure out if updating to Apose 19 will improve the performance. I replaced the libary of aspose 7.7.1.3 with the latest 19.9, but when I try to run it gets stuck on this:

@Override
public Collection<CellRangeAddress> getRegions() {
    Collection<CellRangeAddress> ret = new ArrayList<CellRangeAddress>();
    ArrayList<CellArea> areaList = validation.getAreaList();
    for (CellArea cellArea : areaList) {
        ret.add(new AsposeCellRangeAddress(cellArea));
    }
    return ret;
}

the getAreaList method is not in the validation class anymore in Aspose 19. In another thread I read that getAreas can be used, but the types of data passed are very different. First a list was passed and now with the getAreas method a CellArray[] is passed. Can you please tell me what to write on the line that starts with ArrayList? I tried several thing but cannot get it to work.

Some additional code, might it be needed:

the above code is in an AsposeDataValidation class that extends the DataValidation class:

public abstract class DataValidation {
	public abstract int getValidationConstraintType();
	public abstract Collection<CellRangeAddress> getRegions();
	public abstract List<Object> getValidationOptionValues(String type, Sheet sheet, 
IProvideCellValue valueProvider) throws Exception;
}

The CellRangeAddress class is also self written, here is the code of that one:

public abstract class CellRangeAddress {
	public abstract Integer getFirstRow();
	public abstract Integer getFirstColumn();
	public abstract Integer getLastRow();
}

Hopefully this provides you enough information of how to update my code.


#2

@jbijsusteen,
You may please try the following sample code which demonstrates the required feature. If it does not fulfill your requirement, please provide and runnable sample console application which is required to be converted to latest version of API. We will analyze your code and provide assistance accordingly.

Workbook workbook = new Workbook();
ValidationCollection validations = workbook.getWorksheets().get(0).getValidations();
CellArea area = new CellArea();
area.StartRow = 0;
area.EndRow = 1;
area.StartColumn = 0;
area.EndColumn = 1;
validations.add(area);
Validation validation = validations.get(0);
CellArea[] areas =  validation.getAreas();
List<CellArea> list = Arrays.asList(area);