commit 16c847d8565affa2b651368c7652b82f694c6fb8
Author: mlinha <mlinhac@gmail.com>
Date:   Tue Apr 7 20:26:23 2020 +0200

    re #7781 Created package utils for utility classes and created class Exporter with export to xlsx functionality

diff --git a/pom.xml b/pom.xml
index b4fe59d9..77f883d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -101,8 +101,13 @@
 			<artifactId>orai18n</artifactId>
 			<version>12.1.0.2.0</version>
 		</dependency>
-	</dependencies>
 
+		<dependency>
+			<groupId>org.apache.poi</groupId>
+			<artifactId>poi-ooxml</artifactId>
+			<version>3.17</version>
+		</dependency>
+	</dependencies>
 
 	<build>
 		<plugins>
diff --git a/src/main/java/vldc/aswi/utils/Exporter.java b/src/main/java/vldc/aswi/utils/Exporter.java
new file mode 100644
index 00000000..f2900982
--- /dev/null
+++ b/src/main/java/vldc/aswi/utils/Exporter.java
@@ -0,0 +1,107 @@
+package vldc.aswi.utils;
+
+import org.apache.poi.ss.formula.functions.Column;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * Class used for exporting data to different output files
+ */
+public class Exporter {
+
+    /**
+     * !!!DUMMY!!!
+     * Exports data to .xlsx file
+     * @param tableName name of the table
+     */
+    public static void exportToExcel(String tableName) {
+
+        //temporary dummy implementation, used for testing
+        String[] columns = new String[] {"studuje", "nestuduje"};
+        String[] rows = new String[] {"fav", "fst"};
+        String[] data = new String[] {"1", "2", "3", "4"};
+
+        Workbook workbook = new XSSFWorkbook();
+
+        Sheet sheet = workbook.createSheet(tableName);
+
+        Font colRowNameFont = workbook.createFont();
+        colRowNameFont.setBold(true);
+        colRowNameFont.setFontHeightInPoints((short) 16);
+        colRowNameFont.setColor(IndexedColors.BLACK.getIndex());
+
+        Font dataFont = workbook.createFont();
+        dataFont.setBold(false);
+        dataFont.setFontHeightInPoints((short) 12);
+        dataFont.setColor(IndexedColors.BLACK.getIndex());
+
+        CellStyle colRowStyle = workbook.createCellStyle();
+        colRowStyle.setFont(colRowNameFont);
+
+        CellStyle dataStyle = workbook.createCellStyle();
+        dataStyle.setFont(dataFont);
+
+        Row descRow = sheet.createRow(0);
+
+        for (int i = 0; i < 2; i++) {
+            Cell cell = descRow.createCell(i + 1);
+            cell.setCellValue(columns[i]);
+            cell.setCellStyle(colRowStyle);
+        }
+
+        for (int i = 0; i < 2; i++) {
+            Row row = sheet.createRow(i + 1);
+            Cell nameCell = row.createCell(0);
+            nameCell.setCellValue(rows[i]);
+            nameCell.setCellStyle(colRowStyle);
+
+            Cell cell1 = row.createCell(1);
+            cell1.setCellValue(data[i + i + 1]);
+            cell1.setCellStyle(dataStyle);
+
+            Cell cell2 = row.createCell(2);
+            cell2.setCellValue(data[i + i + 1]);
+            cell2.setCellStyle(dataStyle);
+        }
+
+        for (int i = 0; i < 3; i++) {
+            sheet.autoSizeColumn(i);
+        }
+
+        //merge of columns, will be used for column headers
+        //sheet.addMergedRegion(new CellRangeAddress(0,0,1,2));
+
+        FileOutputStream streamOut = null;
+
+        try {
+            streamOut = new FileOutputStream("out.xlsx");
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            workbook.write(streamOut);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            if (streamOut != null) {
+                streamOut.close();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            workbook.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+}
