Code for Writing a xlsx file in java
Written by Ankur Goel
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
















Comments
Figure out how to effectively integrate the terminology you should use in your Html code labels. Search term usage will help you boost your Search engine optimisation. Search phrases that can be found in label tags are weighted more heavily by search engine listings than search phrases in virtually any other situation. The most effective keywords and phrases must be used for optimum effects.
Use internal backlinks to connect blog sites of a related topic. You will recognize that it will help site visitors relocate concerning the site and maintains them interested. There's nothing at all quite as aggravating as reaching a blog rather than understanding how to get what you will need essay writing http://www.kissmyessays.com custom essays.
You can easily build website traffic by trading backlinks along with other blog owners. Find blogs with content that is certainly connected to your own property, and business hyperlinks. Don't waste time with website link exchanges that are not related to the site's information. Your main concern has to be sketching in guests who will probably put about this may improve your search engine ranking positions considerably.