-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0000619: Add year in Indicators export monthly table #16
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,8 @@ private void createDetailSheet(final IndicatorDTO indicator) throws Throwable { | |
int rowIndex = -1; | ||
|
||
List<PivotTableData.Axis> leaves = data.getEntryMap().get(indicator.getId()).getRootColumn().getLeaves(); | ||
final List<PivotTableData.Axis> leavesyear | ||
= data.getEntryMap().get(indicator.getId() + 1).getRootColumn().getLeaves(); | ||
int numbOfLeaves = leaves.size(); | ||
int numbOfCols = 4; | ||
|
||
|
@@ -211,16 +213,76 @@ private void createDetailSheet(final IndicatorDTO indicator) throws Throwable { | |
row.getCellByIndex(4).setCellStyleName(null); | ||
|
||
// data entry | ||
//for year row in sheet | ||
String merge = "hello"; | ||
row = tableEx.getRowByIndex(++rowIndex); | ||
int cellIndex = 0; | ||
CalcUtils.putHeader(row, ++cellIndex, "Year"); | ||
Map<String, Integer> columnIndexMapyr = new HashMap<String, Integer>(); | ||
for (PivotTableData.Axis axis : leavesyear) { | ||
CalcUtils.putHeader(row, ++cellIndex, axis.getLabel()); | ||
columnIndexMapyr.put(axis.getLabel(), cellIndex); | ||
if (merge.equals(axis.getLabel()) && cellIndex > 2) { | ||
CalcUtils.mergeCell(tableEx, cellIndex - 1, rowIndex, cellIndex, rowIndex); | ||
} else { | ||
} | ||
merge = axis.getLabel(); | ||
|
||
} | ||
int month = 0; | ||
String completedate = "hello"; | ||
// header | ||
row = tableEx.getRowByIndex(++rowIndex); | ||
int cellIndex = 0; | ||
CalcUtils.putHeader(row, ++cellIndex, data.getLocalizedVersion("sideAndMonth")); | ||
cellIndex = 0; | ||
CalcUtils.putHeader(row, ++cellIndex, "Month"); | ||
Map<String, Integer> columnIndexMap = new HashMap<String, Integer>(); | ||
for (PivotTableData.Axis axis : leaves) { | ||
CalcUtils.putHeader(row, ++cellIndex, axis.getLabel()); | ||
columnIndexMap.put(axis.getLabel(), cellIndex); | ||
if (cellIndex == 2) { | ||
completedate = axis.getLabel(); | ||
} | ||
} | ||
|
||
//for date value | ||
if (completedate.equals("Jan")) { | ||
month = 1; | ||
} else if (completedate.equals("Feb")) { | ||
month = 2; | ||
} else if (completedate.equals("Mar")) { | ||
month = 3; | ||
} else if (completedate.equals("Apr")) { | ||
month = 4; | ||
} else if (completedate.equals("May")) { | ||
month = 5; | ||
} else if (completedate.equals("Jun")) { | ||
month = 6; | ||
} else if (completedate.equals("Jul")) { | ||
month = 7; | ||
} else if (completedate.equals("Aug")) { | ||
month = 8; | ||
} else if (completedate.equals("Sep")) { | ||
month = 9; | ||
} else if (completedate.equals("Oct")) { | ||
month = 10; | ||
} else if (completedate.equals("Nov")) { | ||
month = 11; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do it more safely, like } else if (completeDate.equals("Dec")) {
month = 12;
} else {
throw new IllegalStateException("unable to parse " + completedate);
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, it's quite strange you do that manually, you should be using a date manipulation API (I guess, something like |
||
month = 12; | ||
} | ||
//for year row in sheet | ||
row = tableEx.getRowByIndex(++rowIndex); | ||
cellIndex = 0; | ||
CalcUtils.putHeader(row, ++cellIndex, "Site"); | ||
Map<String, Integer> columnIndexMapcompletedate = new HashMap<String, Integer>(); | ||
for (PivotTableData.Axis axis : leavesyear) { | ||
CalcUtils.putHeader(row, ++cellIndex, month + "." + axis.getLabel()); | ||
columnIndexMapcompletedate.put(axis.getLabel(), cellIndex); | ||
if (month == 12) { | ||
month = 1; | ||
} else { | ||
month++; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A date manipulation API should do that kind of thing for you. You may have a look at something called lenient (see |
||
} | ||
// rows | ||
for (PivotTableData.Axis axis : data.getEntryMap().get(indicator.getId()).getRootRow().getChildren()) { | ||
row = tableEx.getRowByIndex(++rowIndex); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,8 @@ private void createDetailSheet(final IndicatorDTO indicator) { | |
int rowIndex = -1; | ||
|
||
final List<PivotTableData.Axis> leaves = data.getEntryMap().get(indicator.getId()).getRootColumn().getLeaves(); | ||
final List<PivotTableData.Axis> leavesyear = data.getEntryMap().get(indicator.getId() + 1).getRootColumn().getLeaves(); | ||
|
||
int numbOfLeaves = leaves.size(); | ||
int numbOfCols = 4; | ||
|
||
|
@@ -207,17 +209,88 @@ private void createDetailSheet(final IndicatorDTO indicator) { | |
sheetEx.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, 1, numbOfCols)); | ||
|
||
// data entry | ||
//for year above months in indicators | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @manishvishnoi2 : This needs an indentation fix before the pull request can be merged. |
||
int startval = 2; | ||
int endval = 0; | ||
String merge = "hello"; | ||
row = sheetEx.createRow(++rowIndex); | ||
row.setHeightInPoints(defHeight); | ||
int cellIndex = 0; | ||
utils.putHeader(row, ++cellIndex, "Year"); | ||
Map<String, Integer> columnIndexMapyr = new HashMap<String, Integer>(); | ||
for (PivotTableData.Axis axis : leavesyear) { | ||
utils.putHeader(row, ++cellIndex, axis.getLabel()); | ||
columnIndexMapyr.put(axis.getLabel(), cellIndex); | ||
if (cellIndex > 3) { | ||
if (merge.equals(axis.getLabel())) { | ||
|
||
} else { | ||
endval = cellIndex - 1; | ||
sheetEx.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, startval, endval)); | ||
startval = cellIndex; | ||
} | ||
} | ||
sheetEx.addMergedRegion(new CellRangeAddress(rowIndex, rowIndex, startval, cellIndex)); | ||
merge = axis.getLabel(); | ||
|
||
} | ||
// header | ||
int month = 0; | ||
String completedate = "hello"; | ||
row = sheetEx.createRow(++rowIndex); | ||
row.setHeightInPoints(defHeight); | ||
int cellIndex = 0; | ||
utils.putHeader(row, ++cellIndex, data.getLocalizedVersion("sideAndMonth")); | ||
cellIndex = 0; | ||
utils.putHeader(row, ++cellIndex, "month"); | ||
Map<String, Integer> columnIndexMap = new HashMap<String, Integer>(); | ||
for (PivotTableData.Axis axis : leaves) { | ||
utils.putHeader(row, ++cellIndex, axis.getLabel()); | ||
columnIndexMap.put(axis.getLabel(), cellIndex); | ||
if (cellIndex == 2) { | ||
completedate = axis.getLabel(); | ||
} | ||
} | ||
|
||
|
||
if (completedate.equals("Jan")) { | ||
month = 1; | ||
} else if (completedate.equals("Feb")) { | ||
month = 2; | ||
} else if (completedate.equals("Mar")) { | ||
month = 3; | ||
} else if (completedate.equals("Apr")) { | ||
month = 4; | ||
} else if (completedate.equals("May")) { | ||
month = 5; | ||
} else if (completedate.equals("Jun")) { | ||
month = 6; | ||
} else if (completedate.equals("Jul")) { | ||
month = 7; | ||
} else if (completedate.equals("Aug")) { | ||
month = 8; | ||
} else if (completedate.equals("Sep")) { | ||
month = 9; | ||
} else if (completedate.equals("Oct")) { | ||
month = 10; | ||
} else if (completedate.equals("Nov")) { | ||
month = 11; | ||
} else { | ||
month = 12; | ||
} | ||
|
||
//for year row in sheet | ||
row = sheetEx.createRow(++rowIndex); | ||
row.setHeightInPoints(defHeight); | ||
cellIndex = 0; | ||
utils.putHeader(row, ++cellIndex, "Site"); | ||
Map<String, Integer> columnIndexMapcompletedate = new HashMap<String, Integer>(); | ||
for (PivotTableData.Axis axis : leavesyear) { | ||
utils.putHeader(row, ++cellIndex, month + "." + axis.getLabel()); | ||
columnIndexMapcompletedate.put(axis.getLabel(), cellIndex); | ||
if (month == 12) { | ||
month = 1; | ||
} else { | ||
month++; | ||
} | ||
} | ||
// rows | ||
for (PivotTableData.Axis axis : data.getEntryMap().get(indicator.getId()).getRootRow().getChildren()) { | ||
row = sheetEx.createRow(++rowIndex); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, follow java conventions and use
lowerCamelCase
for variable names (completedate
,leavesyear
lacks uppercases)