Polishing
This commit is contained in:
@@ -26,7 +26,6 @@ import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.LocalizedResourceHelper;
|
||||
@@ -172,8 +171,7 @@ public abstract class AbstractExcelView extends AbstractView {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Loading Excel workbook from " + inputFile);
|
||||
}
|
||||
POIFSFileSystem fs = new POIFSFileSystem(inputFile.getInputStream());
|
||||
return new HSSFWorkbook(fs);
|
||||
return new HSSFWorkbook(inputFile.getInputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +192,7 @@ public abstract class AbstractExcelView extends AbstractView {
|
||||
* <p>Creates the row and the cell if they still doesn't already exist.
|
||||
* Thus, the column can be passed as an int, the method making the needed downcasts.
|
||||
* @param sheet a sheet object. The first sheet is usually obtained by workbook.getSheetAt(0)
|
||||
* @param row thr row number
|
||||
* @param row the row number
|
||||
* @param col the column number
|
||||
* @return the HSSFCell
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,7 +27,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Jasper Reports view class that allows for the actual rendering format
|
||||
* JasperReports view class that allows for the actual rendering format
|
||||
* to be specified at runtime using a parameter contained in the model.
|
||||
*
|
||||
* <p>This view works on the concept of a format key and a mapping key.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,6 @@ import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -59,8 +58,6 @@ import static org.junit.Assert.*;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExcelViewTests {
|
||||
|
||||
private MockServletContext servletCtx;
|
||||
|
||||
private MockHttpServletRequest request;
|
||||
|
||||
private MockHttpServletResponse response;
|
||||
@@ -70,7 +67,7 @@ public class ExcelViewTests {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
servletCtx = new MockServletContext("org/springframework/web/servlet/view/document");
|
||||
MockServletContext servletCtx = new MockServletContext("org/springframework/web/servlet/view/document");
|
||||
request = new MockHttpServletRequest(servletCtx);
|
||||
response = new MockHttpServletResponse();
|
||||
webAppCtx = new StaticWebApplicationContext();
|
||||
@@ -99,8 +96,7 @@ public class ExcelViewTests {
|
||||
|
||||
excelView.render(new HashMap<String, Object>(), request, response);
|
||||
|
||||
POIFSFileSystem poiFs = new POIFSFileSystem(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFWorkbook wb = new HSSFWorkbook(poiFs);
|
||||
HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
assertEquals("Test Sheet", wb.getSheetName(0));
|
||||
HSSFSheet sheet = wb.getSheet("Test Sheet");
|
||||
HSSFRow row = sheet.getRow(2);
|
||||
@@ -134,8 +130,7 @@ public class ExcelViewTests {
|
||||
excelView.setUrl("template");
|
||||
excelView.render(new HashMap<String, Object>(), request, response);
|
||||
|
||||
POIFSFileSystem poiFs = new POIFSFileSystem(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFWorkbook wb = new HSSFWorkbook(poiFs);
|
||||
HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFSheet sheet = wb.getSheet("Sheet1");
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
HSSFCell cell = row.getCell(0);
|
||||
@@ -168,8 +163,7 @@ public class ExcelViewTests {
|
||||
excelView.setUrl("template");
|
||||
excelView.render(new HashMap<String, Object>(), request, response);
|
||||
|
||||
POIFSFileSystem poiFs = new POIFSFileSystem(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFWorkbook wb = new HSSFWorkbook(poiFs);
|
||||
HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFSheet sheet = wb.getSheet("Sheet1");
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
HSSFCell cell = row.getCell(0);
|
||||
@@ -202,8 +196,7 @@ public class ExcelViewTests {
|
||||
excelView.setUrl("template");
|
||||
excelView.render(new HashMap<String, Object>(), request, response);
|
||||
|
||||
POIFSFileSystem poiFs = new POIFSFileSystem(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFWorkbook wb = new HSSFWorkbook(poiFs);
|
||||
HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(response.getContentAsByteArray()));
|
||||
HSSFSheet sheet = wb.getSheet("Sheet1");
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
HSSFCell cell = row.getCell(0);
|
||||
|
||||
Reference in New Issue
Block a user