Sunday Feb 05
Move
Display 0 | 5 | 10 | 15 Stories

Software Tutorials

Topics
Top Story

How to Enable / Disable Autoformat in word 2007

How to Enable / Disable Autoformat in word 2007

  The interface of Office 2007 does does not offer an intuitive tool to enable or disable the autocorrect...

How to use old MSN Messenger without upgrading

  If you dont like the newer version of MSN Live Messenger and want to use the old MSN Messenger...

Software Tutorials

 

Code for Writing a xlsx file in java

(2 votes, average: 3.50 out of 5)





Here is a small code to write xlsx file though java code. 

 

You may need to include some of the jar files like

  • xmlbeans-2.3.0.jar
  • dom4j-1.1.jar
  • poi-ooxml-schemas-3.6-20091214.jar
  • poi-ooxml-3.6-20091214.jar
  • poi-3.6-20091214.jar

You can google it and download and include it along with the below code.

 


import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import org.apache.poi.ss.usermodel.*;

import java.io.*;

public class Start {

 

   

 

    public void WriteData()

    {

        try{

            Workbook[] wbs = new Workbook[] {  new XSSFWorkbook() };

            for(int i=0; i

            {

                Workbook wb = wbs[i];

                 Sheet s = wb.createSheet();

                Row r1=s.createRow(0);

                Cell c1=r1.createCell(0);

                c1.setCellValue("helo");

                c1=r1.createCell(1);

                c1.setCellValue((double)1);

                c1=r1.createCell(2);

                c1.setCellValue((double)3);

                c1=r1.createCell(3);

                c1.setCellFormula("B1+C1");

                String filename = "workbook.xlsx";

                FileOutputStream out = new FileOutputStream(filename);

                wb.write(out);

                out.close();

            }

 

        }catch(Exception e)

        {

            e.printStackTrace();

        }

    }

 

    public static void main(String[] args)

    {

        Start Object=new Start();

        Object.WriteData();

}

}

 

 

You can run the above code and a xlsx file is generated in the local directory. You will find some sample values you can then modify the code as required.

 

If you need any help then you can leave a comment or mail at This e-mail address is being protected from spambots. You need JavaScript enabled to view it



Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! Google! Live! Facebook! Slashdot! Technorati! StumbleUpon! Spurl! Furl! Yahoo! Squidoo! Ask! DZone! Free Joomla PHP extensions, software, information and tutorials.



Comments

B
i
u
Quote
Code
List
List item
URL
Name *
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment

Tag Cloud

Login Form