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];
|
||||
}
|
||||
|
@ -226,12 +229,14 @@ public class Spreadsheet {
|
|||
int[] werte = new int[(wahreEndZeile - wahreStartZeile + 1) * (wahreEndSpalte - wahreStartSpalte + 1)];
|
||||
|
||||
int i=0;
|
||||
for(int z=wahreStartZeile;z<=wahreEndZeile;z++) {
|
||||
for(int s=wahreStartSpalte;s<=wahreEndSpalte;s++) {
|
||||
werte[i] = Integer.parseInt(get(z, s));
|
||||
for (int z = wahreStartZeile; z <= wahreEndZeile; z++) {
|
||||
for (int s = wahreStartSpalte; s <= wahreEndSpalte; 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