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

Free Support Forum - aspose.com

Bubble chart not working if sheet Name has a whitespace character

Hello,

I’m using the Aspose cells 19.7 version and I can’t create a bubble chart if the sheet name has a white-space character.
when I’m referencing the Xvalues,Yvalues… I’m always using the name of the sheet in addition to the cells range:
chart.getNSeries().get(0).setXValues(sheet.getName() + “!B3:D3”);
Unfortunately this is not working but It did in previous versions like the 7.7 that we had before.

Here is a complete sample example :

Workbook workbook = new Workbook(FileFormatType.XLSX);

    Worksheet sheet = workbook.getWorksheets().get(0);

// setting the sheet name with a whitespace character.
sheet.setName(“ark 10”);

    // Put data

    sheet.getCells().get(0, 0).putValue("Y Values");

    sheet.getCells().get(0, 1).putValue(2);

    sheet.getCells().get(0, 2).putValue(4);

    sheet.getCells().get(0, 3).putValue(6);

    sheet.getCells().get(1, 0).putValue("Bubble Size");

    sheet.getCells().get(1, 1).putValue(1);

    sheet.getCells().get(1, 2).putValue(5);

    sheet.getCells().get(1, 3).putValue(3);

    sheet.getCells().get(2, 0).putValue("X Values");

    sheet.getCells().get(2, 1).putValue(1);

    sheet.getCells().get(2, 2).putValue(2);

    sheet.getCells().get(2, 3).putValue(3);

    // Generate chart

    int chartIndex = sheet.getCharts().add(ChartType.BUBBLE_3_D, 5, 5, 22, 12);

    Chart chart = sheet.getCharts().get(chartIndex);

    // Insert series, set bubble size and x values

    chart.getNSeries().add(sheet.getName() + "!B1:D1", false);

    chart.getNSeries().get(0).setBubbleSizes(sheet.getName() + "!B2:D2");

    chart.getNSeries().get(0).setXValues(sheet.getName() + "!B3:D3");

    // Set a single color the series data points

    chart.getNSeries().setColorVaried(true);

    try {
      workbook.save("C:\\Users\\ARK\\Desktop\\testAspose\\outBubbleChart1.xls");
      System.out.println("OK");
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

@eljuventino,

Since there is space char in worksheet’s name, so you need to put the name in single quotes when specifying the data series, bubble sizes and its x-axis values with respect to specific sheet. See the updated lines of code that you may try, it will work fine as I tested:
e.g
Sample code:

    ......
    // Insert series, set bubble size and x values

    	    chart.getNSeries().add("'" + sheet.getName() + "'!B1:D1", false);

    	    chart.getNSeries().get(0).setBubbleSizes("'" + sheet.getName() + "'!B2:D2");

    	    chart.getNSeries().get(0).setXValues("'" + sheet.getName() + "'!B3:D3");
......

Hope, this helps a bit.