forked from hummel/PR1-Spreadsheet
Compare commits
3 Commits
505f428029
...
ef2ad7511e
Author | SHA1 | Date |
---|---|---|
Florian Hörner | ef2ad7511e | |
Florian Hörner | 60fc1a9935 | |
Florian Hörner | 21eefb6d91 |
|
@ -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
|
|
@ -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>
|
|
@ -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>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
|
@ -1,4 +1,10 @@
|
||||||
1,2
|
123,,,,,,,,,1111
|
||||||
3,4
|
1,,,,,,,,,
|
||||||
5,6
|
,,,,,,,,,
|
||||||
7,8
|
,,,,,,,,,
|
||||||
|
,,,,,,,,,=7*6
|
||||||
|
,,,,,,,,,=3/2
|
||||||
|
,,,,,,,,,
|
||||||
|
,,,,,,,,,
|
||||||
|
,=41+A2,,,,,,,,
|
||||||
|
,,,,,,,,,
|
||||||
|
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
,,,,,,,,,
|
||||||
|
1,,,,,,,,,
|
||||||
|
123,,,,,,,,,
|
||||||
|
,,,,,,,,,
|
||||||
|
,,,,,,,,,=7*6
|
||||||
|
,,,,,,,,,=3/2
|
||||||
|
,,,,,,,,,
|
||||||
|
,,,,,,,,,
|
||||||
|
,=41+A2,,,,,,,,
|
||||||
|
,,,,,,,,,
|
|
|
@ -12,16 +12,24 @@ public class Axel {
|
||||||
public static void main(String[] args) throws FileNotFoundException {
|
public static void main(String[] args) throws FileNotFoundException {
|
||||||
Spreadsheet spr = new Spreadsheet(10,10);
|
Spreadsheet spr = new Spreadsheet(10,10);
|
||||||
|
|
||||||
spr.put("A3", "123");
|
spr.put("A1", "123");
|
||||||
spr.put("A2", "1");
|
spr.put("A2", "1");
|
||||||
|
|
||||||
spr.put("B9", "=41+A2");
|
spr.put("B9", "=41+A2");
|
||||||
spr.put("J5", "=7*6");
|
spr.put("J5", "=7*6");
|
||||||
spr.put("J6", "=3/2");
|
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);
|
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.
|
// TODO: You might want to put "UI loop" for entering value and formulas here resp. in some UI methods.
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,18 @@ public class Spreadsheet {
|
||||||
|
|
||||||
// TODO limit the maximum size on 99 (1..99) rows and 26 (A..Z) columns
|
// 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];
|
cells = new Cell[rows][cols];
|
||||||
|
|
||||||
for (int r = 0; r < rows; r++)
|
for (int r = 0; r < rows; r++)
|
||||||
|
@ -57,13 +69,9 @@ public class Spreadsheet {
|
||||||
put(getRow(cellName), getCol(cellName), value);
|
put(getRow(cellName), getCol(cellName), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getCol(String cellName) {
|
private int getCol(String cellName) {return cellName.charAt(0) - 'A';}
|
||||||
return cellName.charAt(0) - 'A';
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getRow(String cellName) {
|
private int getRow(String cellName) {return cellName.charAt(1) - '1';}
|
||||||
return cellName.charAt(1) - '1';
|
|
||||||
}
|
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
// business logic
|
// business logic
|
||||||
|
@ -72,7 +80,7 @@ public class Spreadsheet {
|
||||||
* A method for reading in data from a CSV file.
|
* A method for reading in data from a CSV file.
|
||||||
* @param path The file to read.
|
* @param path The file to read.
|
||||||
* @param separator The char used to split up the input, e.g. a comma or a semicolon.
|
* @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.
|
* @return Nothing.
|
||||||
* @exception IOException If path does not exist.
|
* @exception IOException If path does not exist.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue