-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEvent.java
More file actions
73 lines (68 loc) · 2.75 KB
/
Event.java
File metadata and controls
73 lines (68 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package project_A;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
public class Event {
@SuppressWarnings({ "deprecation", "resource", "unused" })
public ObservableList<Table_data> eventAll() throws IOException, URISyntaxException{
InputStream file = new Source().getFile();
ObservableList<Table_data> All = FXCollections.observableArrayList();
XSSFRow row;
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet spreadsheet = workbook.getSheetAt(1);
Iterator < Row > rowIterator = spreadsheet.iterator();
while (rowIterator.hasNext()){
row = (XSSFRow) rowIterator.next();
Iterator < Cell > cellIterator = row.cellIterator();
int x =0; String AR[]=new String[5];
while (x <=4){
Cell cell = row.getCell(x, Row.CREATE_NULL_AS_BLANK);
cell.setCellType(Cell.CELL_TYPE_STRING);
AR[x]=cell.getStringCellValue();
x++;
}
All.add(new Table_data(AR[0],AR[1],AR[2],AR[3],AR[4]));
}
file.close();
return All;
}
@SuppressWarnings({ "resource", "unused", "deprecation" })
public ObservableList<Table_data> eventSearch (String megaString, int x) throws IOException, URISyntaxException {
InputStream file = new Source().getFile();
ObservableList<Table_data> All = FXCollections.observableArrayList();
megaString = megaString.toUpperCase();
x = x-1;
XSSFRow row;
String value;
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet spreadsheet = workbook.getSheetAt(1);
for (int rowIndex = 0; rowIndex <= spreadsheet.getLastRowNum(); rowIndex++) {
row = spreadsheet.getRow(rowIndex);
Cell cell = row.getCell(x, Row.CREATE_NULL_AS_BLANK);
cell.setCellType(Cell.CELL_TYPE_STRING);
value = cell.getStringCellValue();
value = value.toUpperCase();
if(value.contentEquals(megaString)){
Iterator < Cell > cellIterator = row.cellIterator();
int y =0; String AR[]=new String[5];
while (y <=4){
Cell cell2 = row.getCell(y, Row.CREATE_NULL_AS_BLANK);
cell2.setCellType(Cell.CELL_TYPE_STRING);
AR[y]=cell2.getStringCellValue();
y++;
}
All.add(new Table_data(AR[0],AR[1],AR[2],AR[3],AR[4]));
}
}
file.close();
return All;
}
}