After WorkbookDesigner.process , Chart output null

public static void main(String[] args) throws Exception {

Workbook wb = new Workbook("/Users/admin/Downloads/财务比较分析-test15_3.xlsx");

Worksheet s = wb.getWorksheets().get(“三大报表”);

Cells cells = s.getCells();

ListObject listObject = s.getListObjects().get(0);

String[] names = new String[listObject.getEndColumn() - listObject.getStartColumn() + 1];

int row = listObject.getStartRow() + 1;

for ( int i = listObject.getStartColumn(), idx = 0; i <= listObject.getEndColumn(); i++) {

String v = (String) cells.get(row, i).getValue();

v = v.substring(v.lastIndexOf(’.’) + 1);

names[idx++] = v;

}

Workbook wb2 = new Workbook("/Users/admin/Downloads/财务比较分析-Data.xlsx");

WorkbookDesigner designer = new WorkbookDesigner(wb);

designer.setDataSource(“TAB_回写_null_gaocheng_finance”,

new ListObjectDataCellTable(names, wb2.getWorksheets().get(“三大报表”)));

designer.process();

HtmlSaveOptions options = new HtmlSaveOptions();

options.setHiddenColDisplayType(HtmlHiddenColDisplayType. HIDDEN );

options.setHiddenRowDisplayType(HtmlHiddenRowDisplayType. HIDDEN );

ImageOrPrintOptions imgOptions = options.getImageOptions();

imgOptions.setSaveFormat(SaveFormat. SVG );

wb.save("/Users/admin/Downloads/财务比较分析-test15.html", options);

}

public static class ListObjectDataCellTable implements ICellsDataTable {

private int index = -1;

private ListObject listObject;

private Cells cells;

private String[] names;

public ListObjectDataCellTable(String[] names, Worksheet worksheet) {

this .names = names;

this .cells = worksheet.getCells();

listObject = worksheet.getListObjects().get(0);

}

public void beforeFirst() {

index = listObject.getStartRow();

}

public Object get( int index) {

return cells.get( this .index, index + listObject.getStartColumn()).getValue();

}

public Object get(String name) {

for ( int i = 0; i < names.length; i++) {

if (name.equals(names[i])) {

return cells.get(index, i + listObject.getStartColumn()).getValue();

}

}

return null ;

}

public String[] getColumns() {

return names;

}

public int getCount() {

return listObject.getEndRow() - listObject.getStartRow();

}

public boolean next() {

return ++index <= listObject.getEndRow();

}

}

Chart is empty in output html.

xlsx.zip (62.6 KB)

@xhaixia,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSJAVA-43143 – After WorkbookDesigner.process , Chart output null in HTML

@xhaixia,

Please try our latest version/fix: Aspose.Cells for Java v20.2.6 (attached)

Your issue should bed fixed in it. Please try the following code with template file.
e.g
Sample code:

       for ( int i = listObject.getStartColumn(), idx = 0; i <= listObject.getEndColumn(); i++) 
              {

              String v = (String) cells.get(row, i).getValue();

              v = v.substring(v.lastIndexOf('.') + 1);
              int index = v.indexOf('(');
              if(index != -1)
              {
                     v= v.substring(0,index);
              }
              names[idx++] = v;

In your data source file, all data are string values, we have to convert them to number value, otherwise the chart could not display file. So please add smart marker (numeric) or directly change your template data as number values.

Let us know your feedback.

aspose-cells-20.2.6-java.zip (7.0 MB)
The updated smart marker template file is attached here for your reference:
财务比较分析-test15_3_number.xlsx.zip (16.5 KB)

The issues you have found earlier (filed as CELLSJAVA-43143) have been fixed in Aspose.Cells for Java v20.3. This message was posted using Bugs notification tool by ahsaniqbalsidiqui