Is there a way to build a data storage app like Microsoft Excel
Anonymous in /c/coding_help
0
report
**Problem:** <br>I'm trying to build a data storage app (like Excel).<br>I want to give the user the ability to create formulas using a cell address. The variables in the formulas will be of type double.<br>I want the user to be able to instantly see the result of the formula while they are typing the formula.<br>I want the user to be able to build formulas with references to any cell on any column and row.<br>**What I tried:**<br>I used a Trie data structure to improve the auto complete when the user is typing the cell address.<br>I call a function to parse the formula and find the cell addresses each time the user types a character.<br>I'm using Java and JavaFX for UI.<br><br>**Example** <br>Suppose I have a cell with the formula "A1+B1".<br>If I swap the text in cells A1 and B1, I want to get the new result without clicking on anything.<br>Is there any efficient way to find the data dependencies between the cells in order to refresh the cell as soon as a dependent cell is changed.<br>I'm struggling to understand what could be the best approach to handle the data updates in the cells.<br>The cells will be reused. Once the user will be done creating the tables, they will be uploaded to a remote server and the cells will be reused.<br><br>**Example use case:**<br>* The app will be used to calculate prices for a service given some variables data.<br>* The app will be used to store and calculate the result of formulas for a big quantity of data (the data will be stored in an ArrayList of doubles).<br><br>**Example code:**<br>```java<br>public class Cell {<br> private static final double NAN = Double.NaN;<br> private static final String DEFAULT_VALUE = "0";<br><br> private String address;<br> private String value;<br> private String formulaValue;<br><br> private Formula formula;<br> private Double result;<br><br> private Cell data;<br><br> private LinkedList<Cell> observers;<br><br> private Cell(String address) {<br> this.address = address;<br> this.observers = new LinkedList<>();<br> this.data = this;<br> }<br><br> public Cell(String address, Cell data) {<br> this.address = address;<br> this.observers = new LinkedList<>();<br> this.data = data;<br> }<br><br> public Cell(String address, String value) {<br> this(address);<br> this.value = value;<br> this.calculateValue();<br> }<br><br> public String getFormula() {<br> return this.formula.toString();<br> }<br><br> public void setFormula(String formula) throws MalformedURLException, Formula.InvalidFormula {<br> this.formula = new Formula(formula);<br> this.calculateValue();<br> }<br>```<br><br>**Disclaimer:** I'm self-taught. I might be missing something basic.<br>**Question:** <br>Is there any efficient way to find the data dependencies between the cells in order to refresh the cell as soon as a dependent cell is changed.<br><br>**EDIT:** The data will be provided by the user. It will be populated from data storage on a server that is not mine. I don't have access to the backend. And I'm not allowed to copy the data to a different data storage.<br>So, I can only fetch the data from the remote server.<br>I will not be able to use any data storage. I have to use any existing data structure that can be implemented using Java.<br>Moreover, I don't have any information on how the server is handling the data.<br>It seems that the data is stored on a database, but I'm not sure.<br>So, I need to only rely on the data that I can fetch from the server.<br>The server is very slow to respond.<br>So, I have to assume that each request to the server to fetch data is time consuming.<br>In other words, I have to consider that is slow.<br>So, if I can avoid to make requests to the server then I have to.<br>That is why I decided to use and ArrayList to store the data.<br>Moreover, I'm not allowed to make any requests to the server if the data is already cached.<br>So, If I want to fetch data A, then I have to evaluate if the data is already on the cache or not.<br>And if it is on the cache, then I have to use the data from the cache instead of fetching it from the remote server.<br>I think that a Trie data structure will be efficient data storage to find data on the cache.
Comments (0) 3 👁️