mercredi 17 juillet 2019

How to model Inter-dependent Worksheet in Java Array?

I want to build two arrays, mimicking two worksheet in Excel.

In the spreadsheet world, let's called it Worksheet1 and Worksheet2.

The value of each cell in Worksheet2 is driven by formula specified in Worksheet2 consuming data from Worksheet1. In other words, if I change the data in Worksheet1, it will change the value in Worksheet2.

And also, some part of the cells in Worksheet2, also inter-dependent due to the formula in Worksheet2. For example, cell A2 in Worksheet2 depends on value from B2 in Worksheet2, and B2 value in Worksheet2 depends on value from B2 in Worksheet1.

In Java, I will have two two-dimensional arrays mimicking each spreadsheet.

Any idea on how best to implement this in Java? 1. Which is the best design pattern to do this so that the O(n) is acceptable? 2. Which is the best algorithm to simulate this structure? The brute force way is I will always need to evaluate the value of each cells of Worksheet2 everytime the data in the cells in Worksheet1 changed. But this will be bad in performance.

Please advise! Thanks!

Aucun commentaire:

Enregistrer un commentaire