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

Programming

Topics
Top Story

Code for Writing a xlsx file in java

Here is a small code to write xlsx file though java code.    You may need to include some of...

Code for Reading a xlsx file in java

Here is a small code to read xlsx file thoug java code.    You may need to include some of the...

How to read and write data from socket in java

   ServerSocket serverSocket=new ServerSocket(port);  // The below statement will wait for the...

Producer Consumer Problem in C using Semaphores and Shared Memory

  The classic bounded-buffer problem can be implemented using a variety of synchronization mechanisms....

Common Intermediate Language

Common Intermediate Language (formerly called Microsoft Intermediate Language or MSIL) is the lowest-level...

Common Type System in C#

Common Language Runtime

A Quick Introduction to C# Features

Code for updating database using hibernate framework in java

Conversion of int to byte and vice versa

Web Crawler in Python

Neural Network in Python

Programming

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