Posts

Showing posts from August, 2017

Read Images from a xlsx file using Apache POI

This article is all about how to read and download images inside a file in xlsx format. We will use Apache POI using java. 1. Maven dependencies commons-logging-1.2.jar  commons-collections4-4.1.jar openxml4j-1.0-betapoi-3.16.jar poi-ooxml-3.16.jar poi-ooxml-schemas-3.16.jar xmlbeans-2.6.0.jar servlet-api 2. Sharing java code import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.apache.poi.ss.usermodel.PictureData; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFDrawing; import org.apache.poi.xssf.usermodel.XSSFPicture; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFShape; import org.apache.poi.xssf.usermodel.XSSFSheet; imp...

Read Excel using Apache POI - Exception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException:

Read Excel using Apache POI - Challenges ------------------------------------------------ 1) E xception in thread "main" org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF) Add following maven dependency -- Use poi-ooxml from xlsx files while poi for xls <!-- POI : Excel library -->   <dependency>   <groupId>org.apache.poi</groupId>   <artifactId>poi</artifactId>   <version>${poi.version}</version>   </dependency>   <dependency>        < groupId>org.apache.poi</groupId>           <artifactId>poi-ooxml</artifactId>   ...

Create and write Excel file using Google App Engine

This article explains how you can export data in excel using Google App Engine. 1. Apache POI library -- Here is maven dependency         <dependency>         <groupId>org.apache.poi</groupId>         <artifactId>poi</artifactId>     <version>3.16</version> 2. Download Servlet import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFW...

Git Commands : How to remove all files deleted from index

Remove all deleted files from git index git ls-files --deleted -z | xargs -0 git rm