Skip to content

Commit

Permalink
Merge pull request #184 from nguyenngoclinhchi/master
Browse files Browse the repository at this point in the history
Modify Excel Util
  • Loading branch information
nguyenngoclinhchi authored Nov 8, 2018
2 parents a11f022 + 8f507c6 commit b162369
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ Format: +
Examples:

* `import dir/C:\Financial_Planner_ALL.xlsx`
* `import dir/C:\ n/Financial_Planner_ALL`
* `import dir/C:\ n/Financial_Planner_All.xlsx`

Please note that User have to add the post-fix `.xlsx` at the end to indicate this is a Excel file.
Expand Down Expand Up @@ -943,6 +944,7 @@ e.g. +
* *Import from Excel file into app* : multiple modes of `import` +
e.g. +
. `import dir/C:\Financial_Planner_ALL.xlsx`
. `import dir/C:\ n/Financial_Planner_ALL`
. `import dir/C:\ n/Financial_Planner_All.xlsx`

* *Archive records into Excel file* : multiple modes of `archive` +
Expand Down
11 changes: 5 additions & 6 deletions docs/team/nguyenngoclinhchi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ A summary of my contributions is given below.
** `Highlights`: This major enhancement was unexpectedly difficult as it requires a in-depth knowledge for the Internal List structure building up the list of records, and pointer when looping through the list and deleting records.
** `My contributions`: I wrote the code for the command, parser, and tests, and modify other classes and codes to adjust when a new command is added.

* *Major enhancements*: Export the records data into
** `Reason for enhancement`:
** `Overview`:
** `Highlights`:
** `My contributions`:

* *Major enhancements*: Export the records data into Excel file
** `Reason for enhancement`: As the user has used the application long time, the memory made up this application will be very large. Hence, it will impose a memory burden on the computer. It would be great that we can archive this data and store them in differen location, like Google Drive, One Drive, ...
** `Overview`: The feature allows users to archive the data in excel file.
** `Highlights`: This major enhancement requires significant effort and time, as initially, the library is not included in Java SDK10. I have to read the documentation as well as learn how to utilize the library in the short time.
** `My contributions`: I created Excel utility that can be used for other Excel related command. This feature have a sophisticated parser as it takes in 6 different modes command and execute different Archive command for each mode.
* *Major enhancements*:
** `Reason for enhancement`:
** `Overview`:
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/seedu/planner/commons/util/ExcelUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public static Boolean checkIfFileOpen (String filePath) {
}
return true;
}

/**
* Check if the first row has the appropriate title.
*/
Expand Down Expand Up @@ -413,7 +414,13 @@ private static void writeDataIntoCell (Row row, int colNum, Object object) {
* Create the fileName path.
*/
public static String setPathFile (String nameFile, String directoryPath) {
return directoryPath + (System.getProperty("file.separator") + nameFile);
String checkedNameFile;

checkedNameFile = (nameFile.length() > 5
&& nameFile.substring(nameFile.length() - 5, nameFile.length()).equals(".xlsx"))
? nameFile : (nameFile + ".xlsx");
logger.info("=----------------------------------------" + checkedNameFile);
return directoryPath + (System.getProperty("file.separator") + checkedNameFile);
}
/**
* Set the name for the Excel file based on type of inputs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public class ImportExcelCommand extends Command {
+ "Parameters: (FILE_PATH) or (DIRECTORY PATH and FILE NAME)\n"
+ "Example 1: " + COMMAND_WORD + " " + PREFIX_DIR
+ DirectoryPath.WORKING_DIRECTORY_STRING + DirectoryPath.FILE_SEPERATOR
+ "Book1.xlsx (MUST end with .xlsx)\n"
+ "Financial_Planner_ALL.xlsx (MUST end with .xlsx)\n"
+ "Example 2: " + COMMAND_WORD + " " + PREFIX_DIR
+ DirectoryPath.WORKING_DIRECTORY_STRING + " " + PREFIX_NAME + " Book1\n";
+ DirectoryPath.WORKING_DIRECTORY_STRING + " " + PREFIX_NAME + " Financial_Planner_ALL.xlsx\n"
+ "Example 3: " + COMMAND_WORD + " " + PREFIX_DIR
+ DirectoryPath.WORKING_DIRECTORY_STRING + " " + PREFIX_NAME + " Financial_Planner_ALL\n";
private String directoryPath;

public ImportExcelCommand(String directoryPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static ImportExcelCommand createImportExcelCommand (String args) throws
directoryPath = ParserUtil.parseDirectoryString(argMultimap.getValue(PREFIX_DIR).get().trim());
checkedDirectoryPath = ParserUtil.parseFilePathString(ExcelUtil.setPathFile(nameFile, directoryPath));
} else {
checkedDirectoryPath = ParserUtil.parseFilePathString(directoryPath);
checkedDirectoryPath = ParserUtil.parseFilePathString(argMultimap.getValue(PREFIX_DIR).get().trim());
}
return new ImportExcelCommand(checkedDirectoryPath);
}
Expand Down

0 comments on commit b162369

Please sign in to comment.