Skip to content

Commit

Permalink
issue: Add issue body, comments when download as xls file
Browse files Browse the repository at this point in the history
See: Yona Github issue #148
  • Loading branch information
doortts committed Mar 13, 2017
1 parent 4015ec2 commit e8631eb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 14 deletions.
50 changes: 36 additions & 14 deletions app/models/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,50 @@ public static byte[] excelFrom(List<Issue> issueList) throws WriteException, IOE
workbook = Workbook.createWorkbook(bos);
sheet = workbook.createSheet(String.valueOf(JodaDateUtil.today().getTime()), 0);

String[] titles = {"No", Messages.get("issue.state"), Messages.get("title"), Messages.get("issue.assignee"), Messages.get("issue.label"), "Created", "Due Date", "Source"};
String[] titles = {"No",
Messages.get("issue.state"),
Messages.get("title"),
Messages.get("issue.assignee"),
Messages.get("issue.content"),
Messages.get("issue.label"),
Messages.get("issue.createdDate"),
Messages.get("issue.dueDate"),
"URL",
Messages.get("common.comment"),
Messages.get("common.comment.author"),
Messages.get("common.comment.created")};

for (int i = 0; i < titles.length; i++) {
sheet.addCell(new jxl.write.Label(i, 0, titles[i], headerCellFormat));
sheet.setColumnView(i, 20);
}
int lineNumber = 0;
for (int idx = 1; idx < issueList.size() + 1; idx++) {
Issue issue = issueList.get(idx - 1);
List<IssueComment> comments = issue.comments;

lineNumber++;
int columnPos = 0;
sheet.addCell(new jxl.write.Label(columnPos++, idx, issue.getNumber().toString(), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, idx, issue.state.toString(), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, idx, issue.title, bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, idx, getAssigneeName(issue.assignee), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, idx, getIssueLabels(issue), bodyCellFormat));
sheet.addCell(new jxl.write.DateTime(columnPos++, idx, issue.createdDate, dateCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, idx, JodaDateUtil.geYMDDate(issue.dueDate), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, idx, controllers.routes.IssueApp.issue(issue.project.owner, issue.project.name, issue.number).toString(), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, issue.getNumber().toString(), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, issue.state.toString(), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, issue.title, bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, getAssigneeName(issue.assignee), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, issue.body, bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, getIssueLabels(issue), bodyCellFormat));
sheet.addCell(new jxl.write.DateTime(columnPos++, lineNumber, issue.createdDate, dateCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, JodaDateUtil.geYMDDate(issue.dueDate), bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos++, lineNumber, controllers.routes.IssueApp.issue(issue.project.owner, issue.project.name, issue.number).toString(), bodyCellFormat));
if (comments.size() > 0) {
for (int j = 0; j < comments.size(); j++) {
sheet.addCell(new jxl.write.Label(columnPos, lineNumber + j, comments.get(j).contents, bodyCellFormat));
sheet.addCell(new jxl.write.Label(columnPos+1, lineNumber + j, comments.get(j).authorName, bodyCellFormat));
sheet.addCell(new jxl.write.DateTime(columnPos + 2, lineNumber + j, comments.get(j).createdDate, dateCellFormat));
}
lineNumber = lineNumber + comments.size() - 1;
}
}
workbook.write();

workbook.write();
try {
workbook.close();
} catch (WriteException | IOException e) {
Expand All @@ -276,7 +300,6 @@ private static WritableCellFormat getDateCellFormat() throws WriteException {
WritableCellFormat cellFormat = new WritableCellFormat(valueFormatDate);
cellFormat.setFont(baseFont);
cellFormat.setShrinkToFit(true);
cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
cellFormat.setAlignment(Alignment.CENTRE);
cellFormat.setVerticalAlignment(VerticalAlignment.TOP);
return cellFormat;
Expand All @@ -289,8 +312,7 @@ private static WritableCellFormat getBodyCellFormat() throws WriteException {

private static WritableCellFormat getBodyCellFormat(WritableFont baseFont) throws WriteException {
WritableCellFormat cellFormat = new WritableCellFormat(baseFont);
cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN);
cellFormat.setWrap(true);
cellFormat.setBorder(Border.NONE, BorderLineStyle.THIN);
cellFormat.setVerticalAlignment(VerticalAlignment.TOP);
return cellFormat;
}
Expand All @@ -299,7 +321,7 @@ private static WritableCellFormat getHeaderCellFormat() throws WriteException {
WritableFont headerFont = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD, false,
UnderlineStyle.NO_UNDERLINE, Colour.BLACK, ScriptStyle.NORMAL_SCRIPT);
WritableCellFormat headerCell = new WritableCellFormat(headerFont);
headerCell.setBorder(Border.ALL, BorderLineStyle.DOUBLE);
headerCell.setBorder(Border.ALL, BorderLineStyle.THIN);
headerCell.setAlignment(Alignment.CENTRE);
return headerCell;
}
Expand Down
2 changes: 2 additions & 0 deletions conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ common.attach.error.upload = Failed to upload. <br>{1} ({0})
common.attach.pastehere = Paste the clipboard image
common.attachment= Attachment
common.comment = Comment
common.comment.author = Comment Author
common.comment.beforeunload.confirm = Would you like to exit this page without submitting comment?
common.comment.delete = Delete comment
common.comment.delete.confirm = Once you delete this comment, you won''t be able to recover it. Are you sure you want to delete this comment?
Expand Down Expand Up @@ -247,6 +248,7 @@ issue.comment.delete.window = Delete issue comment
issue.comment.error.vote = Failed to agree with the comment because server error has occurred.
issue.comment.error.unvote = Failed to disagree with the comment because server error has occurred.
issue.comment.error.have.not.voted = Failed to disagree with the comment because you have not voted this.
issue.content = Issue Content
issue.createdDate = Created date
issue.delete = Delete issue
issue.downloadAsExcel = Download as Excel file
Expand Down
3 changes: 3 additions & 0 deletions conf/messages.ko-KR
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ common.attach.error.upload = 파일 첨부에 실패했습니다.<br>{1} ({0})
common.attach.pastehere = . 클립보드 이미지를 붙여 넣을 수도 있습니다
common.attachment = 첨부파일
common.comment = 댓글
common.comment.author = 댓글 작성자
common.comment.beforeunload.confirm = 입력 중인 댓글이 있습니다. 저장하지 않은 채로 다른 페이지로 이동하시겠습니까?
common.comment.created = 댓글 작성일
common.comment.delete = 댓글 삭제
common.comment.delete.confirm = 해당 댓글이 삭제되면 영원히 복구할 수 없습니다. 그래도 삭제하시겠습니까?
common.comment.edit = 댓글 수정
Expand Down Expand Up @@ -247,6 +249,7 @@ issue.comment.delete.window = 이슈 댓글 삭제
issue.comment.error.vote = 서버 오류가 발생하여 댓글에 공감을 할 수 없습니다.
issue.comment.error.unvote = 서버 오류가 발생하여 댓글에 공감 취소를 할 수 없습니다.
issue.comment.error.have.not.voted = 이 댓글에 공감하지 않아서 공감 취소를 할 수 없습니다.
issue.content = 이슈 본문
issue.createdDate = 작성일
issue.delete = 이슈 삭제
issue.downloadAsExcel = 엑셀파일로 다운받기
Expand Down

0 comments on commit e8631eb

Please sign in to comment.