Springmvc-excel
提供:Dev Guides
Spring MVC-Excelの生成の例
次の例は、Spring Web MVCフレームワークを使用してExcelを生成する方法を示しています。 はじめに、作業中のEclipse IDEを用意し、次の手順に従って、Spring Web Frameworkを使用して動的フォームベースのWebアプリケーションを開発します。
Step | Description |
---|---|
1 | Create a project with a name TestWeb under a package com.finddevguides as explained in the Spring MVC - Hello World chapter. |
2 | Create Java classes UserExcelView and ExcelController under the com.finddevguides package. |
3 | Download the Apache POI library Apache POI from the maven repository page. Put it in your CLASSPATH. |
4 | The final step is to create the content of the source and configuration files and export the application as explained below. |
ExcelController.java
UserExcelView.java
TestWeb-servlet.xml
views.xml
ここで、ExcelControllerとExcelViewを作成しました。 Apache POIライブラリはMicrosoft Officeファイル形式を扱い、データをExcelドキュメントに変換します。
ソースファイルと構成ファイルの作成が完了したら、アプリケーションをエクスポートします。 アプリケーションを右クリックし、[エクスポート]→[WARファイル]オプションを使用して、 TestWeb.war ファイルをTomcatのwebappsフォルダーに保存します。
次に、Tomcatサーバーを起動し、標準ブラウザーを使用してwebappsフォルダーから他のWebページにアクセスできることを確認します。 URLを試してください- http://localhost:8080/TestWeb/excel 。次の画面が表示されます。