forked from hummel/PR1-Spreadsheet
Produktrechnung implementiert
parent
9197f30031
commit
bc13be8b44
|
@ -0,0 +1,10 @@
|
|||
=SUMME(C1:E2),,=1,=2,=3,,,,,
|
||||
,,=4,=5,=6,,,,,
|
||||
,,,,=0,,,,,
|
||||
,,,,=0,,,,,
|
||||
,,,,,,,,,
|
||||
,,,,,,,,,
|
||||
,,,,,,,,,
|
||||
,,,,,,,,,
|
||||
,,,,,,,,,
|
||||
,,,,,,,,,
|
|
|
@ -155,8 +155,11 @@ public class Spreadsheet {
|
|||
}
|
||||
|
||||
else if (formula.startsWith("PRODUKT(")) {// e.g. PRODUKT(A3:B9)
|
||||
String[] onlyCells = formula.substring(8, formula.length() - 1).split(":");
|
||||
|
||||
result = "TODO"; // TODO
|
||||
if(checkIfCellExists(onlyCells[0])&&checkIfCellExists(onlyCells[1])) {
|
||||
result = "" + pro(onlyCells[0], onlyCells[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,7 +203,7 @@ public class Spreadsheet {
|
|||
private long pro(String startCellName, String endCellName) {
|
||||
int werte[]=getValues(startCellName,endCellName);
|
||||
|
||||
int produkt=0;
|
||||
int produkt=1;
|
||||
for(int i=0;i<werte.length;i++) {
|
||||
produkt*=werte[i];
|
||||
}
|
||||
|
@ -228,10 +231,12 @@ public class Spreadsheet {
|
|||
int i=0;
|
||||
for (int z = wahreStartZeile; z <= wahreEndZeile; z++) {
|
||||
for (int s = wahreStartSpalte; s <= wahreEndSpalte; s++) {
|
||||
werte[i] = Integer.parseInt(get(z, s));
|
||||
if (!get(z, s).isBlank()) {
|
||||
werte[i] = Integer.parseInt(get(z, s)); // Update the element if it's a number
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return werte;
|
||||
|
|
Loading…
Reference in New Issue