Rev 767 | Rev 775 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 767 | Rev 771 | ||
|---|---|---|---|
| Line 67... | Line 67... | ||
| 67 | try (FileInputStream fis = new FileInputStream(excelFile.toFile()); Workbook workbook = new XSSFWorkbook(fis)) { |
67 | try (FileInputStream fis = new FileInputStream(excelFile.toFile()); Workbook workbook = new XSSFWorkbook(fis)) { |
| 68 | int numberOfSheets = workbook.getNumberOfSheets(); |
68 | int numberOfSheets = workbook.getNumberOfSheets(); |
| 69 | 69 | ||
| 70 | for (int i = 0; i < numberOfSheets; i++) { |
70 | for (int i = 0; i < numberOfSheets; i++) { |
| 71 | Sheet sheet = workbook.getSheetAt(i); |
71 | Sheet sheet = workbook.getSheetAt(i); |
| 72 | if (sheet.getSheetName().equals(sheetName)) { |
- | |
| 73 | - | ||
| 74 | for (Row row : sheet) { |
- | |
| 75 | - | ||
| 76 | // 0 = Ativo
|
- | |
| 77 | // 1 = Dia
|
- | |
| 78 | // 2 = Hora
|
- | |
| 79 | // 3 = Abertura
|
- | |
| 80 | // 4 = Máxima
|
- | |
| 81 | // 5 = Mínima
|
- | |
| 82 | // 6 = Fechamento
|
- | |
| 83 | // 7 = Volume
|
- | |
| 84 | // 8 = ...
|
- | |
| 85 | - | ||
| 86 | Cell ativoCell = row.getCell(0); |
- | |
| 87 | Cell dataCell = row.getCell(1); |
- | |
| 88 | Cell horaCell = row.getCell(2); |
- | |
| 89 | Cell aberturaCell = row.getCell(3); |
- | |
| 90 | Cell maximaCell = row.getCell(4); |
- | |
| 91 | Cell minimaCell = row.getCell(5); |
- | |
| 92 | Cell fechamentoCell = row.getCell(6); |
- | |
| 93 | - | ||
| 94 | if (!ExcelDataUtils.isNumeric(aberturaCell) || !ExcelDataUtils.isNumeric(maximaCell) |
- | |
| 95 | || !ExcelDataUtils.isNumeric(minimaCell) || !ExcelDataUtils.isNumeric(fechamentoCell)) { |
- | |
| 96 | continue; |
- | |
| 97 | }
|
- | |
| 98 | - | ||
| 99 | LocalDate data = ExcelDataUtils.lerData(dataCell); |
- | |
| 100 | LocalTime hora = ExcelDataUtils.lerHora(horaCell); |
- | |
| 101 | hora = hora.plusMinutes(6).plusSeconds(28); |
- | |
| 102 | LocalDateTime dataHora = LocalDateTime.of(data, hora); |
- | |
| 103 | - | ||
| 104 | String ativoDescricao = ativoCell.getStringCellValue(); |
- | |
| 105 | BigDecimal abertura = BigDecimal.valueOf(aberturaCell.getNumericCellValue()); |
- | |
| 106 | BigDecimal topo = BigDecimal.valueOf(maximaCell.getNumericCellValue()); |
- | |
| 107 | BigDecimal fundo = BigDecimal.valueOf(minimaCell.getNumericCellValue()); |
- | |
| 108 | BigDecimal fechamento = BigDecimal.valueOf(fechamentoCell.getNumericCellValue()); |
- | |
| 109 | - | ||
| 110 | Candle candle = new Candle(null, ativoDescricao, dataHora, abertura, topo, fundo, fechamento, TipoPeriodoCandle.M1.getValor()); |
- | |
| 111 | candles.add(candle); |
- | |
| 112 | }
|
- | |
| - | 72 | for (Row row : sheet) { |
|
| - | 73 | ||
| - | 74 | // 0 = Ativo
|
|
| - | 75 | // 1 = Dia
|
|
| - | 76 | // 2 = Hora
|
|
| - | 77 | // 3 = Abertura
|
|
| - | 78 | // 4 = Máxima
|
|
| - | 79 | // 5 = Mínima
|
|
| - | 80 | // 6 = Fechamento
|
|
| - | 81 | // 7 = Volume
|
|
| - | 82 | // 8 = ...
|
|
| - | 83 | ||
| - | 84 | Cell ativoCell = row.getCell(0); |
|
| - | 85 | Cell dataCell = row.getCell(1); |
|
| - | 86 | Cell horaCell = row.getCell(2); |
|
| - | 87 | Cell aberturaCell = row.getCell(3); |
|
| - | 88 | Cell maximaCell = row.getCell(4); |
|
| - | 89 | Cell minimaCell = row.getCell(5); |
|
| - | 90 | Cell fechamentoCell = row.getCell(6); |
|
| - | 91 | ||
| - | 92 | if (!ExcelDataUtils.isNumeric(aberturaCell) || !ExcelDataUtils.isNumeric(maximaCell) |
|
| - | 93 | || !ExcelDataUtils.isNumeric(minimaCell) || !ExcelDataUtils.isNumeric(fechamentoCell)) { |
|
| - | 94 | continue; |
|
| - | 95 | }
|
|
| - | 96 | ||
| - | 97 | LocalDate data = ExcelDataUtils.lerData(dataCell); |
|
| - | 98 | LocalTime hora = ExcelDataUtils.lerHora(horaCell); |
|
| - | 99 | hora = hora.plusMinutes(6).plusSeconds(28); |
|
| - | 100 | LocalDateTime dataHora = LocalDateTime.of(data, hora); |
|
| - | 101 | ||
| - | 102 | String ativoDescricao = ativoCell.getStringCellValue(); |
|
| - | 103 | BigDecimal abertura = BigDecimal.valueOf(aberturaCell.getNumericCellValue()); |
|
| - | 104 | BigDecimal topo = BigDecimal.valueOf(maximaCell.getNumericCellValue()); |
|
| - | 105 | BigDecimal fundo = BigDecimal.valueOf(minimaCell.getNumericCellValue()); |
|
| - | 106 | BigDecimal fechamento = BigDecimal.valueOf(fechamentoCell.getNumericCellValue()); |
|
| - | 107 | ||
| - | 108 | Candle candle = new Candle(null, ativoDescricao, dataHora, abertura, topo, fundo, fechamento, TipoPeriodoCandle.M1.getValor()); |
|
| - | 109 | candles.add(candle); |
|
| 113 | }
|
110 | }
|
| 114 | }
|
111 | }
|
| 115 | } catch (EncryptedDocumentException e) { |
112 | } catch (EncryptedDocumentException e) { |
| 116 | // TODO Auto-generated catch block
|
113 | // TODO Auto-generated catch block
|
| 117 | e.printStackTrace(); |
114 | e.printStackTrace(); |