Example usage for org.apache.poi.ss.usermodel Cell setCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell setCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell setCellValue.

Prototype

void setCellValue(boolean value);

Source Link

Document

Set a boolean value for the cell

Usage

From source file:co.turnus.analysis.data.bottlenecks.io.XlsAlgoBottlenecksDataWriter.java

License:Open Source License

private void writeActorsTable(HSSFWorkbook workbook, HotspotsDataAnalyser analyzer) {
    HSSFSheet sheet = workbook.createSheet("Actors");

    // Actors Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Actors Results");
    title.applyFont(titleFont);//from w  w  w.  j  av  a2 s  . co  m
    cell.setCellValue(title);

    Row row = sheet.createRow(1);
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 0, 0));
    row.createCell(0).setCellValue("Actor");
    sheet.addMergedRegion(new CellRangeAddress(1, 3, 1, 1));
    row.createCell(1).setCellValue("Class");

    sheet.addMergedRegion(new CellRangeAddress(1, 1, 2, 6));
    row.createCell(2).setCellValue("Total Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 7, 11));
    row.createCell(7).setCellValue("Non Deferrable Executions");
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 12, 16));
    row.createCell(12).setCellValue("Critical Executions");

    row = sheet.createRow(2);
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 2, 3));
    row.createCell(2).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 4, 6));
    row.createCell(4).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 7, 8));
    row.createCell(7).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 9, 11));
    row.createCell(9).setCellValue("Clock Cycles");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 12, 13));
    row.createCell(12).setCellValue("Executions");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 14, 16));
    row.createCell(14).setCellValue("Clock Cycles");

    row = sheet.createRow(3);
    row.createCell(2).setCellValue("%");
    row.createCell(3).setCellValue("abs");
    row.createCell(4).setCellValue("%");
    row.createCell(5).setCellValue("mean");
    row.createCell(6).setCellValue("variance");
    row.createCell(7).setCellValue("%");
    row.createCell(8).setCellValue("abs");
    row.createCell(9).setCellValue("%");
    row.createCell(10).setCellValue("mean");
    row.createCell(11).setCellValue("variance");
    row.createCell(12).setCellValue("%");
    row.createCell(13).setCellValue("abs");
    row.createCell(14).setCellValue("%");
    row.createCell(15).setCellValue("mean");
    row.createCell(16).setCellValue("variance");

    Map<Actor, ExtendExecData> aMap = analyzer.getSumDataMap(Actor.class, Key.CRITICAL_CLOCKCYCLES,
            Order.DECREASING);

    // row index
    int rowi = 4;
    for (Entry<Actor, ExtendExecData> entry : aMap.entrySet()) {
        Actor actor = entry.getKey();
        ExtendExecData exec = entry.getValue();

        row = sheet.createRow(rowi);
        rowi++;

        row.createCell(0).setCellValue(actor.getId());
        row.createCell(1).setCellValue(actor.getActorClass().getName());
        cell = row.createCell(2);
        cell.setCellFormula("D" + rowi + "/Summary!A14*100");
        row.createCell(3).setCellValue(exec.getTotalExec().getExecutions());
        cell = row.createCell(4);
        cell.setCellFormula("F" + rowi + "/Summary!B14*100");
        row.createCell(5).setCellValue(exec.getTotalExec().getClockCyclesMean());
        row.createCell(6).setCellValue(exec.getTotalExec().getClockCyclesVariance());
        cell = row.createCell(7);
        cell.setCellFormula("I" + rowi + "/Summary!E14*100");
        row.createCell(8).setCellValue(exec.getNotDeferrableExec().getExecutions());
        cell = row.createCell(9);
        cell.setCellFormula("K" + rowi + "/Summary!G14*100");
        row.createCell(10).setCellValue(exec.getNotDeferrableExec().getClockCyclesMean());
        row.createCell(11).setCellValue(exec.getNotDeferrableExec().getClockCyclesVariance());
        cell = row.createCell(12);
        cell.setCellFormula("N" + rowi + "/Summary!J14*100");
        row.createCell(13).setCellValue(exec.getCriticalExec().getExecutions());
        cell = row.createCell(14);
        cell.setCellFormula("P" + rowi + "/Summary!L14*100");
        row.createCell(15).setCellValue(exec.getCriticalExec().getClockCyclesMean());
        row.createCell(16).setCellValue(exec.getCriticalExec().getClockCyclesVariance());

    }

}

From source file:co.turnus.analysis.data.bottlenecks.io.XlsAlgoBottlenecksDataWriter.java

License:Open Source License

private void writeImpactAnalysis(HSSFWorkbook workbook, ImpactData impact) {
    HSSFSheet sheet = workbook.createSheet("Impact Analysis");

    // Impact Analysis Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Impact analysis");
    title.applyFont(titleFont);/*from   w  ww .j a va  2  s.  c o  m*/
    cell.setCellValue(title);

    int colli = 0;
    Map<Integer, Row> rowsMap = new HashMap<Integer, Row>();
    for (ActionImpactData step : impact.getActionsData()) {
        // action row
        Row row = rowsMap.get(1);
        if (row == null) {
            row = sheet.createRow(1);
            rowsMap.put(1, row);
        }
        row.createCell(colli).setCellValue("Action");
        row.createCell(colli + 1).setCellValue(step.getAction().getId());

        // actor or actor class row
        row = rowsMap.get(2);
        if (row == null) {
            row = sheet.createRow(2);
            rowsMap.put(2, row);
        }
        if (impact.isActorsLevel()) {
            row.createCell(colli).setCellValue("Actor");
            row.createCell(colli + 1).setCellValue(step.getActors().get(0).getId());
        } else {
            row.createCell(colli).setCellValue("ActorClass");
            row.createCell(colli + 1).setCellValue(step.getActors().get(0).getActorClass().getName());
        }

        // reductions row
        row = rowsMap.get(3);
        if (row == null) {
            row = sheet.createRow(3);
            rowsMap.put(3, row);
        }
        row.createCell(colli).setCellValue("WL reduction");
        row.createCell(colli + 1).setCellValue("CP WL reduction");
        for (int i = 0; i < step.getCplReduction().size(); i++) {
            double wl = step.getWlReduction().get(i);
            double cp = step.getCplReduction().get(i);
            row = rowsMap.get(4 + i);
            if (row == null) {
                row = sheet.createRow(4 + i);
                rowsMap.put(4 + i, row);
            }
            row.createCell(colli).setCellValue(wl);
            row.createCell(colli + 1).setCellValue(cp);
        }

        colli += 2;
    }

}

From source file:co.turnus.analysis.data.bottlenecks.io.XlsAlgoBottlenecksDataWriter.java

License:Open Source License

private void writeSummary(HSSFWorkbook workbook, Network network, HotspotsDataAnalyser analyzer) {
    HSSFSheet sheet = workbook.createSheet("Summary");

    // Network Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Hotspots and Algorithmic Bottlenecks Report Summary");
    title.applyFont(titleFont);//from w  w w . j  a v  a 2s  .c  o  m
    cell.setCellValue(title);

    // network name
    Row row = sheet.createRow(2);
    row.createCell(0).setCellValue("Network");
    row.createCell(1).setCellValue(network.getName());

    // network cal project
    row = sheet.createRow(3);
    row.createCell(0).setCellValue("CAL Project");
    row.createCell(1).setCellValue(network.getCalProject());

    // network source file
    row = sheet.createRow(4);
    row.createCell(0).setCellValue("Source File");
    row.createCell(1).setCellValue(network.getSourceFile());

    // network version
    sheet.addMergedRegion(new CellRangeAddress(5, 7, 0, 0));
    row = sheet.createRow(5);
    row.createCell(0).setCellValue("Version");
    row.createCell(1).setCellValue("Id");
    row.createCell(2).setCellValue(network.getVersion().getId());
    row = sheet.createRow(6);
    row.createCell(1).setCellValue("Last Modification Date");
    cell = row.createCell(2);
    cell.setCellValue(network.getVersion().getLastModificationDate());
    cell.setCellStyle(cellStyle);
    row = sheet.createRow(7);
    row.createCell(1).setCellValue("Versioning Date");
    cell = row.createCell(2);
    cell.setCellValue(network.getVersion().getVersioningDate());
    cell.setCellStyle(cellStyle);

    // [total | non deferrable | critical]
    row = sheet.createRow(10);
    sheet.addMergedRegion(new CellRangeAddress(10, 10, 0, 2));
    cell = row.createCell(0);
    cell.setCellValue("Total Executions");

    sheet.addMergedRegion(new CellRangeAddress(10, 10, 3, 7));
    cell = row.createCell(3);
    cell.setCellValue("Non Deferrable Executions");

    sheet.addMergedRegion(new CellRangeAddress(10, 10, 8, 12));
    cell = row.createCell(8);
    cell.setCellValue("Critical Executions");

    // [Executions | Workload | slack || Executions | workload || Executions
    // | workload ]
    row = sheet.createRow(11);
    sheet.addMergedRegion(new CellRangeAddress(11, 12, 0, 0));
    cell = row.createCell(0);
    cell.setCellValue("Executions");

    sheet.addMergedRegion(new CellRangeAddress(11, 11, 1, 2));
    cell = row.createCell(1);
    cell.setCellValue("Clock Cycles");

    sheet.addMergedRegion(new CellRangeAddress(11, 11, 3, 4));
    cell = row.createCell(3);
    cell.setCellValue("Executions");

    sheet.addMergedRegion(new CellRangeAddress(11, 11, 5, 7));
    cell = row.createCell(5);
    cell.setCellValue("Clock Cycles");

    sheet.addMergedRegion(new CellRangeAddress(11, 11, 8, 9));
    cell = row.createCell(8);
    cell.setCellValue("Executions");

    sheet.addMergedRegion(new CellRangeAddress(11, 11, 10, 12));
    cell = row.createCell(10);
    cell.setCellValue("Clock Cycles");

    // [* | mean , variance, % ... ]
    row = sheet.createRow(12);
    row.createCell(1).setCellValue("mean");
    row.createCell(2).setCellValue("variance");
    row.createCell(3).setCellValue("%");
    row.createCell(4).setCellValue("abs");
    row.createCell(5).setCellValue("%");
    row.createCell(6).setCellValue("mean");
    row.createCell(7).setCellValue("variance");
    row.createCell(8).setCellValue("%");
    row.createCell(9).setCellValue("abs");
    row.createCell(10).setCellValue("%");
    row.createCell(11).setCellValue("mean");
    row.createCell(12).setCellValue("variance");

    // write down data
    ExtendExecData sumData = analyzer.getSumData();
    row = sheet.createRow(13);

    row.createCell(0).setCellValue(sumData.getTotalExec().getExecutions());
    row.createCell(1).setCellValue(sumData.getTotalExec().getClockCyclesMean());
    row.createCell(2).setCellValue(sumData.getTotalExec().getClockCyclesVariance());
    cell = row.createCell(3);
    cell.setCellFormula("E14/A14*100");
    row.createCell(4).setCellValue(sumData.getNotDeferrableExec().getExecutions());
    cell = row.createCell(5);
    cell.setCellFormula("G14/B14*100");
    row.createCell(6).setCellValue(sumData.getNotDeferrableExec().getClockCyclesMean());
    row.createCell(7).setCellValue(sumData.getNotDeferrableExec().getClockCyclesVariance());
    cell = row.createCell(8);
    cell.setCellFormula("J14/A14*100");
    row.createCell(9).setCellValue(sumData.getCriticalExec().getExecutions());
    cell = row.createCell(10);
    cell.setCellFormula("L14/B14*100");
    row.createCell(11).setCellValue(sumData.getCriticalExec().getClockCyclesMean());
    row.createCell(12).setCellValue(sumData.getCriticalExec().getClockCyclesVariance());
}

From source file:co.turnus.analysis.data.buffers.io.XlsBufferMinimizationDataWriter.java

License:Open Source License

private void writeData(HSSFWorkbook workbook, BuffersData data, Network netork, String algorithm,
        int solutionId) {
    HSSFSheet sheet = workbook.createSheet("Solution " + solutionId);

    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString(algorithm + " Results");
    title.applyFont(titleFont);//  w w w.  j  a va  2 s .co m
    cell.setCellValue(title);

    Row row = sheet.createRow(3);
    sheet.addMergedRegion(new CellRangeAddress(3, 3, 0, 3));
    row.createCell(0).setCellValue("Algorithm specific Parameters");
    row = sheet.createRow(4);
    int cellNum = 0;
    for (String attrName : data.getKeyAttributes()) {
        row.createCell(cellNum++).setCellValue(attrName);
        Object val = data.getAttribute(attrName);
        row.createCell(cellNum++).setCellValue(val.toString());
    }

    row = sheet.createRow(1);
    sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 5));
    row.createCell(0).setCellValue("Generic Parameters");
    row = sheet.createRow(2);
    row.createCell(0).setCellValue("Total bits");
    row.createCell(1).setCellValue(data.getTotalBitSize());
    row.createCell(2).setCellValue("Total Tokens");
    row.createCell(3).setCellValue(data.getTotalTokenSize());
    row.createCell(4).setCellValue("Solution Time (ms)");
    row.createCell(5).setCellValue(data.getExecutionTime());
    row.createCell(6).setCellValue("number of Actors");
    row.createCell(7).setCellValue(netork.getActors().size());
    row.createCell(8).setCellValue("number of Fifos");
    row.createCell(9).setCellValue(netork.getFifos().size());
    row.createCell(10).setCellValue("bit accurate");
    row.createCell(11).setCellValue(data.isBitAccurate());
    row.createCell(12).setCellValue("deadlock free");
    row.createCell(13).setCellValue(data.isDeadlockFree());

    row = sheet.createRow(5);
    sheet.addMergedRegion(new CellRangeAddress(5, 5, 0, 6));
    row.createCell(0).setCellValue("Buffers Size Configuration");
    row = sheet.createRow(6);
    sheet.addMergedRegion(new CellRangeAddress(6, 7, 0, 0));
    row.createCell(0).setCellValue("Source Actor");
    sheet.addMergedRegion(new CellRangeAddress(6, 7, 1, 1));
    row.createCell(1).setCellValue("Source Port");
    sheet.addMergedRegion(new CellRangeAddress(6, 7, 2, 2));
    row.createCell(2).setCellValue("Traget Actor");
    sheet.addMergedRegion(new CellRangeAddress(6, 7, 3, 4));
    row.createCell(3).setCellValue("Traget Port");
    sheet.addMergedRegion(new CellRangeAddress(6, 7, 4, 4));
    row.createCell(4).setCellValue("Type");
    sheet.addMergedRegion(new CellRangeAddress(6, 6, 5, 6));
    row.createCell(5).setCellValue("Size");
    sheet.addMergedRegion(new CellRangeAddress(6, 6, 8, 9));
    row.createCell(8).setCellValue("Algorithm Starting Point");
    row = sheet.createRow(7);
    row.createCell(5).setCellValue("bit");
    row.createCell(6).setCellValue("tokens");
    row.createCell(8).setCellValue("bit");
    row.createCell(9).setCellValue("tokens");

    int rowi = 8;
    for (Entry<Fifo, Integer> entry : data.getFifosSize().getFifosSizeMap().entrySet()) {
        Fifo fifo = entry.getKey();
        int tokens = entry.getValue();

        row = sheet.createRow(rowi++);
        row.createCell(0).setCellValue(fifo.getSourceActor().getId());
        row.createCell(1).setCellValue(fifo.getSourcePort().getName());
        row.createCell(2).setCellValue(fifo.getTargetActor().getId());
        row.createCell(3).setCellValue(fifo.getTargetPort().getName());
        row.createCell(4).setCellValue(fifo.getType().toString());
        row.createCell(5).setCellValue(tokens * fifo.getType().getBits());
        row.createCell(6).setCellValue(tokens);

        // do the same for the starting point (if it exists)
        tokens = data.getStartingPoint().containsKey(fifo) ? data.getStartingPoint().get(fifo) : 0;
        row.createCell(8).setCellValue(tokens * fifo.getType().getBits());
        row.createCell(9).setCellValue(tokens);
    }

}

From source file:co.turnus.analysis.data.partitioning.io.XlsPartitioningDataWriter.java

License:Open Source License

private void writeData(HSSFWorkbook workbook, PartitionsData data, Network network, String algorithm,
        int solutionId) {
    HSSFSheet sheet = workbook.createSheet("Partition " + solutionId);

    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString(algorithm + " Results");
    title.applyFont(titleFont);/*from  w  w w.  j a  va2  s . co m*/
    cell.setCellValue(title);

    Row row = sheet.createRow(3);
    sheet.addMergedRegion(new CellRangeAddress(3, 3, 0, 3));
    row.createCell(0).setCellValue("Algorithm specific Parameters");
    row = sheet.createRow(4);
    int cellNum = 0;
    for (String attrName : data.getKeyAttributes()) {
        row.createCell(cellNum++).setCellValue(attrName);
        Object val = data.getAttribute(attrName);
        row.createCell(cellNum++).setCellValue(val.toString());
    }

    row = sheet.createRow(5);
    sheet.addMergedRegion(new CellRangeAddress(5, 5, 0, 1));
    row.createCell(0).setCellValue("Partitions");

    row = sheet.createRow(6);
    row.createCell(0).setCellValue("id");
    row.createCell(1).setCellValue("Actors");

    int rown = 7;
    row = sheet.createRow(rown);
    for (ActorsMapping p : data.getMapping().getActorsMappings()) {
        row.createCell(0).setCellValue(p.getId());
        for (Actor a : p.getActors()) {
            row.createCell(1).setCellValue(a.getId());
            row = sheet.createRow(++rown);
        }
    }

}

From source file:co.turnus.analysis.data.pipelining.io.XlsSimplePipeliningDataWriter.java

License:Open Source License

public void write(SimplePipelingData report, File file) {
    try {// www. j a  v a2s . c  o m

        HSSFWorkbook workbook = new HSSFWorkbook();

        titleFont = workbook.createFont();
        titleFont.setFontName("Arial");
        titleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

        cellStyle = workbook.createCellStyle();
        cellStyle.setDataFormat(workbook.getCreationHelper().createDataFormat().getFormat("m/d/yy h:mm"));

        HSSFSheet sheet = workbook.createSheet("Pipelinable <Actor, Action>");
        // Action Actor Class Results
        Cell cell = sheet.createRow(0).createCell(0);
        HSSFRichTextString title = new HSSFRichTextString("Action and Actor Pipelining Results");
        title.applyFont(titleFont);
        cell.setCellValue(title);

        Row row = sheet.createRow(1);
        sheet.addMergedRegion(new CellRangeAddress(1, 3, 0, 0));
        row.createCell(0).setCellValue("Actor");
        sheet.addMergedRegion(new CellRangeAddress(1, 3, 1, 1));
        row.createCell(1).setCellValue("Action");
        sheet.addMergedRegion(new CellRangeAddress(1, 3, 2, 2));
        row.createCell(2).setCellValue("pipelinable");
        sheet.addMergedRegion(new CellRangeAddress(1, 1, 3, 10));
        row.createCell(3).setCellValue("Consecutive Executions");
        sheet.addMergedRegion(new CellRangeAddress(1, 3, 11, 11));
        row.createCell(11).setCellValue("Splittable Actions");

        row = sheet.createRow(2);
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 3, 6));
        row.createCell(3).setCellValue("Pipelinable");
        sheet.addMergedRegion(new CellRangeAddress(2, 2, 7, 10));
        row.createCell(7).setCellValue("Unconstrained");
        row = sheet.createRow(3);
        row.createCell(3).setCellValue("min");
        row.createCell(4).setCellValue("mean");
        row.createCell(5).setCellValue("max");
        row.createCell(6).setCellValue("var");
        row.createCell(7).setCellValue("min");
        row.createCell(8).setCellValue("mean");
        row.createCell(9).setCellValue("max");
        row.createCell(10).setCellValue("var");

        int rowId = 4;
        Map<Actor, Map<Action, SimpleActionPipeliningData>> table = report.asTable().rowMap();
        for (Map<Action, SimpleActionPipeliningData> ac : table.values()) {
            for (SimpleActionPipeliningData data : ac.values()) {
                row = sheet.createRow(rowId);
                row.createCell(0).setCellValue(data.getActor().getId());
                row.createCell(1).setCellValue(data.getAction().getId());

                row.createCell(2).setCellValue(data.isPipelinable());

                StatisticalData stat = data.getPipelinableRepetitions();
                if (stat.getSamples() > 0) {
                    row.createCell(3).setCellValue(stat.getMin());
                    row.createCell(4).setCellValue(stat.getMean());
                    row.createCell(5).setCellValue(stat.getMax());
                    row.createCell(6).setCellValue(stat.getVariance());
                } else {
                    row.createCell(3).setCellValue("-");
                    row.createCell(4).setCellValue("-");
                    row.createCell(5).setCellValue("-");
                    row.createCell(6).setCellValue("-");
                }

                stat = data.getUnconstrainedRepetitions();
                if (stat.getSamples() > 0) {
                    row.createCell(7).setCellValue(stat.getMin());
                    row.createCell(8).setCellValue(stat.getMean());
                    row.createCell(9).setCellValue(stat.getMax());
                    row.createCell(10).setCellValue(stat.getVariance());
                } else {
                    row.createCell(7).setCellValue("-");
                    row.createCell(8).setCellValue("-");
                    row.createCell(9).setCellValue("-");
                    row.createCell(10).setCellValue("-");
                }

                StringBuffer b = new StringBuffer();
                for (Action action : data.getSplittableActions()) {
                    b.append(action.getId()).append(" ");
                }
                row.createCell(11).setCellValue(b.toString());

                rowId++;
            }
        }

        OutputStream out = new FileOutputStream(file);
        out = new BufferedOutputStream(out);
        workbook.write(out);
        out.close();

    } catch (Exception e) {
        throw new TurnusRuntimeException("Error writing the excel file " + file, e.getCause());
    }
}

From source file:co.turnus.profiling.io.XlsHalsteadAnalysisWriter.java

License:Open Source License

private void writeActorClassesTable(HSSFWorkbook workbook, SourceCodeData report) {
    int sheetNumber = 0;
    for (ActorClassStaticData aData : report.getActorsData()) {
        HalsteadAnalyser a = new HalsteadAnalyser(aData);
        String aClass = aData.getActorClass().getName();

        HSSFSheet sheet = workbook.createSheet("Class n." + sheetNumber++);
        // Action Actor Class Results
        Cell cell = sheet.createRow(0).createCell(0);
        HSSFRichTextString title = new HSSFRichTextString("Halstead Analysis for the Actor Class: " + aClass);
        title.applyFont(titleFont);//from   w  w w.j  ava2  s  . c  o  m
        cell.setCellValue(title);

        Row row = sheet.createRow(2);
        row.createCell(0).setCellValue("Summary");
        row.createCell(1).setCellValue("n1");
        row.createCell(2).setCellValue("n2");
        row.createCell(3).setCellValue("n");
        row.createCell(4).setCellValue("N1");
        row.createCell(5).setCellValue("N2");
        row.createCell(6).setCellValue("N");
        row.createCell(7).setCellValue("cN");
        row.createCell(8).setCellValue("V");
        row.createCell(9).setCellValue("D");
        row.createCell(10).setCellValue("E");
        row.createCell(11).setCellValue("T");
        row.createCell(12).setCellValue("B");
        row.createCell(13).setCellValue("I");
        row.createCell(14).setCellValue("NoL");

        row = sheet.createRow(3);
        row.createCell(1).setCellValue(a.getn1());
        row.createCell(2).setCellValue(a.getn2());
        row.createCell(3).setCellValue(a.getn());
        row.createCell(4).setCellValue(a.getN1());
        row.createCell(5).setCellValue(a.getN2());
        row.createCell(6).setCellValue(a.getN());
        row.createCell(7).setCellValue(a.getcN());
        row.createCell(8).setCellValue(a.getV());
        row.createCell(9).setCellValue(a.getD());
        row.createCell(10).setCellValue(a.getE());
        row.createCell(11).setCellValue(a.getT());
        row.createCell(12).setCellValue(a.getB());
        row.createCell(13).setCellValue(a.getI());
        row.createCell(14).setCellValue(aData.getNumberOfLines());

        int i = 5;
        row = sheet.createRow(i++);
        row.createCell(0).setCellValue("Action");
        row.createCell(1).setCellValue("n1");
        row.createCell(2).setCellValue("n2");
        row.createCell(3).setCellValue("n");
        row.createCell(4).setCellValue("N1");
        row.createCell(5).setCellValue("N2");
        row.createCell(6).setCellValue("N");
        row.createCell(7).setCellValue("cN");
        row.createCell(8).setCellValue("V");
        row.createCell(9).setCellValue("D");
        row.createCell(10).setCellValue("E");
        row.createCell(11).setCellValue("T");
        row.createCell(12).setCellValue("B");
        row.createCell(13).setCellValue("I");
        for (ActionStaticData actionData : aData.getActionsData()) {
            a = new HalsteadAnalyser(actionData);
            row = sheet.createRow(i++);
            row.createCell(0).setCellValue(actionData.getAction().getId());
            row.createCell(1).setCellValue(a.getn1());
            row.createCell(2).setCellValue(a.getn2());
            row.createCell(3).setCellValue(a.getn());
            row.createCell(4).setCellValue(a.getN1());
            row.createCell(5).setCellValue(a.getN2());
            row.createCell(6).setCellValue(a.getN());
            row.createCell(7).setCellValue(a.getcN());
            row.createCell(8).setCellValue(a.getV());
            row.createCell(9).setCellValue(a.getD());
            row.createCell(10).setCellValue(a.getE());
            row.createCell(11).setCellValue(a.getT());
            row.createCell(12).setCellValue(a.getB());
            row.createCell(13).setCellValue(a.getI());
        }

        /*
         * i++; row = sheet.createRow(i++);
         * row.createCell(0).setCellValue("Procedure");
         * row.createCell(1).setCellValue("n1");
         * row.createCell(2).setCellValue("n2");
         * row.createCell(3).setCellValue("n");
         * row.createCell(4).setCellValue("N1");
         * row.createCell(5).setCellValue("N2");
         * row.createCell(6).setCellValue("N");
         * row.createCell(7).setCellValue("cN");
         * row.createCell(8).setCellValue("V");
         * row.createCell(9).setCellValue("D");
         * row.createCell(10).setCellValue("E");
         * row.createCell(11).setCellValue("T");
         * row.createCell(12).setCellValue("B");
         * row.createCell(13).setCellValue("I");
         * 
         * for (ProcedureStaticData pData : aData.getProceduresData()) { a =
         * new HalsteadAnalyser(pData); row = sheet.createRow(i++);
         * row.createCell(0).setCellValue(pData.getProcedure().getName());
         * row.createCell(1).setCellValue(a.getn1());
         * row.createCell(2).setCellValue(a.getn2());
         * row.createCell(3).setCellValue(a.getn());
         * row.createCell(4).setCellValue(a.getN1());
         * row.createCell(5).setCellValue(a.getN2());
         * row.createCell(6).setCellValue(a.getN());
         * row.createCell(7).setCellValue(a.getcN());
         * row.createCell(8).setCellValue(a.getV());
         * row.createCell(9).setCellValue(a.getD());
         * row.createCell(10).setCellValue(a.getE());
         * row.createCell(11).setCellValue(a.getT());
         * row.createCell(12).setCellValue(a.getB());
         * row.createCell(13).setCellValue(a.getI()); }
         */
    }

}

From source file:co.turnus.profiling.io.XlsHalsteadAnalysisWriter.java

License:Open Source License

private void writeSummary(HSSFWorkbook workbook, Network network, SourceCodeData report) {
    BasicStaticData networkData = ProfilingFactory.eINSTANCE.createBasicStaticData();

    for (ActorClassStaticData aData : report.getActorsData()) {
        StaticDataUtil.merge(networkData, aData);
    }/*from   w ww.  j ava2  s  .co  m*/

    HalsteadAnalyser a = new HalsteadAnalyser(networkData);
    HSSFSheet sheet = workbook.createSheet("Halstead Summary");
    // Action Actor Class Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Halstead Analysis: Network and Actor Classes");
    title.applyFont(titleFont);
    cell.setCellValue(title);

    Row row = sheet.createRow(1);
    row.createCell(0).setCellValue("Network");
    row = sheet.createRow(2);
    row.createCell(0).setCellValue("n1");
    row.createCell(1).setCellValue("n2");
    row.createCell(2).setCellValue("n");
    row.createCell(3).setCellValue("N1");
    row.createCell(4).setCellValue("N2");
    row.createCell(5).setCellValue("N");
    row.createCell(6).setCellValue("cN");
    row.createCell(7).setCellValue("V");
    row.createCell(8).setCellValue("D");
    row.createCell(9).setCellValue("E");
    row.createCell(10).setCellValue("T");
    row.createCell(11).setCellValue("B");
    row.createCell(12).setCellValue("I");
    row.createCell(13).setCellValue("NoL");
    row = sheet.createRow(3);
    row.createCell(0).setCellValue(a.getn1());
    row.createCell(1).setCellValue(a.getn2());
    row.createCell(2).setCellValue(a.getn());
    row.createCell(3).setCellValue(a.getN1());
    row.createCell(4).setCellValue(a.getN2());
    row.createCell(5).setCellValue(a.getN());
    row.createCell(6).setCellValue(a.getcN());
    row.createCell(7).setCellValue(a.getV());
    row.createCell(8).setCellValue(a.getD());
    row.createCell(9).setCellValue(a.getE());
    row.createCell(10).setCellValue(a.getT());
    row.createCell(11).setCellValue(a.getB());
    row.createCell(12).setCellValue(a.getI());
    row.createCell(13).setCellValue(networkData.getNumberOfLines());

    row = sheet.createRow(5);
    row.createCell(0).setCellValue("Actor Class");
    row.createCell(1).setCellValue("n1");
    row.createCell(2).setCellValue("n2");
    row.createCell(3).setCellValue("n");
    row.createCell(4).setCellValue("N1");
    row.createCell(5).setCellValue("N2");
    row.createCell(6).setCellValue("N");
    row.createCell(7).setCellValue("cN");
    row.createCell(8).setCellValue("V");
    row.createCell(9).setCellValue("D");
    row.createCell(10).setCellValue("E");
    row.createCell(11).setCellValue("T");
    row.createCell(12).setCellValue("B");
    row.createCell(13).setCellValue("I");
    row.createCell(14).setCellValue("NoL");

    int i = 6;
    for (ActorClassStaticData aData : report.getActorsData()) {
        a = new HalsteadAnalyser(aData);
        row = sheet.createRow(i);
        row.createCell(0).setCellValue(aData.getActorClass().getName());
        row.createCell(1).setCellValue(a.getn1());
        row.createCell(2).setCellValue(a.getn2());
        row.createCell(3).setCellValue(a.getn());
        row.createCell(4).setCellValue(a.getN1());
        row.createCell(5).setCellValue(a.getN2());
        row.createCell(6).setCellValue(a.getN());
        row.createCell(7).setCellValue(a.getcN());
        row.createCell(8).setCellValue(a.getV());
        row.createCell(9).setCellValue(a.getD());
        row.createCell(10).setCellValue(a.getE());
        row.createCell(11).setCellValue(a.getT());
        row.createCell(12).setCellValue(a.getB());
        row.createCell(13).setCellValue(a.getI());
        row.createCell(14).setCellValue(aData.getNumberOfLines());

        i++;
    }
}

From source file:co.turnus.profiling.io.XlsProfilingDataWriter.java

License:Open Source License

private void writeFifosData(HSSFWorkbook workbook, ProfilingData data) {
    HSSFSheet sheet = workbook.createSheet("Fifos Data");
    // Action Actor Class Results
    Cell cell = sheet.createRow(0).createCell(0);
    HSSFRichTextString title = new HSSFRichTextString("Communication data summary");
    title.applyFont(titleFont);/*from  www  . ja v  a 2 s .  c  o m*/
    cell.setCellValue(title);

    int rowIdx = 2;
    Row row = sheet.createRow(rowIdx++);
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 0, 1));
    row.createCell(0).setCellValue("Source");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 2, 3));
    row.createCell(2).setCellValue("Target");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 4, 5));
    row.createCell(4).setCellValue("Type");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 6, 12));
    row.createCell(6).setCellValue("Writing (tokens)");
    sheet.addMergedRegion(new CellRangeAddress(2, 2, 13, 20));
    row.createCell(13).setCellValue("Reading (tokens)");

    // header
    row = sheet.createRow(rowIdx++);
    row.createCell(0).setCellValue("Actor");
    row.createCell(1).setCellValue("Out Port");
    row.createCell(2).setCellValue("Actor");
    row.createCell(3).setCellValue("In Port");

    // type
    row.createCell(4).setCellValue("Name");
    row.createCell(5).setCellValue("Bit:Token");

    // writing
    row.createCell(6).setCellValue("hits");
    row.createCell(7).setCellValue("misses");
    row.createCell(8).setCellValue("total");
    row.createCell(9).setCellValue("average");
    row.createCell(10).setCellValue("min");
    row.createCell(11).setCellValue("max");
    row.createCell(12).setCellValue("variance");

    // reading
    row.createCell(13).setCellValue("peeks");
    row.createCell(14).setCellValue("hits");
    row.createCell(15).setCellValue("misses");
    row.createCell(16).setCellValue("total");
    row.createCell(17).setCellValue("average");
    row.createCell(18).setCellValue("min");
    row.createCell(19).setCellValue("max");
    row.createCell(20).setCellValue("variance");

    for (FifoProfilingData fData : data.getFifosData()) {
        row = sheet.createRow(rowIdx++);
        Fifo fifo = fData.getFifo();
        // header
        row.createCell(0).setCellValue(fifo.getSourceActor().getId());
        row.createCell(1).setCellValue(fifo.getSourcePort().getName());
        row.createCell(2).setCellValue(fifo.getTargetActor().getId());
        row.createCell(3).setCellValue(fifo.getTargetPort().getName());
        // type
        row.createCell(4).setCellValue(fifo.getType().toString());
        row.createCell(5).setCellValue(fifo.getType().getBits());
        // writes
        row.createCell(6).setCellValue(fData.getWriteHit());
        row.createCell(7).setCellValue(fData.getWriteMiss());
        row.createCell(8).setCellValue(fData.getWriteTokens().getSum());
        row.createCell(9).setCellValue(fData.getWriteTokens().getMean());
        row.createCell(10).setCellValue(fData.getWriteTokens().getMin());
        row.createCell(11).setCellValue(fData.getWriteTokens().getMax());
        row.createCell(12).setCellValue(fData.getWriteTokens().getVariance());
        // reads
        row.createCell(13).setCellValue(fData.getPeeks());
        row.createCell(14).setCellValue(fData.getReadHit());
        row.createCell(15).setCellValue(fData.getWriteMiss());
        row.createCell(16).setCellValue(fData.getReadTokens().getSum());
        row.createCell(17).setCellValue(fData.getWriteTokens().getMean());
        row.createCell(18).setCellValue(fData.getWriteTokens().getMin());
        row.createCell(19).setCellValue(fData.getWriteTokens().getMax());
        row.createCell(20).setCellValue(fData.getWriteTokens().getVariance());

    }

}

From source file:code.excelreport.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try {/*from w w  w. j  a v a 2s .  co  m*/
        /* TODO output your page here. You may use following sample code. */

        String allpath = getServletContext().getRealPath("/MOIS.xlsm");

        XSSFWorkbook wb1;

        String pathtodelete = null;

        Date da = new Date();
        String dat2 = da.toString().replace(" ", "_");

        dat2 = dat2.toString().replace(":", "_");

        String mydrive = allpath.substring(0, 1);

        String np = mydrive + ":\\APHIAPLUS\\MOIS\\MACROS\\MOIS_REPORT" + dat2 + ".xlsm";
        //check if file exists
        String sourcepath = getServletContext().getRealPath("/MOIS.xlsm");

        File f = new File(np);
        if (!f.exists() && !f.isFile()) {
            /* do something */

            copytemplates ct = new copytemplates();
            System.out.println("Copying macros..");
            ct.transfermacros(sourcepath, np);

        } else
        //copy the file alone  
        {

            copytemplates ct = new copytemplates();
            //copy the agebased file only
            ct.copymacros(sourcepath, np);

        }

        File allpathfile = new File(np);

        OPCPackage pkg = OPCPackage.open(allpathfile);

        pathtodelete = np;

        //wb = new XSSFWorkbook( OPCPackage.open(allpath) );
        wb1 = new XSSFWorkbook(pkg);

        SXSSFWorkbook wb = new SXSSFWorkbook(wb1, 100);

        Sheet rawdata = wb.getSheet("Facility Report");
        String startdate = "2016-10-01";

        String enddate = "2016-10-30";
        String county = "";

        if (request.getParameter("startdate") != null) {
            startdate = request.getParameter("startdate");
        }
        if (request.getParameter("county") != null) {
            if (!request.getParameter("county").equals("")) {

                county = request.getParameter("county");

            }
        }

        if (request.getParameter("enddate") != null) {
            enddate = request.getParameter("enddate");
        }
        String countywhere = " and 1=1";
        if (!county.equals("")) {
            countywhere = "  and ( county like '" + county + "' ) ";
        }

        DateTime dateTime1 = new DateTime(startdate);
        DateTime dateTime2 = new DateTime(enddate);

        int weeks = Weeks.weeksBetween(dateTime1, dateTime2).getWeeks();
        System.out.println("___Weeks____" + weeks);

        if (weeks == 0) {
            weeks = 1;
        }
        //String header[]="county,subcounty,facilityname,startdate,enddate,hiv_pos_target_child,hiv_pos_target_adult,hiv_pos_target_total,hiv_pos_child,hiv_pos_adult,hiv_pos_total,new_care_child,new_care_adult,new_care_total,new_art_target_child,new_art_target_adult,new_art_target_total,started_art_child,started_art_adult,started_art_total,viral_load_target_child,viral_load_target_adult,viral_load_target_total,viral_load_done_child,viral_load_done_adult,viral_load_done_total,ipt_target_child,ipt_target_adult,ipt_target_total,ipt_child,ipt_adult,ipt_total,testing_target_child,testing_target_adult,testing_target_total,test_child,test_adult,test_total,pmtct_hiv_pos_target,pmtct_hiv_pos,eid_target,eid_done,viral_load_mothers_target,viral_load_mothers_done,hiv_pos_yield_perc_child,hiv_pos_yield_perc_adult,hiv_pos_yield_perc_all,hiv_pos_care_perc_child,hiv_pos_care_perc_adult,hiv_pos_care_perc_all,started_art_perc_child,started_art_perc_adult,started_art_perc_all,viral_test_perc_child,viral_test_perc_adult,viral_test_perc_all,ipt_done_perc_child,ipt_done_perc_adult,ipt_done_perc_all,tested_perc_child,tested_perc_adult,tested_perc_all,viral_load_mothers_perc,eid_done_perc,pmtct_hiv_pos_perc,hiv_pos_yield_cmts,hiv_pos_care_cmts,started_art_cmts,viral_test_cmts,ipt_done_cmts,tested_cmts,viral_load_mothers_cmts,eid_done_cmts,pmtct_hiv_pos_cmts".split(",");
        //String headername[]="COUNTY,SUB-COUNTY,FACILITY,START DATE,END DATE,HIV POSITIVE TARGET CHILDREN,HIV POSITIVE TARGET ADULT,HIV POSITIVE TARGET TOTAL,HIV POSITIVE CHILDREN,HIV POSITIVE ADULT,HIV POSITIVE TOTAL, NEW CARE CHILDREN,NEW CARE ADULT,NEW CARE TOTAL,NEW ART TARGET CHILDREN,NEW ART TARGET ADULT,NEW ART TARGET TOTAL,STARTED ART CHILDREN,STARTED ART ADULT,STARTED ART TOTAL,VIRAL LOAD TARGET CHILDREN,VIRAL LOAD TARGET ADULT,VIRAL LOAD TARGET TOTAL,VIRAL LOAD DONE CHILDREN,VIRAL LOAD DONE ADULT,VIRAL LOAD DONE TOTAL,IPT TARGET CHILDREN,IPT TARGET ADULT,IPT TARGET TOTAL,IPT CHILDREN,IPT ADULT,IPT TOTAL,TESTING TARGET CHILDREN,TESTING TARGET ADULT,TESTING TARGET TOTAL,TESTING CHILDREN,TESTING ADULT,TESTING TOTAL,PMTCT HIV POSITIVE TARGET,PMTCT HIV POSITIVE ,EID TARGET,EID DONE,VIRAL LOAD MOTHERS TARGET,VIRAL LOAD MOTHERS DONE,HIV POSITIVE YIELD CHILDREN ,HIV POSITIVE YIELD ADULT,HIV POSITIVE YIELD ALL,HIV POSITIVE CARE CHILDREN,HIV POSITIVE CARE ADULT,HIV POSITIVE CARE ALL,STARTED ART CHILDREN,STARTED ART ADULT,STARTED ART ,VIRAL TEST CHILDREN,VIRAL TEST ADULT,VIRAL TEST ALL,IPT DONE CHILD,IPT DONE ADULT,IPT DONE ALL,TESTED CHILD,TESTED ADULT,TESTED ALL,VIRAL LOAD MOTHERS ,EID DONE,PMTCT HIV POSITIVE,HIV POSITIVE YIELD COMMENTS,HIV POSITIVE CARE COMMENTS,STARTED ART COMMENTS,VIRAL TEST COMMENTS,IPT DONE COMMENTS ,TESTED COMMENTS,VIRAL LOAD MOTHERS COMMENTS,EID DONE COMMENTS,PMTCT HIV POSITIVE COMMENTS,REPORTING RATE".split(",");

        String header[] = "county,subcounty,facilityname,startdate,enddate,testing_target_child,testing_target_adult,testing_target_total,test_child,test_adult,test_total,tested_perc_child,tested_perc_adult,tested_perc_all,tested_cmts,hiv_pos_target_child,hiv_pos_target_adult,hiv_pos_target_total,hiv_pos_child,hiv_pos_adult,hiv_pos_total,hiv_pos_yield_perc_child,hiv_pos_yield_perc_adult,hiv_pos_yield_perc_all,hiv_pos_yield_cmts,new_care_child,new_care_adult,new_care_total,hiv_pos_care_perc_child,hiv_pos_care_perc_adult,hiv_pos_care_perc_all,hiv_pos_care_cmts,new_art_target_child,new_art_target_adult,new_art_target_total,started_art_child,started_art_adult,started_art_total,started_art_perc_child,started_art_perc_adult,started_art_perc_all,started_art_cmts,viral_load_target_child,viral_load_target_adult,viral_load_target_total,viral_load_done_child,viral_load_done_adult,viral_load_done_total,viral_test_perc_child,viral_test_perc_adult,viral_test_perc_all,viral_test_cmts,ipt_target_child,ipt_target_adult,ipt_target_total,ipt_child,ipt_adult,ipt_total,ipt_done_perc_child,ipt_done_perc_adult,ipt_done_perc_all,ipt_done_cmts,pmtct_hiv_pos_target,pmtct_hiv_pos,pmtct_hiv_pos_perc,pmtct_hiv_pos_cmts,eid_target,eid_done,eid_done_perc,eid_done_cmts,viral_load_mothers_target,viral_load_mothers_done,viral_load_mothers_perc,viral_load_mothers_cmts"
                .split(",");
        String headername[] = "COUNTY,SUB-COUNTY,FACILITY,START DATE,END DATE,TESTING TARGET CHILDREN,TESTING TARGET ADULT,TESTING TARGET TOTAL,TESTING CHILDREN,TESTING ADULT,TESTING TOTAL,PERCENTAGE TESTED AGAINST TARGET CHILDREN,PERCENTAGE TESTED AGAINST TARGET ADULT,PERCENTAGE TESTED AGAINST TARGET ALL,PERCENTAGE TESTED AGAINST TARGET COMMENTS,HIV POSITIVE TARGET CHILDREN,HIV POSITIVE TARGET ADULT,HIV POSITIVE TARGET TOTAL,HIV POSITIVE CHILDREN,HIV POSITIVE ADULT,HIV POSITIVE TOTAL,PERCENTAGE HIV POSITIVE TARGET YIELD ACHIEVED CHILDREN,PERCENTAGE HIV POSITIVE TARGET YIELD ACHIEVED ADULT,PERCENTAGE HIV POSITIVE TARGET YIELD ACHIEVED ALL,PERCENTAGE HIV POSITIVE TARGET YIELD ACHIEVED COMMENTS, NEW CARE CHILDREN,NEW CARE ADULT,NEW CARE TOTAL,PERCENTAGE HIV POSITIVE ENROLLED ON CARE CHILDREN,PERCENTAGE HIV POSITIVE ENROLLED ON CARE ADULT,PERCENTAGE HIV POSITIVE ENROLLED ON CARE ALL,PERCENTAGE HIV POSITIVE ENROLLED ON CARE COMMENTS,NEW ART TARGET CHILDREN,NEW ART TARGET ADULT,NEW ART TARGET TOTAL,STARTED ART CHILDREN,STARTED ART ADULT,STARTED ART TOTAL,PERCENTAGE OF TARGET STARTED ON ART CHILDREN,PERCENTAGE OF TARGET STARTED ON ART ADULT,PERCENTAGE OF TARGET STARTED ON ART ALL,PERCENTAGE OF TARGET STARTED ON ART COMMENTS,VIRAL LOAD TARGET CHILDREN,VIRAL LOAD TARGET ADULT,VIRAL LOAD TARGET TOTAL,VIRAL LOAD DONE CHILDREN,VIRAL LOAD DONE ADULT,VIRAL LOAD DONE TOTAL,PERCENTAGE OF VIRAL LOAD TESTS DONE AGAINST TARGET CHILDREN,PERCENTAGE OF VIRAL LOAD TESTS DONE AGAINST TARGET ADULT,PERCENTAGE OF VIRAL LOAD TESTS DONE AGAINST TARGET ALL,PERCENTAGE OF VIRAL LOAD TESTS DONE AGAINST TARGET COMMENTS,IPT TARGET CHILDREN,IPT TARGET ADULT,IPT TARGET TOTAL,IPT CHILDREN,IPT ADULT,IPT TOTAL,PERCENTAGE OF IPT DONE AGAINST TARGET CHILDREN,PERCENTAGE OF IPT DONE AGAINST TARGET ADULT,PERCENTAGE OF IPT DONE AGAINST TARGET ALL,PERCENTAGE OF IPT DONE AGAINST TARGET COMMENTS,PMTCT HIV POSITIVE TARGET,PMTCT HIV POSITIVE ,PERCENTAGE PMTCT HIV POSITIVE YIELD ACHIEVED AGAINST TARGET ALL,PERCENTAGE PMTCT HIV POSITIVE YIELD ACHIEVED AGAINST TARGET COMMENTS,EID TARGET,EID DONE,PERCENTAGE EID DONE AGAINST TARGET ALL,PERCENTAGE EID DONE AGAINST TARGET COMMENTS,VIRAL LOAD MOTHERS TARGET,VIRAL LOAD MOTHERS DONE,PERCENTAGE VIRAL LOAD TESTS DONE FOR MOTHERS AGAINST TARGET ALL,PERCENTAGE VIRAL LOAD TESTS DONE FOR MOTHERS AGAINST TARGET COMMENTS,REPORTING RATE"
                .split(",");
        //
        //
        Row rw0 = rawdata.createRow(0);
        rw0.setHeightInPoints(25);

        for (int d = 0; d < headername.length; d++) {
            Cell ce = rw0.createCell(d);
            ce.setCellValue(headername[d]);

        }

        dbConnweb conn = new dbConnweb();

        conn.st.executeUpdate("SET GLOBAL max_allowed_packet = 209715200");
        conn.rs = conn.st.executeQuery("SHOW VARIABLES LIKE 'max_allowed_packet' ");
        if (conn.rs.next()) {
            System.out.println("Generating report | Max_allowed_connection_" + conn.rs.getString(2));

        }

        String where = " (enddate between '" + startdate + "' and '" + enddate + "')  " + countywhere
                + " and (id not like '%_weekly%' )  ";
        String where1 = " (enddate between '" + startdate + "' and '" + enddate
                + "')  and (id not like '%_weekly%' ) ";

        //get data in report form and add into the various json macros.
        //String query="select facilityname,startdate,enddate, hiv_pos_target_child,hiv_pos_target_adult,hiv_pos_target_total ,hiv_pos_child as hiv_pos_child , hiv_pos_adult as hiv_pos_adult  ,hiv_pos_total as hiv_pos_total  ,new_care_child as new_care_child ,new_care_adult as new_care_adult ,new_care_total as new_care_total  , new_art_target_child  ,new_art_target_adult  ,new_art_target_total  ,started_art_child as started_art_child, started_art_adult as started_art_adult ,started_art_total as started_art_total ,viral_load_target_child  ,viral_load_target_adult  ,viral_load_target_total  ,viral_load_done_child as viral_load_done_child ,viral_load_done_adult as viral_load_done_adult ,viral_load_done_total as viral_load_done_total  ,ipt_target_child  ,ipt_target_adult  ,ipt_target_total  ,ipt_child as ipt_child ,ipt_adult as ipt_adult ,ipt_total as ipt_total ,testing_target_child  ,testing_target_adult  ,testing_target_total  ,test_child as test_child ,test_adult as test_adult   ,test_total as test_total , pmtct_hiv_pos_target,pmtct_hiv_pos as pmtct_hiv_pos, eid_target  , eid_done as eid_done, viral_load_mothers_target, viral_load_mothers_done as viral_load_mothers_done  from weekly_data_new join facility on weekly_data_new.facilityname=facility.facility_name ";

        String query = " select facility.county,facility.subcounty,cur.facilityname,cur.startdate,cur.enddate,cur.testing_target_child,cur.testing_target_adult,cur.testing_target_total,cur.test_child,cur.test_adult,cur.test_total,cur.tested_perc_child,cur.tested_perc_adult,cur.tested_perc_all,cur.tested_cmts,cur.hiv_pos_target_child,cur.hiv_pos_target_adult,cur.hiv_pos_target_total,cur.hiv_pos_child,cur.hiv_pos_adult,cur.hiv_pos_total,cur.hiv_pos_yield_perc_child,cur.hiv_pos_yield_perc_adult,cur.hiv_pos_yield_perc_all,cur.hiv_pos_yield_cmts,cur.new_care_child,cur.new_care_adult,cur.new_care_total,cur.hiv_pos_care_perc_child,cur.hiv_pos_care_perc_adult,cur.hiv_pos_care_perc_all,cur.hiv_pos_care_cmts,cur.new_art_target_child,cur.new_art_target_adult,cur.new_art_target_total,cur.started_art_child,cur.started_art_adult,cur.started_art_total,cur.started_art_perc_child,cur.started_art_perc_adult,cur.started_art_perc_all,cur.started_art_cmts,cur.viral_load_target_child,cur.viral_load_target_adult,cur.viral_load_target_total,cur.viral_load_done_child,cur.viral_load_done_adult,cur.viral_load_done_total,cur.viral_test_perc_child,cur.viral_test_perc_adult,cur.viral_test_perc_all,cur.viral_test_cmts,cur.ipt_target_child,cur.ipt_target_adult,cur.ipt_target_total,cur.ipt_child,cur.ipt_adult,cur.ipt_total,cur.ipt_done_perc_child,cur.ipt_done_perc_adult,cur.ipt_done_perc_all,cur.ipt_done_cmts,cur.pmtct_hiv_pos_target,cur.pmtct_hiv_pos,cur.pmtct_hiv_pos_perc,cur.pmtct_hiv_pos_cmts,cur.eid_target,cur.eid_done,cur.eid_done_perc,cur.eid_done_cmts,cur.viral_load_mothers_target,cur.viral_load_mothers_done,cur.viral_load_mothers_perc,cur.viral_load_mothers_cmts  from weekly_data_new cur join facility on cur.facilityname=facility.facility_name where  "
                + where + " "
                + " and not exists ( select * from weekly_data_new high join facility on high.facilityname=facility.facility_name  where high.facilityname = cur.facilityname and high.enddate > cur.enddate and "
                + where + ")";

        System.out.println("" + query);
        try {

            conn.rs = conn.st.executeQuery(query);
            String facilname = "";
            String facilnamecopy = "";

            String id = "";

            //percentages

            String viral_load_mothers_perc = null;
            String eid_done_perc = null;
            String pmtct_hiv_pos_perc = null;

            //new percenatages
            String hiv_pos_yield_perc_child = null;
            String hiv_pos_yield_perc_adult = null;
            String hiv_pos_yield_perc_all = null;
            String hiv_pos_care_perc_child = null;
            String hiv_pos_care_perc_adult = null;
            String hiv_pos_care_perc_all = null;
            String started_art_perc_child = null;
            String started_art_perc_adult = null;
            String started_art_perc_all = null;
            String viral_test_perc_child = null;
            String viral_test_perc_adult = null;
            String viral_test_perc_all = null;
            String ipt_done_perc_child = null;
            String ipt_done_perc_adult = null;
            String ipt_done_perc_all = null;
            String tested_perc_child = null;
            String tested_perc_adult = null;
            String tested_perc_all = null;
            //comments
            String viral_load_mothers_cmts = null;
            String eid_done_cmts = null;
            String pmtct_hiv_pos_cmts = null;
            String hiv_pos_yield_cmts = null;
            String hiv_pos_care_cmts = null;
            String started_art_cmts = null;
            String viral_test_cmts = null;
            String ipt_done_cmts = null;
            String tested_cmts = null;

            Row rwx = null;

            int rowno = 0;

            while (conn.rs.next()) {

                rowno++;

                rwx = rawdata.createRow(rowno);
                rwx.setHeightInPoints(23);

                //do a per facility 

                //System.out.println("___FACILITY : "+conn.rs.getString("facilityname")+" => hiv_pos_total "+conn.rs.getString("hiv_pos_total"));

                for (int a = 1; a <= header.length; a++) {

                    System.out.print(header[a - 1] + " _ " + conn.rs.getString(a));
                    Cell ce = rwx.createCell(a - 1);

                    if (a > 5 && a <= 73) {
                        if (header[a - 1].contains("cmts")) {
                            ce.setCellValue(conn.rs.getString(a));
                        } else if (header[a - 1].contains("_perc")) {
                            ce.setCellValue(conn.rs.getInt(a));
                            System.out.println("__Percent");
                        } else {
                            ce.setCellValue(conn.rs.getInt(a));
                        }
                    } else {
                        ce.setCellValue(conn.rs.getString(a));
                    }

                }
                //reporting rate
                int reportingrate = 0;

                String getrates = "select ROUND(((count(facilityname))/(" + weeks
                        + ")*100)) as count from weekly_data_new where facilityname like '"
                        + conn.rs.getString("facilityname") + "' and " + where1 + " ";

                conn.rs1 = conn.st1.executeQuery(getrates);

                if (conn.rs1.next()) {

                    reportingrate = conn.rs1.getInt(1);
                }

                Cell ce = rwx.createCell(header.length);
                ce.setCellValue(reportingrate);

            }

            if (conn.rs != null) {
                conn.rs.close();
            }
            if (conn.rs1 != null) {
                conn.rs1.close();
            }
            if (conn.st != null) {
                conn.st.close();
            }
            if (conn.st1 != null) {
                conn.st1.close();
            }
            if (conn.conne != null) {
                conn.conne.close();
            }

            Date dat = new Date();

            String dat1 = dat.toString().replace(" ", "_");

            // write it as an excel attachment
            ByteArrayOutputStream outByteStream = new ByteArrayOutputStream();
            wb.write(outByteStream);
            byte[] outArray = outByteStream.toByteArray();
            response.setContentType("application/ms-excel");
            response.setContentLength(outArray.length);
            response.setHeader("Expires:", "0"); // eliminates browser caching
            response.setHeader("Content-Disposition", "attachment; filename=MOIS_Cum_Report_From"
                    + startdate.replace(" ", "-") + "_To_" + enddate.replace(" ", "_") + ".xlsm");
            response.setHeader("Set-Cookie", "fileDownload=true; path=/");
            OutputStream outStream = response.getOutputStream();
            outStream.write(outArray);
            outStream.flush();
            pkg.close();
            wb.dispose();
            // response.sendRedirect("index.jsp");

            File file = new File(pathtodelete);

            if (file.delete()) {
                System.out.println(file.getName() + " is deleted!");
            } else {
                System.out.println("Delete operation is failed.");
            }

        } catch (SQLException ex) {
            Logger.getLogger(excelreport.class.getName()).log(Level.SEVERE, null, ex);
        }

    } catch (InvalidFormatException ex) {
        Logger.getLogger(excelreport.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(excelreport.class.getName()).log(Level.SEVERE, null, ex);
    }

}