Pages Navigation Menu

Coding is much easier than you think

Java -XLS -XLSX -CSV- Quries

Java code to convert xlsx & xls to csv

Posted by in CSV, Java, Java Excel | 1 comment

Java code to convert xlsx & xls to csv

  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 in CSV, Java, Java Excel | 10 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 in CSV, Java, Java Excel | 4 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 in Java Excel | 4 comments

Java Code to Read XLS and XLSX Files

  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 the...

read more

Read Excel with Java (Jexcel-api)

Posted by in Java, Java Excel

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 in Java, Java Excel

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 in Java, Java Excel | 1 comment

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