private void run() { List<ProjectVariant> variants = Utils.sortVariants(result.getVariants()); List<ImpactCategoryDescriptor> impacts = Utils.sortImpacts(result.getImpactDescriptors()); int row = 1; header(sheet, row++, 1, "LCIA Results"); writeRows(row, variants, impacts); Excel.autoSize(sheet, 1, 4); }
private int writeRows( int row, List<ProjectVariant> variants, List<ImpactCategoryDescriptor> impacts) { for (int i = 0; i < variants.size(); i++) { int col = i + 4; header(sheet, row, col, variants.get(i).getName()); } row++; writeHeader(row++); for (ImpactCategoryDescriptor impact : impacts) { writeInfo(row, impact); ContributionSet<ProjectVariant> contributions = result.getContributions(impact); for (int i = 0; i < variants.size(); i++) { int col = i + 4; ProjectVariant variant = variants.get(i); ContributionItem<?> c = contributions.getContribution(variant); if (c == null) continue; Excel.cell(sheet, row, col, c.getAmount()); } row++; } return row; }
private void header(Sheet sheet, int row, int col, String val) { Excel.cell(sheet, row, col, val).setCellStyle(headerStyle); }
void writeInfo(int row, ImpactCategoryDescriptor impact) { int col = 1; Excel.cell(sheet, row, col++, impact.getRefId()); Excel.cell(sheet, row, col++, impact.getName()); Excel.cell(sheet, row, col++, impact.getReferenceUnit()); }