1
0
Fork 0

Maximale Größe von Spreadsheet (und minimale, dass es immer mindestens 1 Spalte/Zeile hat)

main
Florian Hörner 2024-01-03 15:01:55 +01:00
parent 505f428029
commit 21eefb6d91
4 changed files with 46 additions and 14 deletions

View File

@ -1,4 +1,10 @@
1,2
3,4
5,6
7,8
123,,,,,,,,,1111
1,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,=7*6
,,,,,,,,,=3/2
,,,,,,,,,
,,,,,,,,,
,=41+A2,,,,,,,,
,,,,,,,,,

1 1 123 2 1111
2 3 1 4
3 5 6
4 7 8
5 =7*6
6 =3/2
7
8
9 =41+A2
10

View File

@ -0,0 +1,10 @@
,,,,,,,,,
1,,,,,,,,,
123,,,,,,,,,
,,,,,,,,,
,,,,,,,,,=7*6
,,,,,,,,,=3/2
,,,,,,,,,
,,,,,,,,,
,=41+A2,,,,,,,,
,,,,,,,,,
1
2 1
3 123
4
5 =7*6
6 =3/2
7
8
9 =41+A2
10

View File

@ -12,16 +12,24 @@ public class Axel {
public static void main(String[] args) throws FileNotFoundException {
Spreadsheet spr = new Spreadsheet(10,10);
spr.put("A3", "123");
spr.put("A1", "123");
spr.put("A2", "1");
spr.put("B9", "=41+A2");
spr.put("J5", "=7*6");
spr.put("J6", "=3/2");
spr.put("J10", "1111"); // Das Programm konnte keine Zellen mit 2 Stellen (>9) einlesen! (-> Programm macht es an Stelle 1 statt 10)
System.out.println(spr);
spr.saveCsv("/tmp/test.csv");
spr.saveCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen.csv");
//spr.readCsv("C:\\Users\\flori\\IdeaProjects\\PR1-Spreadsheet\\Axel\\resources\\zahlen2.csv", ',',"A1");
//System.out.println(spr);
// TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods.
}

View File

@ -24,6 +24,18 @@ public class Spreadsheet {
// TODO limit the maximum size on 99 (1..99) rows and 26 (A..Z) columns
if (rows > 99) {
rows = 99;
} else if (rows <= 0) {
rows = 1;
}
if (cols > 26) {
cols = 26;
} else if (cols <= 0) {
cols = 1;
}
cells = new Cell[rows][cols];
for (int r = 0; r < rows; r++)
@ -57,13 +69,9 @@ public class Spreadsheet {
put(getRow(cellName), getCol(cellName), value);
}
private int getCol(String cellName) {
return cellName.charAt(0) - 'A';
}
private int getCol(String cellName) {return cellName.charAt(0) - 'A';}
private int getRow(String cellName) {
return cellName.charAt(1) - '1';
}
private int getRow(String cellName) {return cellName.charAt(1) - '1';}
// -----
// business logic
@ -72,7 +80,7 @@ public class Spreadsheet {
* A method for reading in data from a CSV file.
* @param path The file to read.
* @param separator The char used to split up the input, e.g. a comma or a semicolon.
* @param starCellName The upper left cell where data from the CSV file should be inserted.
* @param startCellName The upper left cell where data from the CSV file should be inserted.
* @return Nothing.
* @exception IOException If path does not exist.
*/