Examples of HSSFWorkbook


Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

      log.info("Using Excel File"+excelFile);


      URL url = new URL(excelFile);

      HSSFWorkbook wb;
      try {
        wb = commonSpreadsheetUtils.callRules(url,ruleSource, RedConstants.EXCEL_LOG_WORKSHEET_NAME);


View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

    // Open the inputfile as a stream
    FileInputStream excelInput = new FileInputStream(excelFile);

    // Call the rules using this Excel datafile
    HSSFWorkbook wb = commonUtils.callRules(excelInput, ruleArgs,
        EXCEL_LOG_WORKSHEET_NAME);

    // delete the outputFile if it exists
    deleteOutputFileIfExists(outputFileName);

    // Open the outputfile as a stream
    FileOutputStream excelOutput = new FileOutputStream(outputFileName);

    wb.write(excelOutput);

  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

      "attachment; filename=result.xls");

      //Get the URL
      URL url = new URL(EXCEL_DATA_FILE);

      HSSFWorkbook wb;
      try {
        wb = commonSpreadsheetUtils.callRules(url,ruleSource, getExcelLogWorksheetName());

        SpreadSheetOutputter.outputToStream(wb, resp.getOutputStream());
      } catch (Exception e) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

   * Creates an XLSX or an XLS type file using apache poi library depending on the extension.
   * Only the first row of every sheet is initialized.
   */
  public void createFile(LinkedList<String> tests) {
     
    Workbook workbook = new HSSFWorkbook();
     
    for (int cnt=0; cnt<tests.size(); cnt++) {
      setColumns(tests.get(cnt));
      Sheet sheet = workbook.createSheet("Test " + cnt);
      Row row = sheet.createRow(0);

      int counter = 2; //A counter which is used to determine how many additional columns are needed.
      createCell(workbook, row, 0, "Grupa", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
      createCell(workbook, row, 1, "Indeks", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
      createCell(workbook, row, 2, "Naziv Fajla", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);     
      if (bInput) {
        createCell(workbook, row, counter+1, "Ulaz", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bOutput) {
        createCell(workbook, row, counter+1, "Izlaz", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bTimeLimit) {
        createCell(workbook, row, counter+1, "Vremensko Ogranicenje", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bMemory) {
        createCell(workbook, row, counter+1, "Zauzece Memorije", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bCPUTime) {
        createCell(workbook, row, counter+1, "CPU Vreme", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bThreadNumber) {
        createCell(workbook, row, counter+1, "Broj Niti", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bHandlers) {
        createCell(workbook, row, counter+1, "Rukovaoci Greskama", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }
      if (bProcessID) {
        createCell(workbook, row, counter+1, "Proces ID", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
        counter++;
      }     
      createCell(workbook, row, counter+1, "Uspesno/Neuspesno", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
      createCell(workbook, row, counter+2, "Komentar", CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER);
     
      for (int i=0; i<counter+3; i++) {
        sheet.autoSizeColumn(i);
      }
    }
     
    try {
      FileOutputStream fileOutput = new FileOutputStream(reportFile + ".xls");
      workbook.write(fileOutput);
      fileOutput.close();
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

        }
        return fileName;
    }

    public void performExport(DataExportModel model, DataExportInstructions instructions, ConnectionHandler connectionHandler) throws DataExportException {
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.createSheet(model.getTableName());

        if (instructions.createHeader()) {
            HSSFRow headerRow = sheet.createRow(0);

            for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++){
                String columnName = model.getColumnName(columnIndex);

                HSSFCell cell = headerRow.createCell(columnIndex);
                cell.setCellValue(columnName);

                HSSFCellStyle cellStyle = workbook.createCellStyle();
                HSSFFont tableHeadingFont = workbook.createFont();
                tableHeadingFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
                cellStyle.setFont(tableHeadingFont);
                cell.setCellStyle(cellStyle);
            }
        }

        CellStyleCache cellStyleCache = new CellStyleCache(workbook, model.getProject());

        for (short rowIndex = 0; rowIndex < model.getRowCount(); rowIndex++) {
            HSSFRow row = sheet.createRow(rowIndex + 1);
            for (int columnIndex = 0; columnIndex < model.getColumnCount(); columnIndex++){
                HSSFCell cell = row.createCell(columnIndex);
                Object value = model.getValue(rowIndex, columnIndex);
                if (value != null) {
                    if (value instanceof Number) {
                        Number number = (Number) value;
                        double doubleValue = number.doubleValue();
                        cell.setCellValue(doubleValue);
                        cell.setCellStyle(
                                doubleValue % 1 == 0 ?
                                        cellStyleCache.getIntegerStyle() :
                                        cellStyleCache.getNumberStyle());

                    } else if (value instanceof Date) {
                        Date date = (Date) value;
                        boolean hasTime = hasTimeComponent(date);
                        cell.setCellValue(date);
                        cell.setCellStyle(hasTime ?
                                cellStyleCache.getDatetimeStyle() :
                                cellStyleCache.getDateStyle());
                    } else {
                        cell.setCellValue(value.toString());
                    }
                }
            }
        }

        for (int columnIndex=0; columnIndex < model.getColumnCount(); columnIndex++){
            sheet.autoSizeColumn(columnIndex);
        }

        File file = instructions.getFile();
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            workbook.write(fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
            throw new DataExportException(
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

    } else {
      log.info("found file:" + EXCEL_DATA_FILE);
    }

    // Convert this into a (POI) Workbook
    HSSFWorkbook wb = new HSSFWorkbook(new POIFSFileSystem(inputFromExcel));

    // Convert the cell
    RangeHolder ranges = RangeConvertor.convertExcelToCells(wb);
    HashMap<String, Object> globals = new HashMap<String, Object>();
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

import org.drools.compiler.DroolsParserException;

public class ExcelDataRulesExampleTest {

  public final void testRunExcelDataRulesExample() throws DroolsParserException, IOException, ClassNotFoundException {
    HSSFWorkbook hsWorkbook = new ExcelDataRulesExample().runExcelDataRulesExample();

    fail("Need to add checks on output"); // TODO
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

public class RuleflowExampleTest {

  public final void testRunRuleflowExample() throws DroolsParserException, IOException, ClassNotFoundException {

    RuleflowExample thisSample =new RuleflowExample();
    HSSFWorkbook wb = thisSample.runRuleflowExample();

    assertNotNull(wb);

    //fail("Test needs further assertions"); // TODO
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

public class ExcelDataExampleTest {

  @Test
  public final void testRunExcelDataExample() throws DroolsParserException, IOException, ClassNotFoundException {

    HSSFWorkbook hsWorkbook = new ExcelDataExample().runExcelDataExample();

    fail("Need to add checks on output"); // TODO
  }
View Full Code Here

Examples of org.apache.poi.hssf.usermodel.HSSFWorkbook

    //Get the URL
    URL url = new URL(SpreadsheetServletSample.EXCEL_DATA_FILE);
    RuleSource ruleSource = new RuleSource();
    ruleSource.setRulesLocation(SpreadsheetServletSample.RULES_FILES);

    HSSFWorkbook wb;
    wb = commonUtils.callRules(url,ruleSource, SpreadsheetServletSample.getExcelLogWorksheetName());



View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.