R4R
Right Place For Right Person TM
 
R4R Right ArrowJavaRight Arrow Java APIsRight ArrowPOI APIRight ArrowPOI APIs Basic Example
Previous Home Next

How to create a new workbook using POI?


Introduction:

In this page of the example we are going to create the workbook with help of the POI APIs in java language. for creation of the workbook we use the method createDocumentInputStream("Workbook").



Descriptions:
 getSid():-
This methods give the description copied from class.

 


SourceCode:

 
package r4r;
import java.io.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.eventusermodel.*;
import org.apache.poi.hssf.record.*;
import org.apache.poi.hssf.dev.EFHSSF;
public class findtypeofworkbook implements HSSFListener {
	public static void main(String[] args) throws IOException
	  {  
	  FileInputStream fis = new FileInputStream(args[0]);
	  POIFSFileSystem pfs = new POIFSFileSystem(fis);
	  InputStream in = pfs.createDocumentInputStream("Workbook");
	  HSSFRequest hreq = new HSSFRequest();
	  hreq.addListenerForAllRecords(new findtypeofworkbook());
	  HSSFEventFactory fact = new HSSFEventFactory();
	  fact.processEvents(hreq, in);
	  fis.close();
	  in.close();
	  System.out.println("STOP");
	  }
	  public void processRecord(Record record)
	  {
	  switch (record.getSid())
	  {
	  case BOFRecord.sid:
	  BOFRecord bof = (BOFRecord) record;
	  if (bof.getType() == bof.TYPE_WORKBOOK)
	  {
	  System.out.println("Workbook");
	  
	  } 
	  break;
	  }
	 }
}




Output of SourceCode:
 

How to create a new workbook using POI?

Previous Home Next
R4R Right ArrowJavaRight Arrow Java APIsRight ArrowPOI APIRight ArrowPOI APIs Basic Example

Tutorials,Examples,Questions and Answer

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R