Bug 12603 - Japanese write in error
Summary: Japanese write in error
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 1.5.1
Hardware: Other All
: P3 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-13 05:14 UTC by Dongkai Zhang
Modified: 2005-03-20 17:06 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dongkai Zhang 2002-09-13 05:14:18 UTC
import org.apache.poi.hssf.usermodel.*;


import java.io.IOException;
import java.io.FileOutputStream;

public class NewSheet1
{
    public static void main(String[] args)
        throws IOException
    {
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet1 = wb.createSheet("new sheet");
        HSSFSheet sheet2 = wb.createSheet("second sheet");
        HSSFCellStyle style = wb.createCellStyle();
        HSSFFont font = wb.createFont();
        font.setFontName("‚l‚r ƒSƒVƒbƒN");
        HSSFRow row = sheet1.createRow((short) 1);
        HSSFCell cell = row.createCell((short) 1);
        style.setFont(font);
        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
        cell.setCellStyle(style);
        cell.setCellValue("“ú–{Œê‘‚݂̃eƒXƒg");
        FileOutputStream fileOut = new FileOutputStream("workbook.xls");
        wb.write(fileOut);
        fileOut.close();
    }
}

I write this source,compile,run.
out file(workbook.xls) is ok,but "“ú–{Œê‘‚݂̃eƒXƒg" is show wrong charset.
Comment 1 Dongkai Zhang 2002-09-13 07:46:37 UTC
Add statement "System.out.println(cell.getStringCellValue());" before place of 
file out. output message is "“ú–{Œê‘‚݂̃eƒXƒg".
And I write another source,read one Japanese Excel Template,in new source 
modify some cell value to Japanese String,the out file is wrong again.
I don't know why it happend.  
Comment 2 Yoichi Yamaguchi 2002-09-13 09:31:40 UTC
I added the following statement before cell.setCellValue(String).

      cell.setEncoding(HSSFCell.ENCODING_UTF_16);

It seems to be worked fine.
Comment 3 Dongkai Zhang 2002-09-13 09:56:46 UTC
I see.
My source was wrong,POI can work right.
This is not one Bug,it is my source bug.^o^
Comment 4 Andy Oliver 2002-09-15 03:43:34 UTC
...