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

Free Support Forum - aspose.com

series.getValues() seriesCollection.getCategoryData() are not thread safe

Workbook wb = new Workbook("c:/BookValues.xlsx");
Chart chart = wb.getWorksheets().get(0).getCharts().get("图表 1");
final Series series = chart.getNSeries().get(0);
final CountDownLatch latch = new CountDownLatch(1);
for (int i = 0; i < 100; i++) {
new Thread() {
public void run() {
try {
latch.await();
} catch (InterruptedException e) {
return;
}
for (int i = 0; i < 10000; i++) {
String v = series.getValues();
if (!v.equals("=Sheet1!$B$2:$B$4")) {
System.out.println(v);
}
}
}
}.start();
}
latch.countDown();



This code will output many difference values.

Hi Xiong,


Thank you for contacting Aspose support.

We have evaluated your presented scenario while using the latest version of Aspose.Cells for Java 8.3.1, and we are able to observe the diverse results for Series.getValue method. We have logged this incident in our bug tracking system under the ticket CELLSJAVA-41139 for further investigation. Please spare us little time to properly analyze this scenario. In the meanwhile, we will keep you posted with updates in this regard.

Hi again,


It is to inform you that we have completed the investigation for the ticket logged earlier as CELLSJAVA-41139. Please note, all data sources of chart related objects are saved in binary data form, and need to be converted in string expression upon calling getValues, getFormula and so on. In order to get the better performance, Aspose.Cells APIs have to cache some information for building formulas globally therefore these calls are not thread safe for accessing such values. You have to synchronize the threads yourself to get formula related values. In fact, we do not think it is a proper solution to access data of one workbook in multi-threaded environment because it is very possible to get concurrent issues for such situations.