下面列出了怎么用org.springframework.core.io.support.LocalizedResourceHelper的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Create the workbook from an existing XLS document.
* @param url the URL of the Excel template without localization part nor extension
* @param request current HTTP request
* @return the template workbook
* @throws Exception in case of failure
*/
protected Workbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
LocalizedResourceHelper helper = new LocalizedResourceHelper(getApplicationContext());
Locale userLocale = RequestContextUtils.getLocale(request);
Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
// Create the Excel document from the source.
if (logger.isDebugEnabled()) {
logger.debug("Loading Excel workbook from " + inputFile);
}
return Workbook.getWorkbook(inputFile.getInputStream());
}
/**
* Creates the workbook from an existing XLS document.
* @param url the URL of the Excel template without localization part nor extension
* @param request current HTTP request
* @return the HSSFWorkbook
* @throws Exception in case of failure
*/
protected HSSFWorkbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
LocalizedResourceHelper helper = new LocalizedResourceHelper(getApplicationContext());
Locale userLocale = RequestContextUtils.getLocale(request);
Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
// Create the Excel document from the source.
if (logger.isDebugEnabled()) {
logger.debug("Loading Excel workbook from " + inputFile);
}
return new HSSFWorkbook(inputFile.getInputStream());
}
protected Workbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
LocalizedResourceHelper helper = new LocalizedResourceHelper(getApplicationContext());
Locale userLocale = RequestContextUtils.getLocale(request);
Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
// Create the Excel document from the source.
if (logger.isDebugEnabled()) {
logger.debug("Loading Excel workbook from " + inputFile);
}
//POIFSFileSystem fs = new POIFSFileSystem(inputFile.getInputStream());
return new XSSFWorkbook(inputFile.getInputStream());
}
/**
* Create the workbook from an existing XLS document.
* @param url the URL of the Excel template without localization part nor extension
* @param request current HTTP request
* @return the template workbook
* @throws Exception in case of failure
*/
protected Workbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
LocalizedResourceHelper helper = new LocalizedResourceHelper(getApplicationContext());
Locale userLocale = RequestContextUtils.getLocale(request);
Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
// Create the Excel document from the source.
if (logger.isDebugEnabled()) {
logger.debug("Loading Excel workbook from " + inputFile);
}
return Workbook.getWorkbook(inputFile.getInputStream());
}
/**
* Creates the workbook from an existing XLS document.
* @param url the URL of the Excel template without localization part nor extension
* @param request current HTTP request
* @return the HSSFWorkbook
* @throws Exception in case of failure
*/
protected HSSFWorkbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
LocalizedResourceHelper helper = new LocalizedResourceHelper(getApplicationContext());
Locale userLocale = RequestContextUtils.getLocale(request);
Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
// Create the Excel document from the source.
if (logger.isDebugEnabled()) {
logger.debug("Loading Excel workbook from " + inputFile);
}
return new HSSFWorkbook(inputFile.getInputStream());
}
/**
* Create the workbook from an existing XLS document.
* @param url the URL of the Excel template without localization part nor extension
* @param request current HTTP request
* @return the template workbook
* @throws Exception in case of failure
*/
protected Workbook getTemplateSource(String url, HttpServletRequest request) throws Exception {
LocalizedResourceHelper helper = new LocalizedResourceHelper(getApplicationContext());
Locale userLocale = RequestContextUtils.getLocale(request);
Resource inputFile = helper.findLocalizedResource(url, EXTENSION, userLocale);
// Create the Excel document from the source.
if (logger.isDebugEnabled()) {
logger.debug("Loading Excel workbook from " + inputFile);
}
return Workbook.getWorkbook(inputFile.getInputStream());
}