IRangeAddressBuilder
Use IRangeAddressBuilder
to build IRangeAddress
.
Functionality:
- buildCell() - builds an address of a single cell;
- buildRange() - returns a single cell or a range address depending on the size of the range.
Usage example
import com.intechcore.scomponents.scell.api.init.ScellApiEntryPoint;
import com.intechcore.scomponents.scell.api.spreadsheet.model.address.IRangeAddress;
import com.intechcore.scomponents.scell.api.spreadsheet.service.builder.IRangeAddressBuilder;
import java.util.concurrent.CompletableFuture;
public class TestApp {
public static void main(String[] args) {
ScellApiEntryPoint.getApiResolverAsync().thenAccept(resolver -> {
IRangeAddressBuilder addressBuilder = resolver.resolve(IRangeAddressBuilder.class);
IRangeAddress defaultAddress1 = addressBuilder.buildCell();
System.out.println("defaultAddress1 = " + defaultAddress1.toA1String()); // A1
IRangeAddress defaultAddress2 = addressBuilder.buildRange();
System.out.println("defaultAddress2 = " + defaultAddress2.toA1String()); // A1
IRangeAddressBuilder customBuilder = addressBuilder
.from(defaultAddress2) // taking existing address as source
.setBottomRight(3, 2); // setting bottom right corner of future range
IRangeAddress customAddress1 = customBuilder.buildRange();
System.out.println("customAddress1 = " + customAddress1.toA1String()); //A1:B3
IRangeAddress customAddress2 = customBuilder.buildCell();
System.out.println("customAddress2 = " + customAddress2.toA1String()); // A1
IRangeAddress customAddress3 = addressBuilder
.setBottomRow(4)
.buildRange();
System.out.println("customAddress3 = " + customAddress3.toA1String()); // A1:B4
IRangeAddressBuilder parsedAddressBuilder = addressBuilder
.fromA1String("A1"); // parse cell address from string. Not empty if string represents correct address
IRangeAddressBuilder parsedRangeBuilder = addressBuilder
.fromA1String("A1:B5"); // parse cells range from string. Not empty if string represents correct range
}).whenComplete((unused, throwable) -> {
if (throwable != null) {
System.out.println(throwable.getMessage());
}
}).join();
}
}