List of usage examples for org.apache.poi.ss.usermodel Sheet createRow
Row createRow(int rownum);
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteReservasPorSala() throws Exception { listaReservasGenerador = null;/*from w ww. jav a2 s . c om*/ String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else { rutaArchivo = System.getProperty("user.home") + "/" + "RESERVAS_POR_SALA" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("RESERVAS"); BigInteger idSala = null; if (null != salaLaboratorio) { idSala = salaLaboratorio.getIdsalalaboratorio(); } List<ReservaModuloLaboratorio> reservamodulo = administradorGeneradorReportesBO .obtenerReservasModuloLaboratorioPorSala(idSala); convertirReservasModulo(reservamodulo); List<ReservaSala> reservasala = administradorGeneradorReportesBO.obtenerReservasSalaPorSala(idSala); convertirReservasSala(reservasala); int tamtotal = listaReservasGenerador.size(); for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); ReservasGenerador reserva = listaReservasGenerador.get(f); for (int c = 0; c < 13; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("ID_RESERVA"); } else if (c == 1) { celda.setCellValue("RESERVA"); } else if (c == 2) { celda.setCellValue("FECHA_RESERVA"); } else if (c == 3) { celda.setCellValue("HORA_RESERVA"); } else if (c == 4) { celda.setCellValue("HORA_REAL"); } else if (c == 5) { celda.setCellValue("TIPO_RESERVA"); } else if (c == 6) { celda.setCellValue("SERVICIO"); } else if (c == 7) { celda.setCellValue("LABORATORIO"); } else if (c == 8) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 9) { celda.setCellValue("ESTADO"); } else if (c == 10) { celda.setCellValue("TIPO_USUARIO"); } else if (c == 11) { celda.setCellValue("USUARIO"); } else if (c == 12) { celda.setCellValue("ID_USUARIO"); } } else { if (c == 0) { celda.setCellValue(reserva.getID_RESERVA()); } else if (c == 1) { celda.setCellValue(reserva.getRESERVA()); } else if (c == 2) { celda.setCellValue(reserva.getFECHA_RESERVA()); } else if (c == 3) { celda.setCellValue(reserva.getHORA_RESERVA()); } else if (c == 4) { celda.setCellValue(reserva.getHORA_REAL()); } else if (c == 5) { celda.setCellValue(reserva.getTIPO_RESERVA()); } else if (c == 6) { celda.setCellValue(reserva.getSERVICIO()); } else if (c == 7) { celda.setCellValue(reserva.getLABORATORIO()); } else if (c == 8) { celda.setCellValue(reserva.getSALA_LABORATORIO()); } else if (c == 9) { celda.setCellValue(reserva.getESTADO()); } else if (c == 10) { celda.setCellValue(reserva.getTIPO_USUARIO()); } else if (c == 11) { celda.setCellValue(reserva.getUSUARIO()); } else if (c == 12) { celda.setCellValue(reserva.getID_USUARIO()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteReservasPorParametros() throws Exception { listaReservasGenerador = null;//from w ww .j ava2 s. c om String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else { rutaArchivo = System.getProperty("user.home") + "/" + "RESERVAS_POR_PARAMETROS" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("RESERVAS"); if (0 == tipoReserva) { List<ReservaModuloLaboratorio> reservamodulo = administradorGeneradorReportesBO .obtenerReservasModuloLaboratorioPorFechas(fechaInicio, fechaFin); convertirReservasModulo(reservamodulo); List<ReservaSala> reservasala = administradorGeneradorReportesBO .obtenerReservasSalaPorFechas(fechaInicio, fechaFin); convertirReservasSala(reservasala); } else { if (tipoReserva == 1) { List<ReservaModuloLaboratorio> reservamodulo = administradorGeneradorReportesBO .obtenerReservasModuloLaboratorioPorFechas(fechaInicio, fechaFin); convertirReservasModulo(reservamodulo); } else { List<ReservaSala> reservasala = administradorGeneradorReportesBO .obtenerReservasSalaPorFechas(fechaInicio, fechaFin); convertirReservasSala(reservasala); } } int tamtotal = listaReservasGenerador.size(); for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); ReservasGenerador reserva = listaReservasGenerador.get(f); for (int c = 0; c < 13; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("ID_RESERVA"); } else if (c == 1) { celda.setCellValue("RESERVA"); } else if (c == 2) { celda.setCellValue("FECHA_RESERVA"); } else if (c == 3) { celda.setCellValue("HORA_RESERVA"); } else if (c == 4) { celda.setCellValue("HORA_REAL"); } else if (c == 5) { celda.setCellValue("TIPO_RESERVA"); } else if (c == 6) { celda.setCellValue("SERVICIO"); } else if (c == 7) { celda.setCellValue("LABORATORIO"); } else if (c == 8) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 9) { celda.setCellValue("ESTADO"); } else if (c == 10) { celda.setCellValue("TIPO_USUARIO"); } else if (c == 11) { celda.setCellValue("USUARIO"); } else if (c == 12) { celda.setCellValue("ID_USUARIO"); } } else { if (c == 0) { celda.setCellValue(reserva.getID_RESERVA()); } else if (c == 1) { celda.setCellValue(reserva.getRESERVA()); } else if (c == 2) { celda.setCellValue(reserva.getFECHA_RESERVA()); } else if (c == 3) { celda.setCellValue(reserva.getHORA_RESERVA()); } else if (c == 4) { celda.setCellValue(reserva.getHORA_REAL()); } else if (c == 5) { celda.setCellValue(reserva.getTIPO_RESERVA()); } else if (c == 6) { celda.setCellValue(reserva.getSERVICIO()); } else if (c == 7) { celda.setCellValue(reserva.getLABORATORIO()); } else if (c == 8) { celda.setCellValue(reserva.getSALA_LABORATORIO()); } else if (c == 9) { celda.setCellValue(reserva.getESTADO()); } else if (c == 10) { celda.setCellValue(reserva.getTIPO_USUARIO()); } else if (c == 11) { celda.setCellValue(reserva.getUSUARIO()); } else if (c == 12) { celda.setCellValue(reserva.getID_USUARIO()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteReservasPorIdUsuario() throws Exception { listaReservasGenerador = null;//from ww w . j a va 2 s .c om String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else { rutaArchivo = System.getProperty("user.home") + "/" + "RESERVAS_POR_USUARIO" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("RESERVAS"); List<ReservaModuloLaboratorio> reservamodulo = administradorGeneradorReportesBO .obtenerReservasModuloLaboratorioPorUsuario(idUsuario); convertirReservasModulo(reservamodulo); List<ReservaSala> reservasala = administradorGeneradorReportesBO.obtenerReservasSalaPorUsuario(idUsuario); convertirReservasSala(reservasala); int tamtotal = listaReservasGenerador.size(); for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); ReservasGenerador reserva = listaReservasGenerador.get(f); for (int c = 0; c < 13; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("ID_RESERVA"); } else if (c == 1) { celda.setCellValue("RESERVA"); } else if (c == 2) { celda.setCellValue("FECHA_RESERVA"); } else if (c == 3) { celda.setCellValue("HORA_RESERVA"); } else if (c == 4) { celda.setCellValue("HORA_REAL"); } else if (c == 5) { celda.setCellValue("TIPO_RESERVA"); } else if (c == 6) { celda.setCellValue("SERVICIO"); } else if (c == 7) { celda.setCellValue("LABORATORIO"); } else if (c == 8) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 9) { celda.setCellValue("ESTADO"); } else if (c == 10) { celda.setCellValue("TIPO_USUARIO"); } else if (c == 11) { celda.setCellValue("USUARIO"); } else if (c == 12) { celda.setCellValue("ID_USUARIO"); } } else { if (c == 0) { celda.setCellValue(reserva.getID_RESERVA()); } else if (c == 1) { celda.setCellValue(reserva.getRESERVA()); } else if (c == 2) { celda.setCellValue(reserva.getFECHA_RESERVA()); } else if (c == 3) { celda.setCellValue(reserva.getHORA_RESERVA()); } else if (c == 4) { celda.setCellValue(reserva.getHORA_REAL()); } else if (c == 5) { celda.setCellValue(reserva.getTIPO_RESERVA()); } else if (c == 6) { celda.setCellValue(reserva.getSERVICIO()); } else if (c == 7) { celda.setCellValue(reserva.getLABORATORIO()); } else if (c == 8) { celda.setCellValue(reserva.getSALA_LABORATORIO()); } else if (c == 9) { celda.setCellValue(reserva.getESTADO()); } else if (c == 10) { celda.setCellValue(reserva.getTIPO_USUARIO()); } else if (c == 11) { celda.setCellValue(reserva.getUSUARIO()); } else if (c == 12) { celda.setCellValue(reserva.getID_USUARIO()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteEquiposdeTrabajo() throws Exception { String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else {/*from w w w . j a v a 2 s. co m*/ rutaArchivo = System.getProperty("user.home") + "/" + "EQUIPOS_DE_TRABAJO" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("EQUIPOS DE TRABAJO"); List<EquipoElemento> equipos = administradorGeneradorReportesBO.consultarEquiposdeTrabajoRegistrados(); int tamtotal = 0; if (null != equipos) { tamtotal = equipos.size(); } for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); EquipoElemento equipo = equipos.get(f); for (int c = 0; c < 13; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("NOMBRE_EQUIPO"); } else if (c == 1) { celda.setCellValue("CODIGO_EQUIPO"); } else if (c == 2) { celda.setCellValue("MARCA"); } else if (c == 3) { celda.setCellValue("MODELO"); } else if (c == 4) { celda.setCellValue("SERIE"); } else if (c == 5) { celda.setCellValue("CANTIDAD"); } else if (c == 6) { celda.setCellValue("TIPO_ACTIVO"); } else if (c == 7) { celda.setCellValue("PROVEEDOR"); } else if (c == 8) { celda.setCellValue("NIT_PROVEEDOR"); } else if (c == 9) { celda.setCellValue("LABORATORIO"); } else if (c == 10) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 11) { celda.setCellValue("MODULO_LABORATORIO"); } else if (c == 12) { celda.setCellValue("ESTADO_EQUIPO"); } } else { if (c == 0) { celda.setCellValue(equipo.getNombreequipo()); } else if (c == 1) { celda.setCellValue(equipo.getInventarioequipo()); } else if (c == 2) { celda.setCellValue(equipo.getMarcaequipo()); } else if (c == 3) { celda.setCellValue(equipo.getModeloequipo()); } else if (c == 4) { celda.setCellValue(equipo.getSeriequipo()); } else if (c == 5) { celda.setCellValue(equipo.getCantidadequipo()); } else if (c == 6) { celda.setCellValue(equipo.getTipoactivo().getNombretipoactivo()); } else if (c == 7) { celda.setCellValue(equipo.getProveedor().getNombreproveedor()); } else if (c == 8) { celda.setCellValue(equipo.getProveedor().getNitproveedor()); } else if (c == 9) { celda.setCellValue(equipo.getModulolaboratorio().getSalalaboratorio().getLaboratorio() .getNombrelaboratorio()); } else if (c == 10) { celda.setCellValue(equipo.getModulolaboratorio().getSalalaboratorio().getNombresala()); } else if (c == 11) { celda.setCellValue(equipo.getModulolaboratorio().getDetallemodulo()); } else if (c == 12) { celda.setCellValue(equipo.getEstadoequipo().getNombreestadoequipo()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteModulosLaboratorio() throws Exception { String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else {//from w w w . jav a 2 s . c o m rutaArchivo = System.getProperty("user.home") + "/" + "MODULOS_LABORATORIO_REGISTRADOS" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("MODULOS_REGISTRADOS"); List<ModuloLaboratorio> modulos = administradorGeneradorReportesBO.consultarModuloLaboratorioRegistrados(); int tamtotal = 0; if (null != modulos) { tamtotal = modulos.size(); } for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); ModuloLaboratorio modulo = modulos.get(f); for (int c = 0; c < 7; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("CODIGO_MODULO"); } else if (c == 1) { celda.setCellValue("NOMBRE"); } else if (c == 2) { celda.setCellValue("ESTADO"); } else if (c == 3) { celda.setCellValue("CAPACIDAD"); } else if (c == 4) { celda.setCellValue("COSTO_ALQUILER"); } else if (c == 5) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 6) { celda.setCellValue("LABORATORIO"); } } else { if (c == 0) { celda.setCellValue(modulo.getCodigomodulo()); } else if (c == 1) { celda.setCellValue(modulo.getDetallemodulo()); } else if (c == 2) { celda.setCellValue(modulo.getStrEstado()); } else if (c == 3) { celda.setCellValue(modulo.getCapacidadmodulo()); } else if (c == 4) { celda.setCellValue(modulo.getCostoalquiler().toString()); } else if (c == 5) { celda.setCellValue(modulo.getSalalaboratorio().getNombresala()); } else if (c == 6) { celda.setCellValue(modulo.getSalalaboratorio().getLaboratorio().getNombrelaboratorio()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteComponentes() throws Exception { String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else {//from w w w . j a v a 2 s .c om rutaArchivo = System.getProperty("user.home") + "/" + "COMPONENTES_REGISTRADOS" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("COMPONENTES"); List<ComponenteEquipo> componentes = administradorGeneradorReportesBO.consultarComponentesRegistrados(); int tamtotal = 0; if (null != componentes) { tamtotal = componentes.size(); } for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); ComponenteEquipo componente = componentes.get(f); for (int c = 0; c < 12; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("CODIGO_COMPONENTE"); } else if (c == 1) { celda.setCellValue("NOMBRE_COMPONENTE"); } else if (c == 2) { celda.setCellValue("DESCRIPCION_COMPONENTE"); } else if (c == 3) { celda.setCellValue("MARCA_COMPONENTE"); } else if (c == 4) { celda.setCellValue("MODELO_COMPONENTE"); } else if (c == 5) { celda.setCellValue("SERIAL_COMPONENTE"); } else if (c == 6) { celda.setCellValue("TIPO_COMPONENTE_COMPONENTE"); } else if (c == 7) { celda.setCellValue("ESTADO_COMPONENTE"); } else if (c == 8) { celda.setCellValue("CODIGO_EQUIPO_TRABAJO"); } else if (c == 9) { celda.setCellValue("EQUIPO_TRABAJO"); } else if (c == 10) { celda.setCellValue("CODIGO_MODULO_LABORATORIO"); } else if (c == 11) { celda.setCellValue("MODULO_LABORATORIO"); } else if (c == 12) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 13) { celda.setCellValue("LABORATORIO"); } } else { if (c == 0) { celda.setCellValue(componente.getCodigocomponete()); } else if (c == 1) { celda.setCellValue(componente.getNombrecomponente()); } else if (c == 2) { celda.setCellValue(componente.getDescripcioncomponente()); } else if (c == 3) { celda.setCellValue(componente.getMarcacomponente()); } else if (c == 4) { celda.setCellValue(componente.getModelocomponente()); } else if (c == 5) { celda.setCellValue(componente.getSerialcomponente()); } else if (c == 6) { celda.setCellValue(componente.getTipocomponente().getNombretipo()); } else if (c == 7) { celda.setCellValue(componente.getStrEstado()); } else if (c == 8) { celda.setCellValue(componente.getEquipoelemento().getInventarioequipo()); } else if (c == 9) { celda.setCellValue(componente.getEquipoelemento().getNombreequipo()); } else if (c == 10) { celda.setCellValue(componente.getEquipoelemento().getModulolaboratorio().getCodigomodulo()); } else if (c == 11) { celda.setCellValue( componente.getEquipoelemento().getModulolaboratorio().getDetallemodulo()); } else if (c == 12) { celda.setCellValue(componente.getEquipoelemento().getModulolaboratorio() .getSalalaboratorio().getNombresala()); } else if (c == 13) { celda.setCellValue(componente.getEquipoelemento().getModulolaboratorio() .getSalalaboratorio().getLaboratorio().getNombrelaboratorio()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteIntegracionInventario() throws Exception { String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else {/*w ww . ja v a2 s . co m*/ rutaArchivo = System.getProperty("user.home") + "/" + "INTEGRACION_INVENTARIO" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("INVENTARIO"); List<ComponenteEquipo> componentes = administradorGeneradorReportesBO.consultarComponentesRegistrados(); int tamtotal = 0; if (null != componentes) { tamtotal = componentes.size(); } for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); ComponenteEquipo componente = componentes.get(f); for (int c = 0; c < 18; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("CODIGO_COMPONENTE"); } else if (c == 1) { celda.setCellValue("NOMBRE_COMPONENTE"); } else if (c == 2) { celda.setCellValue("DESCRIPCION_COMPONENTE"); } else if (c == 3) { celda.setCellValue("MARCA_COMPONENTE"); } else if (c == 4) { celda.setCellValue("MODELO_COMPONENTE"); } else if (c == 5) { celda.setCellValue("TIPO_COMPONENTE"); } else if (c == 6) { celda.setCellValue("ESTADO_COMPONENTE"); } else if (c == 7) { celda.setCellValue("CODIGO_EQUIPO"); } else if (c == 8) { celda.setCellValue("NOMBRE_EQUIPO"); } else if (c == 9) { celda.setCellValue("MODELO_EQUIPO"); } else if (c == 10) { celda.setCellValue("SERIE_EQUIPO"); } else if (c == 11) { celda.setCellValue("PROVEEDOR_EQUIPO"); } else if (c == 12) { celda.setCellValue("ESTADO_EQUIPO"); } else if (c == 13) { celda.setCellValue("TIPO_ACTIVO_EQUIPO"); } else if (c == 14) { celda.setCellValue("CODIGO_MODULO_LABORATORIO"); } else if (c == 15) { celda.setCellValue("MODULO_LABORATORIO"); } else if (c == 16) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 17) { celda.setCellValue("LABORATORIO"); } } else { if (c == 0) { celda.setCellValue(componente.getCodigocomponete()); } else if (c == 1) { celda.setCellValue(componente.getNombrecomponente()); } else if (c == 2) { celda.setCellValue(componente.getDescripcioncomponente()); } else if (c == 3) { celda.setCellValue(componente.getMarcacomponente()); } else if (c == 4) { celda.setCellValue(componente.getModelocomponente()); } else if (c == 5) { celda.setCellValue(componente.getTipocomponente().getNombretipo()); } else if (c == 6) { celda.setCellValue(componente.getStrEstado()); } else if (c == 7) { celda.setCellValue(componente.getEquipoelemento().getInventarioequipo()); } else if (c == 8) { celda.setCellValue(componente.getEquipoelemento().getNombreequipo()); } else if (c == 9) { celda.setCellValue(componente.getEquipoelemento().getModeloequipo()); } else if (c == 10) { celda.setCellValue(componente.getEquipoelemento().getSeriequipo()); } else if (c == 11) { celda.setCellValue(componente.getEquipoelemento().getProveedor().getNombreproveedor()); } else if (c == 12) { celda.setCellValue( componente.getEquipoelemento().getEstadoequipo().getNombreestadoequipo()); } else if (c == 13) { celda.setCellValue(componente.getEquipoelemento().getTipoactivo().getNombretipoactivo()); } else if (c == 14) { celda.setCellValue(componente.getEquipoelemento().getModulolaboratorio().getCodigomodulo()); } else if (c == 15) { celda.setCellValue( componente.getEquipoelemento().getModulolaboratorio().getDetallemodulo()); } else if (c == 16) { celda.setCellValue(componente.getEquipoelemento().getModulolaboratorio() .getSalalaboratorio().getNombresala()); } else if (c == 17) { celda.setCellValue(componente.getEquipoelemento().getModulolaboratorio() .getSalalaboratorio().getLaboratorio().getNombrelaboratorio()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sirelab.controller.reportes.ControllerGeneradorReportes.java
public void reporteHojaVidaEquipos() throws Exception { String rutaArchivo = ""; if (validarNombreReporte()) { rutaArchivo = System.getProperty("user.home") + "/" + nombreReporte + ".xls"; } else {/* w w w . j a v a2 s . c om*/ rutaArchivo = System.getProperty("user.home") + "/" + "HOJA_VIDA_EQUIPOS" + ".xls"; } File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists()) { archivoXLS.delete(); } archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("HOJA_VIDA_EQUIPOS"); List<HojaVidaEquipo> hojavidaequipos = administradorGeneradorReportesBO.consultarHojaVidaEquipos(); int tamtotal = 0; if (null != hojavidaequipos) { tamtotal = hojavidaequipos.size(); } for (int f = 0; f < tamtotal; f++) { Row fila = hoja.createRow(f); HojaVidaEquipo hojavida = hojavidaequipos.get(f); for (int c = 0; c < 19; c++) { Cell celda = fila.createCell(c); if (f == 0) { if (c == 0) { celda.setCellValue("FECHA_REGISTRO"); } else if (c == 1) { celda.setCellValue("FECHA_EVENTO"); } else if (c == 2) { celda.setCellValue("FECHA_FIN_EVENTO"); } else if (c == 3) { celda.setCellValue("DETALLE_EVENTO"); } else if (c == 4) { celda.setCellValue("OBSERVACIONES"); } else if (c == 5) { celda.setCellValue("COSTO"); } else if (c == 6) { celda.setCellValue("USUARIO"); } else if (c == 7) { celda.setCellValue("TIPO_EVENTO"); } else if (c == 8) { celda.setCellValue("CODIGO_EQUIPO"); } else if (c == 9) { celda.setCellValue("NOMBRE_EQUIPO"); } else if (c == 10) { celda.setCellValue("MODELO_EQUIPO"); } else if (c == 11) { celda.setCellValue("SERIE_EQUIPO"); } else if (c == 12) { celda.setCellValue("PROVEEDOR_EQUIPO"); } else if (c == 13) { celda.setCellValue("ESTADO_EQUIPO"); } else if (c == 14) { celda.setCellValue("TIPO_ACTIVO_EQUIPO"); } else if (c == 15) { celda.setCellValue("CODIGO_MODULO_LABORATORIO"); } else if (c == 16) { celda.setCellValue("MODULO_LABORATORIO"); } else if (c == 17) { celda.setCellValue("SALA_LABORATORIO"); } else if (c == 18) { celda.setCellValue("LABORATORIO"); } } else { String pattern = "dd/MM/yyyy"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); if (c == 0) { String date = simpleDateFormat.format(hojavida.getFecharegistro()); celda.setCellValue(date); } else if (c == 1) { String date = simpleDateFormat.format(hojavida.getFechaevento()); celda.setCellValue(date); } else if (c == 2) { String date = simpleDateFormat.format(hojavida.getFechafinevento()); celda.setCellValue(date); } else if (c == 3) { celda.setCellValue(hojavida.getDetalleevento()); } else if (c == 4) { celda.setCellValue(hojavida.getObservaciones()); } else if (c == 5) { celda.setCellValue(hojavida.getCosto()); } else if (c == 6) { celda.setCellValue(hojavida.getUsuariomodificacion()); } else if (c == 7) { celda.setCellValue(hojavida.getTipoevento().getDetalleevento()); } else if (c == 8) { celda.setCellValue(hojavida.getEquipoelemento().getInventarioequipo()); } else if (c == 9) { celda.setCellValue(hojavida.getEquipoelemento().getNombreequipo()); } else if (c == 10) { celda.setCellValue(hojavida.getEquipoelemento().getModeloequipo()); } else if (c == 11) { celda.setCellValue(hojavida.getEquipoelemento().getSeriequipo()); } else if (c == 12) { celda.setCellValue(hojavida.getEquipoelemento().getProveedor().getNombreproveedor()); } else if (c == 13) { celda.setCellValue(hojavida.getEquipoelemento().getEstadoequipo().getNombreestadoequipo()); } else if (c == 14) { celda.setCellValue(hojavida.getEquipoelemento().getTipoactivo().getNombretipoactivo()); } else if (c == 15) { celda.setCellValue(hojavida.getEquipoelemento().getModulolaboratorio().getCodigomodulo()); } else if (c == 16) { celda.setCellValue(hojavida.getEquipoelemento().getModulolaboratorio().getDetallemodulo()); } else if (c == 17) { celda.setCellValue(hojavida.getEquipoelemento().getModulolaboratorio().getSalalaboratorio() .getNombresala()); } else if (c == 18) { celda.setCellValue(hojavida.getEquipoelemento().getModulolaboratorio().getSalalaboratorio() .getLaboratorio().getNombrelaboratorio()); } } } } libro.write(archivo); archivo.close(); descargarArchivo(rutaArchivo); }
From source file:com.sitech.chn.s98800.s98820.s882q.util.XLSXCovertCSVReader.java
License:Apache License
public static void writeToXlSX(HttpServletResponse response, List data, String FileName) throws Exception { String filePath = ServletActionContext.getServletContext().getRealPath("/upload") + "/" + FileName; SXSSFWorkbook wb = new SXSSFWorkbook(10000); File exprotFile = new File(filePath); if (exprotFile.exists()) { exprotFile.delete();/*from www.j a v a 2 s . co m*/ exprotFile = new File(filePath); } System.out.println("" + new Date()); FileOutputStream fos = new FileOutputStream(exprotFile); Sheet sh = wb.createSheet(); String[] temp = null; for (int i = 0; i < data.size(); i++) { temp = (String[]) data.get(i); Row row = sh.createRow(i); for (int j = 0; j < temp.length; j++) { Cell cell = row.createCell(j); cell.setCellValue(temp[j] == null ? "" : temp[j].replaceAll("\"", "") + " "); } } wb.write(fos); wb.close();// fos.close(); System.out.println("" + new Date() + exprotFile.getAbsolutePath()); InputStream inStream = new BufferedInputStream(new FileInputStream(exprotFile)); response.reset(); response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("content-disposition", "attachment; filename=" + URLEncoder.encode(FileName, "UTF-8")); response.addHeader("Content-Length", exprotFile.length() + ""); byte[] b = new byte[1024 * 10]; int len; while ((len = inStream.read(b)) > 0) { response.getOutputStream().write(b, 0, len); } inStream.close(); }
From source file:com.skt.adcas.lte.action.DownLinkByNMSAction.java
public String selectDailyCellTrafficCQIExcelDownload() { this.log.debug("selectDailyCellTrafficCQIExcelDownload Start"); SqlSession session = null;/*from w ww. java 2 s . c o m*/ FileOutputStream fileOut = null; try { parseParam(); log.debug(this.MFC_CD); String[] CQINAME = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }; if (MFC_CD.equals("MFC00002")) { CQINAME[0] = "1"; CQINAME[1] = "2"; CQINAME[2] = "3"; CQINAME[3] = "4"; CQINAME[4] = "5"; CQINAME[5] = "6"; CQINAME[6] = "7"; CQINAME[7] = "8"; CQINAME[8] = "9"; CQINAME[9] = "10"; CQINAME[10] = "11"; CQINAME[12] = "12"; CQINAME[13] = "13"; CQINAME[14] = "14"; CQINAME[15] = "15"; } Type type = new TypeToken<Map<String, Object>>() { }.getType(); Gson gson = new Gson(); Map<String, Object> map = gson.fromJson(this.JSONDATA, type); //log.debug("json data : " + this.JSONDATA); Workbook wb = new HSSFWorkbook(); //PDFsheet String sheetName = "CQI PDF"; String safeName = WorkbookUtil.createSafeSheetName(sheetName); Sheet PDFsheet = wb.createSheet(safeName); //CDFsheet sheetName = "CQI CDF"; safeName = WorkbookUtil.createSafeSheetName(sheetName); Sheet CDFsheet = wb.createSheet(safeName); //header ? Row PDFhrow0 = PDFsheet.createRow((short) 0); PDFhrow0.setHeightInPoints(20); PDFhrow0.createCell(0).setCellValue(""); // "YMD" PDFhrow0.createCell(1).setCellValue(""); // "MB_TIME" PDFhrow0.createCell(2).setCellValue("DU"); // "BTS_NM" PDFhrow0.createCell(3).setCellValue("CELL ID"); // "CELL_ID" PDFhrow0.createCell(4).setCellValue("CELL "); // "CELL_NM" PDFhrow0.createCell(5).setCellValue("MCID"); // "MCID" PDFhrow0.createCell(6).setCellValue(""); // "MCID" PDFhrow0.createCell(7).setCellValue("PDF-" + CQINAME[0]); PDFhrow0.createCell(8).setCellValue("PDF-" + CQINAME[1]); PDFhrow0.createCell(9).setCellValue("PDF-" + CQINAME[2]); PDFhrow0.createCell(10).setCellValue("PDF-" + CQINAME[3]); PDFhrow0.createCell(11).setCellValue("PDF-" + CQINAME[4]); PDFhrow0.createCell(12).setCellValue("PDF-" + CQINAME[5]); PDFhrow0.createCell(13).setCellValue("PDF-" + CQINAME[6]); PDFhrow0.createCell(14).setCellValue("PDF-" + CQINAME[7]); PDFhrow0.createCell(15).setCellValue("PDF-" + CQINAME[8]); PDFhrow0.createCell(16).setCellValue("PDF-" + CQINAME[9]); PDFhrow0.createCell(17).setCellValue("PDF-" + CQINAME[10]); PDFhrow0.createCell(18).setCellValue("PDF-" + CQINAME[11]); PDFhrow0.createCell(19).setCellValue("PDF-" + CQINAME[12]); PDFhrow0.createCell(20).setCellValue("PDF-" + CQINAME[13]); PDFhrow0.createCell(21).setCellValue("PDF-" + CQINAME[14]); PDFhrow0.createCell(22).setCellValue("PDF-" + CQINAME[15]); //header ? Row CDFhrow0 = CDFsheet.createRow((short) 0); CDFhrow0.setHeightInPoints(20); CDFhrow0.createCell(0).setCellValue(""); // "YMD" CDFhrow0.createCell(1).setCellValue(""); // "MB_TIME" CDFhrow0.createCell(2).setCellValue("DU"); // "BTS_NM" CDFhrow0.createCell(3).setCellValue("CELL ID"); // "CELL_ID" CDFhrow0.createCell(4).setCellValue("CELL "); // "CELL_NM" CDFhrow0.createCell(5).setCellValue("MCID"); // "MCID" CDFhrow0.createCell(6).setCellValue(""); // "MCID" CDFhrow0.createCell(7).setCellValue("CDF-" + CQINAME[0]); CDFhrow0.createCell(8).setCellValue("CDF-" + CQINAME[1]); CDFhrow0.createCell(9).setCellValue("CDF-" + CQINAME[2]); CDFhrow0.createCell(10).setCellValue("CDF-" + CQINAME[3]); CDFhrow0.createCell(11).setCellValue("CDF-" + CQINAME[4]); CDFhrow0.createCell(12).setCellValue("CDF-" + CQINAME[5]); CDFhrow0.createCell(13).setCellValue("CDF-" + CQINAME[6]); CDFhrow0.createCell(14).setCellValue("CDF-" + CQINAME[7]); CDFhrow0.createCell(15).setCellValue("CDF-" + CQINAME[8]); CDFhrow0.createCell(16).setCellValue("CDF-" + CQINAME[9]); CDFhrow0.createCell(17).setCellValue("CDF-" + CQINAME[10]); CDFhrow0.createCell(18).setCellValue("CDF-" + CQINAME[11]); CDFhrow0.createCell(19).setCellValue("CDF-" + CQINAME[12]); CDFhrow0.createCell(20).setCellValue("CDF-" + CQINAME[13]); CDFhrow0.createCell(21).setCellValue("CDF-" + CQINAME[14]); CDFhrow0.createCell(22).setCellValue("CDF-" + CQINAME[15]); ArrayList list01 = (ArrayList) map.get("rows"); Iterator iterator = (Iterator) list01.iterator(); short i = 1; while (iterator.hasNext()) { StringMap jrow = (StringMap) iterator.next(); // Row PDFrow = PDFsheet.createRow((short) i); Row CDFrow = CDFsheet.createRow((short) i); PDFrow.setHeightInPoints(20); CDFrow.setHeightInPoints(20); PDFrow.createCell(0).setCellValue((String) jrow.get("YMD")); PDFrow.createCell(1).setCellValue((String) jrow.get("MB_TIME")); PDFrow.createCell(2).setCellValue((String) jrow.get("BTS_NM")); PDFrow.createCell(3).setCellValue((String) jrow.get("CELL_ID")); PDFrow.createCell(4).setCellValue((String) jrow.get("CELL_NM")); PDFrow.createCell(5).setCellValue((String) jrow.get("MCID")); PDFrow.createCell(6).setCellValue((String) jrow.get("FREQ_KIND")); CDFrow.createCell(0).setCellValue((String) jrow.get("YMD")); CDFrow.createCell(1).setCellValue((String) jrow.get("MB_TIME")); CDFrow.createCell(2).setCellValue((String) jrow.get("BTS_NM")); CDFrow.createCell(3).setCellValue((String) jrow.get("CELL_ID")); CDFrow.createCell(4).setCellValue((String) jrow.get("CELL_NM")); CDFrow.createCell(5).setCellValue((String) jrow.get("MCID")); CDFrow.createCell(6).setCellValue((String) jrow.get("FREQ_KIND")); PDFrow.createCell(7).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_00") ? jrow.get("CQI_PDF_00").toString() : "0")); PDFrow.createCell(8).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_01") ? jrow.get("CQI_PDF_01").toString() : "0")); PDFrow.createCell(9).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_02") ? jrow.get("CQI_PDF_02").toString() : "0")); PDFrow.createCell(10).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_03") ? jrow.get("CQI_PDF_03").toString() : "0")); PDFrow.createCell(11).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_04") ? jrow.get("CQI_PDF_04").toString() : "0")); PDFrow.createCell(12).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_05") ? jrow.get("CQI_PDF_05").toString() : "0")); PDFrow.createCell(13).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_06") ? jrow.get("CQI_PDF_06").toString() : "0")); PDFrow.createCell(14).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_07") ? jrow.get("CQI_PDF_07").toString() : "0")); PDFrow.createCell(15).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_08") ? jrow.get("CQI_PDF_08").toString() : "0")); PDFrow.createCell(16).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_09") ? jrow.get("CQI_PDF_09").toString() : "0")); PDFrow.createCell(17).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_10") ? jrow.get("CQI_PDF_10").toString() : "0")); PDFrow.createCell(18).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_11") ? jrow.get("CQI_PDF_11").toString() : "0")); PDFrow.createCell(19).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_12") ? jrow.get("CQI_PDF_12").toString() : "0")); PDFrow.createCell(20).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_13") ? jrow.get("CQI_PDF_13").toString() : "0")); PDFrow.createCell(21).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_14") ? jrow.get("CQI_PDF_14").toString() : "0")); PDFrow.createCell(22).setCellValue(Double .parseDouble(jrow.containsKey("CQI_PDF_15") ? jrow.get("CQI_PDF_15").toString() : "0")); CDFrow.createCell(7).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_00") ? jrow.get("CQI_CDF_00").toString() : "0")); CDFrow.createCell(8).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_01") ? jrow.get("CQI_CDF_01").toString() : "0")); CDFrow.createCell(9).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_02") ? jrow.get("CQI_CDF_02").toString() : "0")); CDFrow.createCell(10).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_03") ? jrow.get("CQI_CDF_03").toString() : "0")); CDFrow.createCell(11).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_04") ? jrow.get("CQI_CDF_04").toString() : "0")); CDFrow.createCell(12).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_05") ? jrow.get("CQI_CDF_05").toString() : "0")); CDFrow.createCell(13).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_06") ? jrow.get("CQI_CDF_06").toString() : "0")); CDFrow.createCell(14).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_07") ? jrow.get("CQI_CDF_07").toString() : "0")); CDFrow.createCell(15).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_08") ? jrow.get("CQI_CDF_08").toString() : "0")); CDFrow.createCell(16).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_09") ? jrow.get("CQI_CDF_09").toString() : "0")); CDFrow.createCell(17).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_10") ? jrow.get("CQI_CDF_10").toString() : "0")); CDFrow.createCell(18).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_11") ? jrow.get("CQI_CDF_11").toString() : "0")); CDFrow.createCell(19).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_12") ? jrow.get("CQI_CDF_12").toString() : "0")); CDFrow.createCell(20).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_13") ? jrow.get("CQI_CDF_13").toString() : "0")); CDFrow.createCell(21).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_14") ? jrow.get("CQI_CDF_14").toString() : "0")); CDFrow.createCell(22).setCellValue(Double .parseDouble(jrow.containsKey("CQI_CDF_15") ? jrow.get("CQI_CDF_15").toString() : "0")); i++; } String writeFolderPath = (String) super.properties.get("TEMP_FOLDER_PATH"); String tempFolder = "/" + UUID.randomUUID().toString(); String xlsFileName = "/DownLinkCQI(PDF_CDF).xls"; if (!(new File(writeFolderPath + tempFolder)).mkdir()) { throw new Exception("? ?? ."); } String xlsFileFullPath = writeFolderPath + tempFolder + xlsFileName; fileOut = new FileOutputStream(xlsFileFullPath); wb.write(fileOut); this.msg = "? ? ?"; this.status = "SUCCESS"; this.downloadurl = "download" + tempFolder + xlsFileName; } catch (Exception e) { this.msg = e.getMessage(); this.status = "ERROR"; this.error = true; if (session != null) { session.rollback(); } e.printStackTrace(); } finally { try { if (fileOut != null) fileOut.close(); } catch (IOException e) { e.printStackTrace(); } if (session != null) { session.close(); } } this.log.debug("selectDailyCellTrafficCQIExcelDownload End"); return SUCCESS; }