Cannot resolve symbol "AbstractJExcelView"

273 views Asked by At

I am writing a simple spring mvc application that writes the content in the xls format:

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++;
    }
}

I tried to import the class "AbstractJExcelView" using:

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

It is showing the following:

Cannot find the Symbol "AbstractJExcelView"

I have included the dependency in the pom.xml as:

<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>

Is there anything I should change?

0

There are 0 answers