forked from hummel/PR1-Spreadsheet
mehr als einstellig Zellen befüllen geht jetzt
(2 kleine Bug fixxes, wenn die länge vom Spreadsheet nicht 1:1 ist)main
parent
ef2ad7511e
commit
c23bcf7113
|
@ -69,9 +69,29 @@ public class Spreadsheet {
|
||||||
put(getRow(cellName), getCol(cellName), value);
|
put(getRow(cellName), getCol(cellName), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCol(String cellName) {return cellName.charAt(0) - 'A';}
|
|
||||||
|
|
||||||
private int getRow(String cellName) {return cellName.charAt(1) - '1';}
|
private int getCol(String cellName) {
|
||||||
|
int merker = 0;
|
||||||
|
for (int i = 0; i < cellName.length(); i++) {
|
||||||
|
if (cellName.charAt(i) >= 'A' && cellName.charAt(i) <= 'Z') {
|
||||||
|
merker = (merker * 10) + (cellName.charAt(i) - ('A'-1));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return merker-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int getRow(String cellName) {
|
||||||
|
int merker = 0;
|
||||||
|
for (int i = 0; i < cellName.length(); i++) {
|
||||||
|
if (!(cellName.charAt(i) >= 'A' && cellName.charAt(i) <= 'Z')) {
|
||||||
|
merker = (merker * 10) + (cellName.charAt(i) - '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return merker-1;
|
||||||
|
}
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// business logic
|
// business logic
|
||||||
|
@ -104,7 +124,7 @@ public class Spreadsheet {
|
||||||
else
|
else
|
||||||
out.print(cell.getValue());
|
out.print(cell.getValue());
|
||||||
|
|
||||||
if (cell != row[cells.length-1])
|
if (cell != row[cells[0].length-1]) // "[0]" -> nimmt sonst die falsche Länge!
|
||||||
out.print(",");
|
out.print(",");
|
||||||
}
|
}
|
||||||
out.println();
|
out.println();
|
||||||
|
@ -190,7 +210,7 @@ public class Spreadsheet {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
for (int i = 0; i < cells.length; i++) {
|
for (int i = 0; i < cells[0].length; i++) { // "[0]" -> nimmt sonst die falsche Länge!
|
||||||
sb.append(" " + (char)('A'+ i) + " | ");
|
sb.append(" " + (char)('A'+ i) + " | ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue