I have the following service that has the function of downloading a previously modified xls file (in the comments is the function of each line or block)
@RequestMapping(value = "descarga", method = {RequestMethod.GET, RequestMethod.POST }, produces = "application/vnd.ms-excel")
@ResponseBody
public Response obtenerPostulantes(@RequestParam(required=true)int idPrograma) throws ClientProtocolException, IOException, ParseException{
List <Docente> listaDocentesPostulantes = almacenamientoRegistro.descargaPostulantes(idPrograma);
List <InstanciaFormulario> listaInstanciaFormulario = instanciaFormulario.obtenerInstanciasFormularioXIdPostulacion(idPrograma);
String[] campos = {"RUT(1)","Apellido Paterno(2)","Apellido Materno(3)","Nombre(4)","Genero(5)","Fecha de Nacimiento(6)","Direccion(7)","Region(8)","Provincia(9)",
"Comuna(10)","Telefono(11)","Celular(12)","Email(13)","Titulo(14)","Año Titulacion(15)","Postgrado(16)","Rbd(17)","Establecimiento(18)",
"Nombre Establecimiento(19)","Direccion Establecimiento(20)","Region Establecimiento(21)","Provincia Establecimiento(22)","Comuna Establecimiento(23)",
"Telefono Establecimiento(24)","Cargo Establecimiento(25)","Subsector/Asignatura(26)","Area de Trabajo(27)","Concentracion horaria(28)",
"Curso(29)","Nombre corto curso(30)","Categoria(31)","Nombre aula(32)","Nombre corto aula(33)","Años Experiencia (confirmar)(34)","Nombre del tutor(35)",
"Email tutor(36)","Estado inscripcion(37)","Fecha Inscripcion(38)","Modalidad(39)","Undiad ejecutora(41)","Plan de formacion(42)","Enlaces(43)",
"Estado Final(44)","Nota Final(45)","Asistencia(46)","Documento Adjunto(47)","Fecha ultimo ingreso(48)","Situacion Docente(49)"};
Workbook libroPostulantes = new HSSFWorkbook();
Sheet hoja = libroPostulantes.createSheet("Lista Postulantes");
//Creacion encabezado y asignacion de nombre columnas.
Row filaEncabezado = hoja.createRow(0);
for(int c =0; c < campos.length; c++) {
Cell celda = filaEncabezado.createCell(c);
celda.setCellValue(campos[c]);
}
//Creacion filas con datos de docentes.
int numFila = 1;
for(Docente d : listaDocentesPostulantes) {
Row fila = hoja.createRow(numFila++);
fila.createCell(0).setCellValue(d.getRun());
fila.createCell(1).setCellValue(d.getApellidoPaterno());
fila.createCell(2).setCellValue(d.getApellidoMaterno());
fila.createCell(3).setCellValue(d.getNombre());
fila.createCell(4).setCellValue(d.getGenero());
fila.createCell(5).setCellValue(d.getFechaNacimiento().toString());
fila.createCell(6).setCellValue(d.getDireccionParticular());
fila.createCell(7).setCellValue(d.getRegion());
fila.createCell(9).setCellValue(d.getComuna());
fila.createCell(10).setCellValue(d.getFono());
fila.createCell(11).setCellValue(d.getCelular());
fila.createCell(12).setCellValue(d.getEmail());
fila.createCell(13).setCellValue(d.getTituloProf());
fila.createCell(14).setCellValue(d.getAnioTitulacion());
fila.createCell(16).setCellValue(d.getRbd());
fila.createCell(18).setCellValue(d.getNombreEstablecimiento());
fila.createCell(19).setCellValue(d.getDireccionEstablecimiento());
fila.createCell(20).setCellValue(d.getRegionEstablecimiento());
fila.createCell(21).setCellValue(d.getProvinciaEstablecimiento());
fila.createCell(22).setCellValue(d.getComunaEstablecimiento());
fila.createCell(23).setCellValue(d.getTelefonoEstablecimiento());
fila.createCell(24).setCellValue(d.getCargo());
fila.createCell(25).setCellValue(d.getSubsectorEstablecimiento());
fila.createCell(33).setCellValue(d.getAniosExperiencia());
System.out.println(d.getApellidoMaterno());
}
//Escribir workbook en archivo xls creado previamente.
File ruta = new File("C:\Users\APIUX\Desktop\postulantes.xls");
FileOutputStream fileOut = new FileOutputStream(ruta);
libroPostulantes.write(fileOut);
fileOut.close();
System.out.println("Excel generado!");
//Genera descarga de archivo
ResponseBuilder response = Response.ok((Object) ruta);
response.header("Content-Disposition",
"attachment; filename=new-excel-file.xls");
return response.build();
}
But when entering the URI and trying to download I get the following error message:
I have the jersey-common feature added to the pom but the message keeps coming up.
Any idea what it can be?