fixed JExcel example code (SPR-7277)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3412 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Juergen Hoeller 2010-06-11 10:49:41 +00:00
parent a56df735de
commit b2f90a6be9
1 changed files with 12 additions and 12 deletions

View File

@ -1973,17 +1973,17 @@ public class HomePage extends AbstractExcelView {
// Go to the first sheet // Go to the first sheet
// getSheetAt: only if wb is created from an existing document // getSheetAt: only if wb is created from an existing document
//sheet = wb.getSheetAt( 0 ); // sheet = wb.getSheetAt(0);
sheet = wb.createSheet("Spring"); sheet = wb.createSheet("Spring");
sheet.setDefaultColumnWidth((short)12); sheet.setDefaultColumnWidth((short) 12);
// write a text at A1 // write a text at A1
cell = getCell( sheet, 0, 0 ); cell = getCell(sheet, 0, 0);
setText(cell,"Spring-Excel test"); setText(cell, "Spring-Excel test");
List words = (List ) model.get("wordList"); List words = (List) model.get("wordList");
for (int i=0; i < words.size(); i++) { for (int i=0; i < words.size(); i++) {
cell = getCell( sheet, 2+i, 0 ); cell = getCell(sheet, 2+i, 0);
setText(cell, (String) words.get(i)); setText(cell, (String) words.get(i));
} }
@ -1997,7 +1997,7 @@ public class HomePage extends AbstractExcelView {
// imports omitted for brevity // imports omitted for brevity
public class HomePage extends AbstractExcelView { public class HomePage extends AbstractJExcelView {
protected void buildExcelDocument(Map model, protected void buildExcelDocument(Map model,
WritableWorkbook wb, WritableWorkbook wb,
@ -2005,13 +2005,13 @@ public class HomePage extends AbstractExcelView {
HttpServletResponse response) HttpServletResponse response)
throws Exception { throws Exception {
WritableSheet sheet = wb.createSheet("Spring"); WritableSheet sheet = wb.createSheet("Spring", 0);
sheet.addCell(new Label(0, 0, "Spring-Excel test"); sheet.addCell(new Label(0, 0, "Spring-Excel test"));
List words = (List)model.get("wordList"); List words = (List) model.get("wordList");
for (int i = -; i < words.size(); i++) { for (int i = 0; i < words.size(); i++) {
sheet.addCell(new Label(2+i, 0, (String)words.get(i)); sheet.addCell(new Label(2+i, 0, (String) words.get(i)));
} }
} }
}</programlisting> }</programlisting>