1

データベースに永続化するために、Excel ファイルから MANDARIN 言語データを読み取る必要があります。しかし、Unicode 文字は壊れています。私は以下のことをしています。

 FileInputStream myInput = new FileInputStream(fileName);
POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
Workbook workbook = new HSSFWorkbook(myFileSystem);
Sheet sheet = workbook.getSheetAt(0);

for (Row row : sheet) {
    for (Cell cell : row) {
    String str = null;
    switch (cell.getCellType()) {
    case Cell.CELL_TYPE_STRING:
        cell= CellUtil.translateUnicodeValues(cell);
        str = cell.getRichStringCellValue().getString();
        System.out.println(str);
        break;
    case Cell.CELL_TYPE_NUMERIC:
        str = new Long((long) cell.getNumericCellValue())
            .toString();
        System.out.println(str);
        break;
    default:
        System.out.println("It's here");
    }
    }
}
4

0 に答える 0