We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Usage of templates in ASPOSE Java


We are using the template for report generation using ASPOSE .NET cells. Now, we are planning to migrate from code from .NET to Java. I would like to is there any equivalent of usage of markers in Java such as:

dvCAdequacyHeaderAccts is datatable name.
VALUE_AMT1 is column name.

I would like to if there is equivalent to datatable can be passed

Mahesh Babu

Hi Mahesh,

Thanks for your posting and using Aspose.Cells for Java.

You can implement ICellsDataTable interface as shown below and then set your data source.

I have attached the sample xlsx file used in this code and output xlsx file generated by it for your reference.

String filePath = “F:\Shak-Data-RW\Downloads\sample.xlsx”;

Workbook workbook = new Workbook(filePath);
WorkbookDesigner designer = new WorkbookDesigner(workbook);

CellsDataTableMap dataTable = new CellsDataTableMap();

designer.setDataSource(“dvCAdequacyHeaderAccts”, dataTable);


workbook.save(filePath + “.out.xlsx”);


import com.aspose.cells.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

* DataTable class (based on ASPOSE data table object)
* Has the member “mapList”. This will contain a list of elements parsed from the source XML file.
* The methods are called by the ASPOSE API when “designerobject.process” is executed.
* @author mattimob
public class CellsDataTableMap implements ICellsDataTable {
private List mapList = new ArrayList();
private int index;
private String[] columns = new String[]{“Name”, “Age”};


* Constructor with the data type hashmap as parameter.
* @param elementMap
public CellsDataTableMap() {

* Create a ParseXML object (this is where the SAX Parser is) and pass the input XML file.
* The parser will parse the input XML, place the content in a Data object, add each Data
* object to a list and return this list to this caller.
HashMap hm = new HashMap();
hm.put(“Name”, “Roberts”);
hm.put(“Age”, 33);
hm = new HashMap();
hm.put(“Name”, “James”);
hm.put(“Age”, 28);

index = -1;

public String[] getColumns() {
// String[] columns = new String[4];
// columns[0] = “startColumn”;
// columns[1] = “startRow”;
// columns[2] = “endColumn”;
// columns[3] = “endRow”;
return columns;

public int size() {
return this.mapList.size();

public void beforeFirst() {
index = -1;

public Object get(int columnIndex) {
if(index < 0 || index >= this.size()) {
return false;
if(columnIndex > columns.length)
return null;
return get(columns[columnIndex]);

public boolean next() {
index += 1;
if(index >= this.mapList.size()) {
return false;
return true;

* Returns the value of the designated column in the current row.
* @param columnName
* the property name of the POJO.
* @return the value of the designated column in the current row.
public Object get(String columnName) {
HashMap dataMap = (HashMap) this.mapList.get(index);
return dataMap.get(columnName);

public int getCount() {
// TODO Auto-generated method stub
return this.mapList.size();