VISHAL BABAN KUTE
how make excel
1 Answer(s)      2 years and 6 months ago
Posted in : Java Beginners

how make excel spreadsheet IN JAVA. please send this code argently

View Answers

December 21, 2010 at 1:14 PM


Hello Friend,

Try the following code:

  import  java.io.*;  
  import  org.apache.poi.hssf.usermodel.HSSFSheet;  
  import  org.apache.poi.hssf.usermodel.HSSFWorkbook; 
  import  org.apache.poi.hssf.usermodel.HSSFRow;
  import  org.apache.poi.hssf.usermodel.HSSFCell;  

 public class CreateExcelFile{
    public static void main(String[]args){
try{
String filename="c:/hello.xls" ;
HSSFWorkbook hwb=new HSSFWorkbook();
HSSFSheet sheet =  hwb.createSheet("new sheet");

HSSFRow rowhead=   sheet.createRow((short)0);
rowhead.createCell((short) 0).setCellValue("SNo");
rowhead.createCell((short) 1).setCellValue("First Name");
rowhead.createCell((short) 2).setCellValue("Last Name");
rowhead.createCell((short) 3).setCellValue("Username");
rowhead.createCell((short) 4).setCellValue("E-mail");
rowhead.createCell((short) 5).setCellValue("Country");

HSSFRow row=   sheet.createRow((short)1);
row.createCell((short) 0).setCellValue("1");
row.createCell((short) 1).setCellValue("Rose");
row.createCell((short) 2).setCellValue("India");
row.createCell((short) 3).setCellValue("roseindia");
row.createCell((short) 4).setCellValue("hello@roseindia.net");
row.createCell((short) 5).setCellValue("India");

FileOutputStream fileOut =  new FileOutputStream(filename);
hwb.write(fileOut);
fileOut.close();
System.out.println("Your excel file has been generated!");

} catch ( Exception ex ) {
    System.out.println(ex);

}
    }
}

For the above code, you need Apache POI library.

Thanks









Related Pages:
how make excel
how make excel  how make excel spreadsheet IN JAVA. please send this code argently   Hello Friend, Try the following code: import...(filename); hwb.write(fileOut); fileOut.close(); System.out.println("Your excel file
excel
excel  how to read columns values of excel file in java and store in array list in java like col1 col2 2 3 1 7 7 9 then list1 have values of col1 and list2 have values of col2...  
excel
excel  how to save excel sheet data into the database using poi api?   import java.io.*; import java.sql.*; import java.util.*; import java.util.regex.*; import org.apache.poi.hssf.usermodel.
Excel file Handling in Java
Excel file Handling in Java  Hello Sir, I am new to Java, I have Started Java Core by myself. I want to make a project which include 3-4 Excel file to handle.Please explain how to read and write Excel file in Java.Is it tough
How to Unlock Excel Password
How to Unlock Excel Password  anyone help me how to recover lost Excel file password
JDBC to EXcel
JDBC to EXcel  How to insert data in excel sheet from java
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database
How to retrieve file name and path of an excel spreadsheet imported into Oracle Database  I imported an excel spreadsheet using sql developer into my Oracle database and I want to know how to retrieve the path of the file
download excel
download excel  hi i create an excel file but i don't i know how to give download link to that excel file please give me any code or steps to give download link
How to export grid into excel
How to export grid into excel  Hi, i created a grid panel i have to export it to the excel. please help me by some sample code. thanks in advance. cool day dude
How to Create Excel Page Using JSP
how to create excel page using jsp       In this program, we are going to create an excel... number of excel pages. To make an excel page we can use third party POI APIs
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
JSP TO EXCEL
JSP TO EXCEL  Hi sir/mam, How to import data to excel using jsp without retrieving database.   friend, you can't import excel data into the middle of an HTML pages (your JSP will result in an HTML page
make header and footer and attache it with excel sheet.
 make header and footer and attache it with excel sheet.       In this example we make header and footer and attaché it with excel sheet.  Code description 
Excel sheet in read only mode - WebSevices
make changes.But that i dont want,Also i have checked the permission in excel sheet,It has both read and write permission. How can i make the excel sheet...Excel sheet in read only mode  If am opening an excel sheet(through
How to save data to excel with a 2.1 work sheet format without changing it?
How to save data to excel with a 2.1 work sheet format without changing... ? i tried to make the default type 2.1 work sheet from excel tools but didnt work... and save it to excel file then read it again .. the problem is , when data
export data to excel sheet - JSP-Servlet
export data to excel sheet  Hi.. how to export data to excel sheet from jsp? and how to update the excel sheet from jsp? and how to get the data from excel sheet? and how to make calculations in excel sheet like total avg
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
how make ID - Ajax
how make ID  how make a ID in eyeball chat
how to make this pattern???
how to make this pattern???  how to make following pattern in javascript
How to make elements invisible ?
How to make elements invisible ?   How to make elements invisible
To Generate Excel
With EXCEL in it has to open up how can i achieve this pls explain
convert excel into pdf
convert excel into pdf  How to convert excel into pdf files
how to make exampage in jsp ?
how to make exampage in jsp ?  how to make a online exam page in jsp and servelet
how to display data in excel sheet?
how to display data in excel sheet?  According to the user Id,some... there will be a button called excel download,and if we click the button data will be displayed in excel sheet.can you people please help me how to create
excel to database
excel to database   How to export data from excel sheet to mysql database by using java with request parameter Here q=40 is a request parameter ..request parameter using i export the all data to database   <
how to make a program on array
how to make a program on array  When you make a program on array that the element will move downward and upward and when you input twice 0 then thats the time that it will not move. pls. give me a formula...tnx
How to make selectOneMenu scrollable
How to make selectOneMenu scrollable  how to make the selectOneMenu scrollable? I have around 20 values in drop down and i want the scrollable functionality after 5 values. Kindly reply as soon as possible. Thanks Shikha
struts2 excel downloads
struts2 excel downloads  hi friend, how to set Timestamps(Date+time) values to excel sheet cells
Excel Column change
Excel Column change  How to change sequence of columns in Excel sheet through Java
How to insert rows from Excel spreadsheet into database by browsing the excel file?
How to insert rows from Excel spreadsheet into database by browsing the excel file?  I want to insert rows from excel sheet to database.for this i... the excel file using file browsing dialogue through form in JSP. How can i select
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
how to make multiple rectangles
how to make multiple rectangles  I,m a beginner , m sorry if the question is really simple i have an array list.I want to print the contents...(JFrame.EXIT_ON_CLOSE); //Set JFrame size setSize(400,400); //Make JFrame
make setup
make setup  i've made jbuilder application how could make autorun or jar executable for this application? waiting your answers soon
how to make paging with function ?
how to make paging with function ?  how to make paging with function ?   //this page is display.php <?php</p> $con=mysql_connect("localhost","root",""); if(!$con) { die("you can connect please check". mysql
how to connect xlsx(2007 excel) - JDBC
how to connect xlsx(2007 excel)  i am not able connect to office 2007 excel file from jdbc
How to read excel contents when uploaded
How to read excel contents when uploaded  I am working on a project where the user uploads his excel file. Jsp page must read the excel contents... files.Please do help..   user logins and he uploads his excel file. the excel
currency symbols in excel
currency symbols in excel  How to add a currency symbol in Excel sheet? Please guide me
Zoom in Excel
zoom in excel       In this program we are going to make a java program through which we can zoon in(-)  an excel sheet. By this means you can make an excel sheet
how to make a field left justification
how to make a field left justification  how to make a field left justification.need code.thanks in advance
how to make a label left alignment?
how to make a label left alignment?  how to make a label left alignment
How to make a chain, make a chain, chain
How to make a chain       To learn how to design a chain in the photoshop has become so easy by this example, it has some important instruction to make it so follow
how to make paging with class and ajax
how to make paging with class and ajax  paging with class and ajax
How to make bubbles, make bubbles, bubbles
How to make bubbles      ... to make it easily to draw. New File: First take colored background file. Draw... Overlay, use same both settings as given below. Duplicate: Now make
connect jdbc to an Excel spreadsheet
connect jdbc to an Excel spreadsheet  hello, How can I connect to an Excel spreadsheet file using jdbc?   Hello Friend, Follow... Excel Driver(*.xls) Select work book or excel file and Create the DSN name (e.g
Excel - JSP-Servlet
Excel  How to export data from jsp to excel sheet. I am using struts1.2 in my application.  Hi friend, Code to data from Jsp to excel...: "success.jsp" For more information on excel sheet Using JSP visit
How to make directory in java
Description: This example demonstrate how to create a directory at specified path. Code: import java.io.File; public ... is that it will make a dir at root directory of C drive
How to export chart(graph) generated by jsp into a excel?
How to export chart(graph) generated by jsp into a excel?  How to export chart(graph) generated by jsp into a excel? I have a jsp page which generates charts . Now I need those charts to be exported into an excel.please help
How to make a transparent text
How to make a transparent text Learn how to make a transparent...) and make formatting as looking here. Write Text: Now write your text as you like. I have written here "Text". After writing text make copy (Ctr
Make A website
Make A website  How expensive(hire someone) or hard would it be to create a website like this? I want to build a website where people can be users of the website with a small profile. Their is a point system (kinda like money
how to present the excel to the web browser in jsp
how to present the excel to the web browser in jsp  How to present the content of the newly created excel file in the following jsp to the web...="org.apache.poi.xssf.usermodel.XSSFWorkbook"%> <%@ page contentType="application/vnd.ms-excel