List of usage examples for org.apache.poi.hssf.usermodel HSSFWorkbook HSSFWorkbook
public HSSFWorkbook()
From source file:ch.javasoft.metabolic.generate.ExcelGenerator.java
License:BSD License
public ExcelGenerator(MetabolicNetwork net) { this.net = net; workbook = new HSSFWorkbook(); styleBoldItalic = getCellStyle(HSSFFont.BOLDWEIGHT_BOLD, true); initMetabolites();/*from w w w . ja v a2 s.c o m*/ initReactions(); }
From source file:ch.scheduled.java
public void output() throws FileNotFoundException, IOException { Workbook wb = new HSSFWorkbook(); Sheet sheet = wb.createSheet("Schedule"); int count = 0; for (int i = 0; i < Courses.size(); ++i) { Course temp = Courses.get(i);/* w w w. j av a 2 s . c om*/ if (temp.isScheduled() == true) { Row row = sheet.createRow((short) count); row.createCell(0).setCellValue(temp.getNumber()); row.createCell(2).setCellValue(temp.getSession().getDay()); row.createCell(3).setCellValue(temp.getSession().getSlot()); ++count; } } FileOutputStream fileOut = new FileOutputStream("Final$Exam.xls"); wb.write(fileOut); fileOut.close(); }
From source file:cherry.goods.excel.ExcelFactory.java
License:Apache License
/** * Excel (.xls) ???<br />/*www.j a v a2 s. c o m*/ * * @return ???Excel */ public static Workbook createBlankXls() { return createSheet(new HSSFWorkbook()); }
From source file:cherry.goods.excel.ExcelFactory.java
License:Apache License
/** * Excel (.xls) ???<br />// www. j a v a 2s . c om * * @param sheetname ?????? * @return ???Excel */ public static Workbook createBlankXls(String sheetname) { return createSheet(new HSSFWorkbook(), sheetname); }
From source file:chocanproject.ServiceDetailsGUI.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: try {//from www.j a va2 s.c o m Connection con = DriverManager.getConnection(connectionUrl); Statement st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); String sql = "ChocAn.dbo.GetProviderDirectory_Select"; ResultSet rs = st.executeQuery(sql); //Create a blank workbook and sheet HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("NewSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell((short) 0).setCellValue("CellHeadName1"); rowhead.createCell((short) 1).setCellValue("CellHeadName2"); rowhead.createCell((short) 2).setCellValue("CellHeadName3"); int i = 1; while (rs.next()) { HSSFRow row = sheet.createRow((short) i); row.createCell((short) 0).setCellValue(rs.getString("ServiceDesc")); row.createCell((short) 1).setCellValue(Integer.toString(rs.getInt("ServiceID"))); row.createCell((short) 2).setCellValue(rs.getString("Cost")); i++; } String ProviderDirectory = "D:/Excel/ProviderDirectory.xls"; FileOutputStream fileOut = new FileOutputStream(ProviderDirectory); workbook.write(fileOut); JOptionPane.showMessageDialog(null, "Directory file has been sent to your email address successfully and saved a .xlsx file at local path D:/Excel/"); fileOut.close(); } catch (SQLException e1) { e1.printStackTrace(); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } }
From source file:chronostone.parser.ChronoStoneParser.java
public static void main(String[] args) throws FileNotFoundException, IOException { String rutaArchivo = System.getProperty("user.home") + "/ChronoStoneSheet.xls"; File archivoXLS = new File(rutaArchivo); if (archivoXLS.exists() == false) { try {// w w w . j a va2 s . com archivoXLS.createNewFile(); } catch (IOException ex) { System.err.println("Error on creating XLS"); } } Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("Chrono Stone Sheet"); /** * Codigo a remover o investigar como hacerlo funcionar de verdad */ int check = check_created(hoja); if (check == xls_index) { inicializar_celdas(hoja); } else { xls_index = check + 1; } String name = ""; System.out.println("Archivo creado: " + rutaArchivo); System.out.println("Introduzca nombre"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); name = br.readLine(); while (!name.equalsIgnoreCase("exit")) { try { tenmakun = new Character(name); name = name.replace(" ", "_"); URLConnection connection = null; connection = new URL(root + name).openConnection(); BufferedReader bf = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line = ""; while ((line = bf.readLine()) != null) { if (line.contains(ONE_STATS) || line.contains(TWO_STATS) || line.contains(AURA_HTML)) { //Primero los stats List<String> stats = new ArrayList<>(); for (int index = 0; index < 13; index++) { stats.add(bf.readLine()); } add_stats(stats); //Y ahora a por las habilidades //add_hissatsu(stats); } else if (line.contains("<a href=\"/wiki/Category:Midfielders\"")) { tenmakun.setPosition(MF); } else if (line.contains("<a href=\"/wiki/Category:Forwards\"")) { tenmakun.setPosition(FW); } else if (line.contains("<a href=\"/wiki/Category:Defenders\"")) { tenmakun.setPosition(DF); } else if (line.contains("<a href=\"/wiki/Category:Goalkeepers\"")) { tenmakun.setPosition(GK); } } } catch (Exception ex) { ex.printStackTrace(); } System.out.println(tenmakun.print_stats()); add_character_sheet(hoja); System.out.println("Personaje aadido al fichero"); System.out.println("Introduzca nombre"); name = br.readLine(); } libro.write(archivo); archivo.close(); libro.close(); }
From source file:clases.Funciones.java
private String GenerateReporte_xls(JTable t, int open) { String rutaArchivo = ""; try {//www . j av a 2 s. c o m char rt = p.ReturnPropiedad(p.Ruta_SaveReports) .charAt(p.ReturnPropiedad(p.Ruta_SaveReports).length() - 1); if ("/".equalsIgnoreCase(String.valueOf(rt))) { rutaArchivo = p.ReturnPropiedad(p.Ruta_SaveReports) + ReturnNombreUsuario().replace(" ", "_") + rutaArchivo + "_" + GetFechaAndHourActual().replace(":", "_").replace(" ", "_").replace("-", "_") + ".xls"; } else { rutaArchivo = p.ReturnPropiedad(p.Ruta_SaveReports) + "/" + ReturnNombreUsuario().replace(" ", "_") + rutaArchivo + "_" + GetFechaAndHourActual().replace(":", "_").replace(" ", "_").replace("-", "_") + ".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(ReturnDatosFisicos(this.Datos_Nombre)); for (int f = 0; f < t.getRowCount() + 1; f++) { Row fila = hoja.createRow(f); for (int c = 0; c < t.getColumnCount(); c++) { Cell celda = fila.createCell(c); if (f == 0) { celda.setCellValue(String.valueOf(t.getColumnName(c))); } else { celda.setCellValue(String.valueOf(t.getValueAt(f - 1, c))); } hoja.autoSizeColumn(c); } } libro.write(archivo); archivo.close(); if (open > 0) { Desktop.getDesktop().open(archivoXLS); } } catch (IOException ex) { Alert(ex.getMessage()); } return rutaArchivo; }
From source file:Clavis.Windows.WShedule.java
public void createXLSDocument(String nome, String[][] valores) { HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(nome); HSSFRow row;/*from w w w.ja v a 2 s . c o m*/ HSSFCell cell; for (int i = 0; i < valores.length; i++) { row = sheet.createRow(i); for (int j = 0; j < valores[i].length; j++) { cell = row.createCell(j); cell.setCellValue(valores[i][j]); if (valores[i][j] != null) { sheet.setColumnWidth(j, 255 * valores[i][j].length() + 4); CellUtil.setAlignment(cell, wb, CellStyle.ALIGN_CENTER); } } } wb.setPrintArea(0, 0, valores[0].length, 0, valores.length); sheet.getPrintSetup().setPaperSize(XSSFPrintSetup.A4_PAPERSIZE); FileOutputStream out; String sfile = new File("").getAbsolutePath() + System.getProperty("file.separator") + nome; File file = new File(sfile); if (!file.exists()) { try { file.createNewFile(); } catch (IOException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); } } if (file.canWrite()) { try { out = new FileOutputStream(file); } catch (FileNotFoundException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); out = null; } if (out != null) { try { wb.write(out); out.close(); if (Desktop.isDesktopSupported()) { Desktop.getDesktop().open(file); } else { Components.MessagePane mensagem = new Components.MessagePane(this, Components.MessagePane.INFORMACAO, painelcor, lingua.translate("Nota"), 400, 200, lingua.translate("O documento \"doc.xls\" foi criado na pasta raiz do programa") + ".", new String[] { lingua.translate("Voltar") }); mensagem.showMessage(); } } catch (IOException ex) { Logger.getLogger(WShedule.class.getName()).log(Level.SEVERE, null, ex); } } } }
From source file:Clientes.editaCliente.java
private void bt_actualiza2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_actualiza2ActionPerformed // TODO add your handling code here: javax.swing.JFileChooser jF1 = new javax.swing.JFileChooser(); jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.xls)", new String[] { "xls" })); String ruta = null;/*from ww w . j a va 2 s. c om*/ if (jF1.showSaveDialog(null) == jF1.APPROVE_OPTION) { ruta = jF1.getSelectedFile().getAbsolutePath(); if (ruta != null) { File archivoXLS = new File(ruta + ".xls"); try { if (archivoXLS.exists()) archivoXLS.delete(); archivoXLS.createNewFile(); Workbook libro = new HSSFWorkbook(); FileOutputStream archivo = new FileOutputStream(archivoXLS); Sheet hoja = libro.createSheet("Clientes"); for (int ren = 0; ren < (t_datos.getRowCount() + 1); ren++) { Row fila = hoja.createRow(ren); for (int col = 0; col < t_datos.getColumnCount(); col++) { Cell celda = fila.createCell(col); if (ren == 0) { celda.setCellValue(columnas[col]); } else { try { celda.setCellValue(t_datos.getValueAt(ren - 1, col).toString()); } catch (Exception e) { celda.setCellValue(""); } } } } libro.write(archivo); archivo.close(); Desktop.getDesktop().open(archivoXLS); } catch (Exception e) { System.out.println(e); JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte"); } } } }
From source file:cn.afterturn.easypoi.excel.ExcelExportUtil.java
License:Apache License
private static Workbook getWorkbook(ExcelType type, int size) { if (ExcelType.HSSF.equals(type)) { return new HSSFWorkbook(); } else if (size < USE_SXSSF_LIMIT) { return new XSSFWorkbook(); } else {// w ww . ja v a 2s .com return new SXSSFWorkbook(); } }