0

我正在编写一个简单的 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>

有什么我应该改变的吗?

4

0 回答 0