Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Poi Compressed Unicode in Excel Using POI3.0

Related Tutorials


 
 

Share on Google+Share on Google+

Compressed Unicode in Excel Using POI3.0

Advertisement
In this program we are going to set the sheet name forcing the encoding.

Compressed Unicode in Excel Using POI3.0

     

In this program we are going to set the sheet name forcing the encoding.

The methods can be used for built in data format:


setSheetName(int sheet, String name): 
This method is used to set the sheet name. 

setSheetName(int sheet, String name, short encoding): 
This method is deprecated. In POI 3.0, now automatically detects unicode and sets the encoding appropriately. Simply use setSheetName(int sheet, String encoding)

setSheetName(int sheet, String name):
This method is used to set the sheet name. This method can  throw IllegalArgumentException if the name is greater than 31 chars or contains /\,?,*,[,],etc 

setSheetName( int sheet, String name, short encoding):
This method is also deprecated. Now POI3.0 automatically detects Unicode and sets the encoding appropriately. Simply use setSheetName(int sheet, String encoding) 
 
 The code of the program is given below:
import java.io.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.usermodel.HSSFRow;
class compressedUnicode
  {
  public static void main(String arg[]) {
try{
FileOutputStream out = new FileOutputStream
(
"compressedUnicode.xls");
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
HSSFCellStyle cs = hssfworkbook.createCellStyle();
hssfworkbook.setSheetName(0"HSSF Test"
HSSFWorkbook.ENCODING_COMPRESSED_UNICODE 
);
hssfworkbook.write(out);
out.close();
}catch(Exception e){}
  }}

The output of the program is given below:

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 14, 2008

Related Tutorials

Discuss: Compressed Unicode in Excel Using POI3.0   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com