File tree Expand file tree Collapse file tree 17 files changed +1259
-1
lines changed Expand file tree Collapse file tree 17 files changed +1259
-1
lines changed Original file line number Diff line number Diff line change 99import java .lang .annotation .RetentionPolicy ;
1010import java .lang .annotation .Target ;
1111
12+ /**
13+ * This annotation defines the style of the Excel file body when converting a list of objects to an Excel file
14+ * @author Mirko Benincasa
15+ * @since 0.1.0
16+ */
1217@ Retention (RetentionPolicy .RUNTIME )
1318@ Target (ElementType .TYPE )
1419public @interface ExcelBodyStyle {
1520
21+ /**
22+ * @return the background color of the cell. The default is {@code IndexedColors.GREY_25_PERCENT}
23+ */
1624 IndexedColors cellColor () default IndexedColors .GREY_25_PERCENT ;
1725
26+ /**
27+ * @return the horizontal orientation of the text in the cell. The default is {@code HorizontalAlignment.LEFT}
28+ */
1829 HorizontalAlignment horizontal () default HorizontalAlignment .LEFT ;
1930
31+ /**
32+ * @return the vertical orientation of the text in the cell. The default is {@code VerticalAlignment.TOP}
33+ */
2034 VerticalAlignment vertical () default VerticalAlignment .TOP ;
2135}
Original file line number Diff line number Diff line change 55import java .lang .annotation .RetentionPolicy ;
66import java .lang .annotation .Target ;
77
8+ /**
9+ * This annotation defines the header field of the Excel file
10+ * @author Mirko Benincasa
11+ * @since 0.1.0
12+ */
813@ Retention (RetentionPolicy .RUNTIME )
914@ Target (ElementType .FIELD )
1015public @interface ExcelField {
1116
17+ /**
18+ * @return the name of the field written in the header.
19+ */
1220 String name ();
1321}
Original file line number Diff line number Diff line change 99import java .lang .annotation .RetentionPolicy ;
1010import java .lang .annotation .Target ;
1111
12+ /**
13+ * This annotation defines the header style of the Excel file when converting a list of objects to an Excel file
14+ * @author Mirko Benincasa
15+ * @since 0.1.0
16+ */
1217@ Retention (RetentionPolicy .RUNTIME )
1318@ Target (ElementType .TYPE )
1419public @interface ExcelHeaderStyle {
1520
21+ /**
22+ * @return the background color of the cell. The default is {@code IndexedColors.GREY_50_PERCENT}
23+ */
1624 IndexedColors cellColor () default IndexedColors .GREY_50_PERCENT ;
1725
26+ /**
27+ * @return the horizontal orientation of the text in the cell. The default is {@code HorizontalAlignment.LEFT}
28+ */
1829 HorizontalAlignment horizontal () default HorizontalAlignment .LEFT ;
1930
31+ /**
32+ * @return the vertical orientation of the text in the cell. The default is {@code VerticalAlignment.TOP}
33+ */
2034 VerticalAlignment vertical () default VerticalAlignment .TOP ;
2135
36+ /**
37+ * @return {@code true} if the autosize rules should be applied, otherwise {@code false}. The default is {@code false}
38+ */
2239 boolean autoSize () default false ;
2340}
Original file line number Diff line number Diff line change 77import java .util .Arrays ;
88import java .util .Optional ;
99
10+ /**
11+ * This Enum defines the file extensions supported by the library.
12+ * @author Mirko Benincasa
13+ * @since 0.1.0
14+ */
1015@ Getter
1116@ AllArgsConstructor
1217public enum Extension {
1318
19+ /**
20+ * This extension is used for a Microsoft Office spreadsheet up to version 2003
21+ */
1422 XLS ("xls" , "EXCEL" ),
23+
24+ /**
25+ * This extension is used for a Microsoft Office spreadsheet from version 2007 onwards
26+ */
1527 XLSX ("xlsx" , "EXCEL" ),
28+
29+ /**
30+ * This extension is used for CSV (Comma-separated values) files
31+ */
1632 CSV ("csv" , "CSV" );
1733
34+ /**
35+ * The extension's name
36+ */
1837 private final String ext ;
38+
39+ /**
40+ * The extension's type
41+ */
1942 private final String type ;
2043
44+ /**
45+ * This method retrieves the Enum value based on the extension name provided as input
46+ * @param ext the name of an Excel file extension to search for
47+ * @return The Enum value that matches the name provided as input and is of type Excel
48+ * @throws ExtensionNotValidException if no Enum value is found
49+ */
2150 public static Extension getExcelExtension (String ext ) throws ExtensionNotValidException {
2251 Optional <Extension > extensionOptional = Arrays .stream (Extension .values ()).filter (e -> ext .equalsIgnoreCase (e .getExt ()) && e .getType ().equals ("EXCEL" )).findFirst ();
2352 if (extensionOptional .isEmpty ()) {
Original file line number Diff line number Diff line change 11package exceptions ;
22
3+ /**
4+ * This exception signals that the extension is invalid
5+ * @author Mirko Benincasa
6+ * @since 0.1.0
7+ */
38public class ExtensionNotValidException extends Exception {
49
10+ /**
11+ * Constructs an {@code ExtensionNotValidException} with {@code null}
12+ * as its error detail message.
13+ */
514 public ExtensionNotValidException () {
615 super ();
716 }
817
18+ /**
19+ * Constructs an {@code ExtensionNotValidException} with the specified detail message.
20+ *
21+ * @param message
22+ * The detail message (which is saved for later retrieval
23+ * by the {@link #getMessage()} method)
24+ */
925 public ExtensionNotValidException (String message ) {
1026 super (message );
1127 }
1228
29+ /**
30+ * Constructs an {@code ExtensionNotValidException} with the specified detail message
31+ * and cause.
32+ *
33+ * <p> Note that the detail message associated with {@code cause} is
34+ * <i>not</i> automatically incorporated into this exception's detail
35+ * message.
36+ *
37+ * @param message
38+ * The detail message (which is saved for later retrieval
39+ * by the {@link #getMessage()} method)
40+ *
41+ * @param cause
42+ * The cause (which is saved for later retrieval by the
43+ * {@link #getCause()} method). (A null value is permitted,
44+ * and indicates that the cause is nonexistent or unknown.)
45+ */
1346 public ExtensionNotValidException (String message , Throwable cause ) {
1447 super (message , cause );
1548 }
Original file line number Diff line number Diff line change 11package exceptions ;
22
3+ /**
4+ * This exception signals that the file already exists
5+ * @author Mirko Benincasa
6+ * @since 0.1.0
7+ */
38public class FileAlreadyExistsException extends Exception {
49
10+ /**
11+ * Constructs an {@code FileAlreadyExistsException} with the specified detail message.
12+ *
13+ * @param message
14+ * The detail message (which is saved for later retrieval
15+ * by the {@link #getMessage()} method)
16+ */
517 public FileAlreadyExistsException (String message ) {
618 super (message );
719 }
Original file line number Diff line number Diff line change 11package exceptions ;
22
3+ /**
4+ * This exception signals that the file header is missing
5+ * @author Mirko Benincasa
6+ * @since 0.1.0
7+ */
38public class HeaderNotPresentException extends Exception {
49
10+ /**
11+ * Constructs an {@code HeaderNotPresentException} with {@code null}
12+ * as its error detail message.
13+ */
514 public HeaderNotPresentException () {
615 super ();
716 }
817
18+ /**
19+ * Constructs an {@code HeaderNotPresentException} with the specified detail message.
20+ *
21+ * @param message
22+ * The detail message (which is saved for later retrieval
23+ * by the {@link #getMessage()} method)
24+ */
925 public HeaderNotPresentException (String message ) {
1026 super (message );
1127 }
1228
29+ /**
30+ * Constructs an {@code HeaderNotPresentException} with the specified detail message
31+ * and cause.
32+ *
33+ * <p> Note that the detail message associated with {@code cause} is
34+ * <i>not</i> automatically incorporated into this exception's detail
35+ * message.
36+ *
37+ * @param message
38+ * The detail message (which is saved for later retrieval
39+ * by the {@link #getMessage()} method)
40+ *
41+ * @param cause
42+ * The cause (which is saved for later retrieval by the
43+ * {@link #getCause()} method). (A null value is permitted,
44+ * and indicates that the cause is nonexistent or unknown.)
45+ */
1346 public HeaderNotPresentException (String message , Throwable cause ) {
1447 super (message , cause );
1548 }
Original file line number Diff line number Diff line change 11package exceptions ;
22
3+ /**
4+ * This exception signals that an error occurred while opening an Excel file workbook
5+ * @author Mirko Benincasa
6+ * @since 0.1.0
7+ */
38public class OpenWorkbookException extends Exception {
49
10+ /**
11+ * Constructs an {@code OpenWorkbookException} with {@code null}
12+ * as its error detail message.
13+ */
514 public OpenWorkbookException () {
615 super ();
716 }
817
18+ /**
19+ * Constructs an {@code OpenWorkbookException} with the specified detail message.
20+ *
21+ * @param message
22+ * The detail message (which is saved for later retrieval
23+ * by the {@link #getMessage()} method)
24+ */
925 public OpenWorkbookException (String message ) {
1026 super (message );
1127 }
1228
29+ /**
30+ * Constructs an {@code OpenWorkbookException} with the specified detail message
31+ * and cause.
32+ *
33+ * <p> Note that the detail message associated with {@code cause} is
34+ * <i>not</i> automatically incorporated into this exception's detail
35+ * message.
36+ *
37+ * @param message
38+ * The detail message (which is saved for later retrieval
39+ * by the {@link #getMessage()} method)
40+ *
41+ * @param cause
42+ * The cause (which is saved for later retrieval by the
43+ * {@link #getCause()} method). (A null value is permitted,
44+ * and indicates that the cause is nonexistent or unknown.)
45+ */
1346 public OpenWorkbookException (String message , Throwable cause ) {
1447 super (message , cause );
1548 }
Original file line number Diff line number Diff line change 11package exceptions ;
22
3+ /**
4+ * This exception signals that the Excel sheet was not found
5+ * @author Mirko Benincasa
6+ * @since 0.1.0
7+ */
38public class SheetNotFoundException extends Exception {
49
10+ /**
11+ * Constructs an {@code SheetNotFoundException} with {@code null}
12+ * as its error detail message.
13+ */
514 public SheetNotFoundException () {
615 super ();
716 }
817
18+ /**
19+ * Constructs an {@code SheetNotFoundException} with the specified detail message.
20+ *
21+ * @param message
22+ * The detail message (which is saved for later retrieval
23+ * by the {@link #getMessage()} method)
24+ */
925 public SheetNotFoundException (String message ) {
1026 super (message );
1127 }
You can’t perform that action at this time.
0 commit comments