1
0
Fork 0

Compare commits

...

3 Commits

9 changed files with 85 additions and 14 deletions

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

6
.idea/misc.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/PR1-Spreadsheet.iml" filepath="$PROJECT_DIR$/PR1-Spreadsheet.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

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.
*/

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Axel/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>