我使用 Apache POI 进行excel文件导出。但我的问题是 autoSizeColumn()方法对日文字符无法正常工作。 它无法显示整个日语句子。请任何人帮助我: - )
这是我的代码。
public class AutoWidthTest {
public static void main(String[] args) throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet spreadsheet = workbook.createSheet("sheet");
XSSFRow row = spreadsheet.createRow(1);
XSSFCell cell = (XSSFCell) row.createCell(1);
cell.setCellValue("日本語日本語日本語日本語日本語");
spreadsheet.autoSizeColumn(1,true);
FileOutputStream out = new FileOutputStream(new File("excelBook.xlsx"));
workbook.write(out);
out.close();
System.out.println("excelBook.xlsx written successfully");
}
}
输出结果为: