无法解析符号“ AbstractJExcelView”

时间:2018-11-01 19:20:36

标签: apache-poi jexcelapi apache-poi-4

我正在编写一个简单的spring mvc应用程序,该应用程序以xls格式编写内容:

public class ExcelBuilder extends AbstractJExcelView {

@Override
protected void buildExcelDocument(Map<String, Object> model,
                                  WritableWorkbook workbook, HttpServletRequest request,
                                  HttpServletResponse response) throws Exception {

    // get data model which is passed by the Spring container
    List<User> listBooks = (List<User>) model.get("listuser");

    // create a new Excel sheet
    WritableSheet sheet = workbook.createSheet("User", 0);

    // create header row
    sheet.addCell(new Label(0, 0, "First Name"));
    sheet.addCell(new Label(1, 0, "Second Name"));
    sheet.addCell(new Label(2, 0, "Last Name"));
    sheet.addCell(new Label(3, 0, "Country"));
    sheet.addCell(new Label(4, 0, "ID"));

    // create data rows
    int rowCount = 1;

    for (User aBook : listBooks) {
        sheet.addCell(new Label(0, rowCount, aBook.getFname()));
        sheet.addCell(new Label(1, rowCount, aBook.getSname()));
        sheet.addCell(new Label(2, rowCount, aBook.getLname()));
        sheet.addCell(new Label(3, rowCount, aBook.getCountry()));
        sheet.addCell(new jxl.write.Number(4, rowCount,aBook.getId()));

        rowCount++;
    }
}

我尝试使用以下方法导入“ AbstractJExcelView”类:

import org.springframework.web.servlet.view.document.AbstractJExcelView;

它显示以下内容:

  

找不到符号“ AbstractJExcelView”

我已经将依赖项包含在pom.xml中,

<dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.9</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.9</version>
    </dependency>
    <!-- JExcelAPI library -->
    <dependency>
        <groupId>net.sourceforge.jexcelapi</groupId>
        <artifactId>jxl</artifactId>
        <version>2.6.3</version>
    </dependency>

我有什么需要改变的吗?

0 个答案:

没有答案