Home Java Poi Compressed Unicode in Excel Using POI3.0



Compressed Unicode in Excel Using POI3.0
Posted on: March 14, 2008 at 12:00 AM
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.

Related Tags for Compressed Unicode in Excel Using POI3.0:
cstringunicodeormencodingdatauiformmethodsmethodsedformatsetsnameintriathiscodingsetappdetectforpoicallprogramtoautomaticramicaldeprecatedcishautoeilcanuseshortimcininnormcalmnttrsheetniccanic3.0automaticallyallrcicomeproppcatseeatplyisllomamplpregoforcingandarcodcodestrrtsimssriringthshostatiapctsicaicaplpropprndodsodeomogro


More Tutorials from this section

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

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.