Set Sheet Name Compressed Unicode

In this program we are going to set the sheet name and compress it.

Set Sheet Name Compressed Unicode

In this program we are going to set the sheet name and compress it.

Set Sheet Name Compressed Unicode

Set Sheet Name Compressed Unicode

     

In this program we are going to set the sheet name and compress it.

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 setSheetNameUnicodeDataFormat
  {
  public static void main(String arg[]) {
try{
FileOutputStream out = new FileOutputStream
(
"setSheetNameUnicodeDataFormat.xls");
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
HSSFCellStyle cs = hssfworkbook.createCellStyle();
hssfworkbook.setSheetName(0
"\u0422\u0441\u0422\u043E\u0432\u0430\u044F " 

"\u0421\u0442\u0440\u0437\u043D\u0438\u0447\u043A\u0422"
  HSSFWorkbook.ENCODING_UTF_16 );
hssfworkbook.write(out);
out.close();
}catch(Exception e){}
  }}

The output of the program is given below:

Download this example.