0
我在Excel文件中讀取日文字符時遇到問題。讀者的構造函數是:在ReadOnlySharedStringsTable中無法正確顯示日文字符
public XExcelFileReader(final String excelPath) throws Exception {
this.opcPkg = OPCPackage.open(excelPath, PackageAccess.READ);
this.stringsTable = new ReadOnlySharedStringsTable(this.opcPkg);
XSSFReader xssfReader = new XSSFReader(this.opcPkg);
XMLInputFactory factory = XMLInputFactory.newInstance();
InputStream inputStream = xssfReader.getSheetsData().next();
this.xmlReader = factory.createXMLStreamReader(inputStream);
while (this.xmlReader.hasNext()) {
this.xmlReader.next();
if (this.xmlReader.isStartElement()) {
if (this.xmlReader.getLocalName().equals("sheetData"))
break;
}
}
}
在這一點上,stringsTable有日本字符,如予算ヨサン
但在Excel文件,它只讀取爲予算
。一些顯示爲它們出現在Excel文件中,但有些則不是。我不確定它出錯的地方,編碼是UTF-8。
我正在閱讀一個大的Excel文件,我曾嘗試創建一個工作簿,但它給出了內存錯誤,所以使用它不是一個選項。
任何想法哪裏可能出錯?
對不起。這是Java。感謝您的注意。 – paaaaat
介意給我一個教訓? :) – paaaaat