Pages Navigation Menu

Coding is much easier than you think

Java -XLS -XLSX -CSV- Quries

Export Grid View to Excel in Servlet and Jsp

Posted by on Sep 21, 2013 in J2EE, Java, Java Excel, Servlet | 0 comments

Exporting contents to excel spreadsheet is a much required functionality for almost every data driven website. In this article I am going to explain in detail on how to export gridview contents to an excel sheet via a java web application.     Project Structure     Servlet   package servlet; import java.io.IOException; import java.util.ArrayList; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import...

read more

Java code to convert xlsx & xls to csv

Posted by on Mar 16, 2013 in CSV, Java, Java Excel | 3 comments

  Note : This Program uses XSSFWorkbook for xlsx and HSSFWorkbook for xlx.   package com.simplecode.excel; import java.io.*; import java.util.Iterator; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; class ExcelToCSV { static void convertToXlsx(File inputFile, File outputFile)...

read more

Java Code to Convert XLSX to CSV Files

Posted by on Mar 16, 2013 in CSV, Java, Java Excel | 19 comments

Java Code to Convert XLSX to CSV Files

  Note : xlsx file should contain only data in cells. No image and any other media element. This program has been developed only for cell data   package com.simplecode.excel; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; class XlsxtoCSV { static void xlsx(File...

read more

Converting XLS to CSV files Using Java

Posted by on Mar 16, 2013 in CSV, Java, Java Excel | 13 comments

Converting XLS to CSV files Using Java

  package com.simplecode.excel; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; class XlstoCSV { static void xls(File inputFile, File outputFile) { // For storing data into CSV files StringBuffer data =...

read more

Java Code to Read XLS and XLSX Files

Posted by on Mar 10, 2013 in Java Excel | 18 comments

  Note : This Program uses XSSFWorkbook for xlsx and HSSFWorkbook for xlx.   package com.simplecode.excel; import java.io.*; import java.util.Iterator; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; class ExcelReader { static void readXlsx(File inputFile) { try { // Get...

read more

Read Excel with Java (Jexcel-api)

Posted by on Feb 17, 2013 in Java, Java Excel | 0 comments

Read Excel with Java  (Jexcel-api)

  In our previous article we have In our next article I have implemented Write Excel in Java using Jexcel-api in this article demonstrate how to read Excel files with the Java Excel API.   Since I have explained about Jexcel api in my previous article, so I’m not going to explain here again.   Download – Java Excel library   package com.simplecode.reader; import java.io.File; import java.io.IOException; import jxl.Cell; import jxl.CellType; import jxl.Sheet; import...

read more

Write Excel with Java (Jexcel-api)

Posted by on Feb 16, 2013 in Java, Java Excel | 2 comments

Write Excel with Java (Jexcel-api)

  This article demonstrate how to create Excel files with the Java Excel API.   ExcelApi – one of a number of open-source java Excel API, designed for reading, writing, and editing of dynamic excel. Among its features are: Reading from the book Excel 95, 97, 2000, XP, and 2003 Reading and writing formulas Creating a list in Excel 2000 Support for formatting fonts, numbers and dates Support colors, borders, and colors of cells Changing existing books excel Localization support Copying charts Copying and pasting drawings Logging...

read more

Java code to Auto size columns in Excel files created with Apache POI

Posted by on Sep 9, 2012 in Java, Java Excel | 4 comments

Java code to Auto size columns in Excel files created with Apache POI

  This was the reports created by my java application and it turned out to be quite irritating as the columns are not auto sized.     The solution to the above problem is you just need to call a method to auto fit the column width. Here is the code to auto size the first 5 columns of the spread sheet.   HSSFSheet sheet = workBook.createSheet("testXls"); // Code to Auto size the column widths for(int columnPosition = 0; columnPosition< 5; columnPosition++) { ...

read more