Bug 24239

Summary: Can't used tranditional Chinese
Product: POI Reporter: S.Ping Chen <mike62>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P3    
Version: 1.5.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description S.Ping Chen 2003-10-30 04:03:24 UTC
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.*;


/**
*
*
*
*
*@author:S.Ping-Chen
*@date:10/30/2003
*@version:1.0
*/

public class WriteExcel {

	/**
	 * 
	 * Creation date: 10/29/2003
	 * to generate xls file 
	 */
	public void writeExcel() {
			try {
   			
   			File f =new File
("c:"+File.separator+"temp"+File.separator+"test.xls");
   			
   		 	HSSFWorkbook wb = new HSSFWorkbook();
   		 	HSSFSheet sheet = wb.createSheet("UserAccount");
   		 	
   		 	HSSFFont font =wb.createFont();
   		 	font.setFontName("新細明體");
    			//font.setItalic(true);
    			//font.setStrikeout(true);
   		 	HSSFCellStyle cellStyle =wb.createCellStyle(); 
   		 	cellStyle.setFont(font);

   		 	//HSSFCell cell =null;
   		 	//cell.setCellStyle(cellStyle);
   		 	System.out.println("line 165 === "+font.getFontName());
   		 	HSSFRow row =null;
   		 	
   		 	row= sheet.createRow((short)0);
   		 	row.createCell((short)0).setCellValue("公司");
   		 	row.createCell((short)1).setCellValue("使用者");
   		 	row.createCell((short)2).setCellValue("密碼"); 		
	
   			
   		 	// Write the output to a file
   		 	FileOutputStream fileOut = new FileOutputStream(f);
   		 	wb.write(fileOut);
   		 	fileOut.close();
   		 	               
   		}catch(IOException ex){}
	
	}
	
	public static void main(String args[]) {
		   
				WriteExcel vendorInfo =new WriteExcel();	
				vendorInfo.writeExcel();			
		
				
	}	
	
}
Comment 1 S.Ping Chen 2003-10-30 06:21:16 UTC
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.*;


/**
*
*
*
*
*@author:S.Ping-Chen
*@date:10/30/2003
*@version:1.0
*/

public class WriteExcel {

	/**
	 * 
	 * Creation date: 10/29/2003
	 * to generate xls file 
	 */
	public void writeExcel() {
			try {
   			
   			File f =new File
("c:"+File.separator+"temp"+File.separator+"test.xls");
   			
   		 	HSSFWorkbook wb = new HSSFWorkbook();
   		 	HSSFSheet sheet = wb.createSheet("UserAccount");
   		 	
   		 	HSSFFont font =wb.createFont();
   		 	font.setFontName("新細明體");
    			//font.setItalic(true);
    			//font.setStrikeout(true);
   		 	HSSFCellStyle cellStyle =wb.createCellStyle(); 
   		 	cellStyle.setFont(font);

   		 	//HSSFCell cell =null;
   		 	//cell.setCellStyle(cellStyle);
   		 	System.out.println("line 165 === "+font.getFontName());
   		 	HSSFRow row =null;
   		 	
   		 	row= sheet.createRow((short)0);
   		 	row.createCell((short)0).setCellValue("公司");
   		 	row.createCell((short)1).setCellValue("使用者");
   		 	row.createCell((short)2).setCellValue("密碼"); 		
	
   			
   		 	// Write the output to a file
   		 	FileOutputStream fileOut = new FileOutputStream(f);
   		 	wb.write(fileOut);
   		 	fileOut.close();
   		 	               
   		}catch(IOException ex){}
	
	}
	
	public static void main(String args[]) {
		   
				WriteExcel vendorInfo =new WriteExcel();	
				vendorInfo.writeExcel();			
		
				
	}	
	
}
Comment 2 S.Ping Chen 2003-10-30 06:21:54 UTC
import java.io.IOException;
import java.io.File;
import java.io.FileWriter;
import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.*;


/**
*
*
*
*
*@author:S.Ping-Chen
*@date:10/30/2003
*@version:1.0
*/

public class WriteExcel {

	/**
	 * 
	 * Creation date: 10/29/2003
	 * to generate xls file 
	 */
	public void writeExcel() {
			try {
   			
   			File f =new File
("c:"+File.separator+"temp"+File.separator+"test.xls");
   			
   		 	HSSFWorkbook wb = new HSSFWorkbook();
   		 	HSSFSheet sheet = wb.createSheet("UserAccount");
   		 	
   		 	HSSFFont font =wb.createFont();
   		 	font.setFontName("新細明體");
    			//font.setItalic(true);
    			//font.setStrikeout(true);
   		 	HSSFCellStyle cellStyle =wb.createCellStyle(); 
   		 	cellStyle.setFont(font);

   		 	//HSSFCell cell =null;
   		 	//cell.setCellStyle(cellStyle);
   		 	System.out.println("line 165 === "+font.getFontName());
   		 	HSSFRow row =null;
   		 	
   		 	row= sheet.createRow((short)0);
   		 	row.createCell((short)0).setCellValue("公司");
   		 	row.createCell((short)1).setCellValue("使用者");
   		 	row.createCell((short)2).setCellValue("密碼"); 		
	
   			
   		 	// Write the output to a file
   		 	FileOutputStream fileOut = new FileOutputStream(f);
   		 	wb.write(fileOut);
   		 	fileOut.close();
   		 	               
   		}catch(IOException ex){}
	
	}
	
	public static void main(String args[]) {
		   
				WriteExcel vendorInfo =new WriteExcel();	
				vendorInfo.writeExcel();			
		
				
	}	
	
}
Comment 3 S.Ping Chen 2003-10-30 06:44:30 UTC
When I put tranditional Chinese words to the excel file,then I can't get the 
correct format. but english is correct,and when I parsing the excel file use 
Tranditional Chinese is ok,so is any body know how can I use Tranditional 
Chinese when I generate excel file
Comment 4 Avik Sengupta 2003-10-30 16:34:04 UTC
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(myStringContainingChineseCharacters);

Please reopen this bug only if it does not work after this, and you have tried
with the latest version. Thanks.

Also, i am not sure if the use of chinese characters in the font name works.