我需要从 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");
}
}
}