| 1 | |
package br.mia.test.util; |
| 2 | |
|
| 3 | |
import java.io.File; |
| 4 | |
import java.io.FileOutputStream; |
| 5 | |
import java.io.IOException; |
| 6 | |
import java.util.ArrayList; |
| 7 | |
|
| 8 | |
import org.apache.poi.hssf.usermodel.HSSFRow; |
| 9 | |
import org.apache.poi.hssf.usermodel.HSSFSheet; |
| 10 | |
import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| 11 | |
|
| 12 | |
import br.mia.test.model.CasoUso; |
| 13 | |
import br.mia.test.testcase.CasosTeste; |
| 14 | |
|
| 15 | 0 | public class GeraExcel |
| 16 | |
{ |
| 17 | |
|
| 18 | |
public static void geraExcel(ArrayList<CasosTeste> casoTeste, |
| 19 | |
CasoUso useCase) throws IOException { |
| 20 | |
|
| 21 | 0 | HSSFWorkbook wb = new HSSFWorkbook(); |
| 22 | |
|
| 23 | 0 | File[] files = Util.getFiles(); |
| 24 | |
|
| 25 | 0 | FileOutputStream stream = new FileOutputStream(files[0] |
| 26 | 0 | .getAbsolutePath()); |
| 27 | |
|
| 28 | 0 | HSSFSheet sheet1 = wb.createSheet("Planilha de Cen�rios"); |
| 29 | |
|
| 30 | 0 | short i = 0; |
| 31 | |
|
| 32 | 0 | for (CasosTeste casosTeste : casoTeste) { |
| 33 | |
|
| 34 | 0 | HSSFRow row = sheet1.createRow((short) i); |
| 35 | |
|
| 36 | 0 | i ++; |
| 37 | |
|
| 38 | 0 | row.createCell((short) 0).setCellValue(useCase.getName()); |
| 39 | |
|
| 40 | 0 | row.createCell((short) 1).setCellValue(casosTeste.getDescricao()); |
| 41 | |
|
| 42 | 0 | row.createCell((short) 2).setCellValue(casosTeste.getNome()); |
| 43 | |
|
| 44 | 0 | row.createCell((short) 3).setCellValue(casosTeste.getEntradas()); |
| 45 | |
|
| 46 | 0 | row.createCell((short) 4).setCellValue( |
| 47 | 0 | casosTeste.getSaidasEsperadas()); |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
} |
| 52 | |
|
| 53 | 0 | wb.write(stream); |
| 54 | |
|
| 55 | 0 | } |
| 56 | |
|
| 57 | |
} |