2016-01-22 31 views
0

我們正在將項目從Jxls 1.x遷移到Jxls 2.2.8。在我們當前的模板中,我們使用Spring MessageSource來使用messageSource.getMessage(「message.key」,locale)本地化報表的標題。它適用於1.x版本,但在2.x版本中不能解析消息。從Jxls遷移到Jxls2方法調用

This is our current template

消息分辨率時,該方法有參數,但是當我們調用toString()方法在爲messageSource反對它的工作原理和打印單元格中的字符串失敗。

我們班的代碼是:

public void convertToXLS(final Map<String, Object> p_model, final InputStream p_template, final OutputStream p_file, final Locale p_locale) throws InvalidFormatException, IOException { 
    DeviceEventsDownloadWebModel deviceEventsDownloadWebModel = (DeviceEventsDownloadWebModel) p_model.get("deviceEventsDownloadWebModel"); 

Context context = new Context(); 
context.putVar("messageSource", getMessageSource()); 
context.putVar("locale", p_locale); 
context.putVar("deviceEvents", deviceEventsDownloadWebModel.getDeviceEvents()); 

JxlsHelper.getInstance().processTemplate(p_template, p_file, context); 
} 

任何sugestion來解決這個問題?我們也嘗試將messageSource設置爲一個函數,但它不起作用。

回答

0

解決!我們發現了這個問題。 MessageSource類中的getMessage()方法具有簽名:String key,Object []參數,Locale locale,並且我們只傳遞2個參數。

相關問題