0

HSSF Excel クラスの文字エンコード方式は、3.8 リリースから削除されたようです。少なくともセルのエンコンディングを指定する必要があります。API はエンコーディング メソッドを登録することさえしません。

新しい POI バージョンでエンコーディングを設定するには?

4

1 に答える 1

3

わかりました、コードからこれを行う方法があり、必要に応じて次のようになります。

//Create the workbook, and the font
HSSFWorkbook wb;
HSSFFont wbFont;
wbFont=wb.createFont();
wbFont.setCharSet(HSSFFont.ANSI_CHARSET); //Your Character encoding goes in the parameter
//Establish cell styles
HSSFCellStyle cellStyle =wb.createCellStyle();
cellStyle.setFont(wbFont);
//We create our cells with our data and with our specified format
HSSFCell cell =null;
cell = row.createCell(1);
cell.setCellStyle(cellStyle);
cell.setCellValue("MY DATA");
//Do the rest for whatever you might need for your workbook and then you create it

これらのクラスは .xls 2003 でのみ機能することに注意してください。

于 2012-10-25T15:41:38.220 に答える