Bug 24239 - Can't used tranditional Chinese
Summary: Can't used tranditional Chinese
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 1.5.1
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-10-30 04:03 UTC by S.Ping Chen
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.