Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


VISHAL BABAN KUTE
how make excel
1 Answer(s)      4 years ago
Posted in : Java Beginners


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


Advertisement
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 Tutorials/Questions & Answers:
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
How to Unlock Excel Password
How to Unlock Excel Password  anyone help me how to recover lost Excel file password
Advertisements
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 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
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 
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
how make ID - Ajax
how make ID  how make a ID in eyeball chat
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 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
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
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
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
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 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 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
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 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
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 halo effect
How to make halo effect       Now get ready to learn a simple way to make a halo effect on the picture, follow to make it. Take a picture: Capture any picture to give
How to make a bone, make a bone, a bone
How to make a bone       This example bone design example, It is very easy. If you are looking for, please follow now. New File: Create a new file. Rounded rectangle
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
how to make multiple choice questions
how to make multiple choice questions  I have to make a multiple choice choice using JSP/Servlets. I created a a session bean for the questions and answers. how to associate group of questions to a user? so each user will have
Advertisements
 

 

 

DMCA.com