今天是中秋节哟~~
--------------------------------------------
这2天一直在努力解决ecside2.0RC1在weblogic8.1.6环境下导出xls,csv 文件为空的情况~
期间 xiaotiaotiao 的一篇帖子给我不少灵感~
-------------------------------------
在1.3版本里对比看了下
发现XlsView里面的用到的outputstream
改为1.3版本的ByteArrayOutputStream
同时在beforeBody里改为outputStream=new ByteArrayOutputStream
-----------------------------------------------------------
于是我就尝试改了一下csvView.java结果成功了~开心了半天~
但是,用同样方法的处理xlsView.java却一直不成功,继续郁闷......
今天,我干脆从头到尾把csvView,xlsView做了一下比较和研究~发现xlsView是比csvView缩水处理了~~呵呵
注意原版xlsView和csvView在以下片段不同~
private ByteArrayOutputStream outputStream ;
private ByteArrayOutputStream outputStreamOut;
private PrintWriter out =null;
csvView 是定义了以上3个供输出的属性~而xlsView只有 outputStream 这一个!!
今天偶然又看了一下XlsViewResolver.java文件。。发现问题了~~~居然里面的代码给注释掉了...
这时候我在看xlsView的afterBody方法 发现直接返回outputStream对象~~
********************************************************
可能fins的本来的想法是直接把xls流提交给IE浏览器,让它自己解析出XLS文件下载~
没有使用PrintWriter方法输出!!事实证明TOMCAT5.5是可以的,WEBLOGIC就不可以~
********************************************************
好了,问题找到了·解决起来就快了~~~~
参考CsvView,CsvViewResolver对XlsView,XlsViewResolver做了修改
总结如下(Weblogic8.1.6,JDK1.4环境;TOMCAT 5.5 JDK1.6环境全部通过):

/**//* Copyright 2006-2007 original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ecside.view;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import jxl.Cell;
import jxl.Workbook;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
import jxl.format.CellFormat;
import jxl.format.Colour;
import jxl.write.Blank;
import jxl.write.Label;
import jxl.write.Number;
import jxl.write.NumberFormat;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.ecside.common.log.LogHandler;
import org.ecside.core.ECSideContext;
import org.ecside.core.TableModel;
import org.ecside.core.bean.Column;
import org.ecside.preferences.PreferencesConstants;
import org.ecside.table.calc.CalcResult;
import org.ecside.table.calc.CalcUtils;
import org.ecside.util.ECSideUtils;
import org.ecside.util.ExportViewUtils;
import org.ecside.util.ExtremeUtils;
import org.htmlparser.Node;
import org.htmlparser.NodeFilter;
import org.htmlparser.Parser;
import org.htmlparser.nodes.TagNode;
import org.htmlparser.tags.TableColumn;
import org.htmlparser.tags.TableRow;
import org.htmlparser.tags.TableTag;
import org.htmlparser.util.NodeList;


/** *//**
* @author Wei Zijun
* @editor by pharaohsprince 法老
* http://blog.csdn.net/pharaohsprince
* 2007.09.25 中秋节
*/


/** *//**
* com.extremecomp.table.view.XlsView.java -
*
* @author paul horn
*/


public class XlsView implements View ...{
private Log logger = LogFactory.getLog(XlsView.class);
public static final int WIDTH_MULT = 240; // width per char
public static final int MIN_CHARS = 8; // minimum char width
public static final short DEFAULT_FONT_HEIGHT = 8;
public static final double NON_NUMERIC = -.99999;
public static final String DEFAULT_MONEY_FORMAT = "$###,###,##0.00";
public static final String DEFAULT_PERCENT_FORMAT = "##0.0%";
public static final String NBSP = " ";
public static final int colWidth=15;

private WritableWorkbook wb;
private WritableSheet sheet;

private int rownum;
private short cellnum;

private String moneyFormat;
private String percentFormat;
private ByteArrayOutputStream outputStream ;
private ByteArrayOutputStream outputStreamOut;
private PrintWriter out =null;
private String encoding;


public XlsView() ...{
encoding=ECSideContext.ENCODING;
}


public void beforeBody(TableModel model) ...{
logger.debug("XlsView.init()");
outputStream=new ByteArrayOutputStream();
outputStreamOut=outputStream;
out=new PrintWriter(outputStream);
moneyFormat = model.getPreferences().getPreference(PreferencesConstants.TABLE_EXPORTABLE + "format.money");

if (StringUtils.isEmpty(moneyFormat)) ...{
moneyFormat = DEFAULT_MONEY_FORMAT;
}
percentFormat = model.getPreferences().getPreference(PreferencesConstants.TABLE_EXPORTABLE + "format.percent");

if (StringUtils.isEmpty(percentFormat)) ...{
percentFormat = DEFAULT_PERCENT_FORMAT;
}

// encoding = model.getExportHandler().getCurrentExport().getEncoding();


try ...{
wb = Workbook.createWorkbook(outputStream);
sheet = wb.createSheet("Export Workbook",0);
createHeader(model);
// int totalCol=model.getColumnHandler().getColumns().size();

rownum++;
String extendRowBefore=(String)(model.getTable().getAttribute("ExtendRowBefore"));
rownum+=createRow(sheet, getRows(extendRowBefore,encoding),(CellFormat)WritableWorkbook.NORMAL_STYLE, rownum,0)-1;

} catch (Exception e) ...{
LogHandler.errorLog(logger, e);
}
}

public static TableRow[] getRows(String inputHtml,String encode) throws Exception ...{

if (StringUtils.isBlank(inputHtml))...{
return null;
}
inputHtml=inputHtml.trim();

if (!inputHtml.startsWith("<table>")&&!inputHtml.startsWith("<TABLE>") )...{
inputHtml="<table>"+inputHtml+"</table>";
}
Parser parser = Parser.createParser(inputHtml, encode);

NodeList nodes = parser.extractAllNodesThatMatch(new NodeFilter() ...{

public boolean accept(Node node) ...{
return node instanceof TagNode;
}
});
TagNode node = (TagNode)nodes.elementAt(0);
return ((TableTag)node).getRows();
}

public static int getColumnNum(TableRow row)...{
int totalCol=0;
TableColumn[] columns=row.getColumns();

for (int cn=0;cn<columns.length;cn++)...{
String colspan=columns[cn].getAttribute("colspan");

if (colspan!=null&&colspan.length()>0)...{

try...{
totalCol+=Integer.parseInt(colspan);
continue;

}catch(Exception e)...{}
}
totalCol++;
}
return totalCol;
}

public static int createRow(WritableSheet sheet,TableRow[] tableRows,CellFormat cellFormat,int startRow,int startCol) throws RowsExceededException, WriteException...{


if (tableRows==null||tableRows.length<1) ...{ return 0; }
int totalCol=getColumnNum(tableRows[0]);
// CellFormat cellFormat=(CellFormat)WritableWorkbook.NORMAL_STYLE;
int colWidth=15;
List mergeCells=new ArrayList();

for (int rowNo=startRow;rowNo<startRow+tableRows.length;rowNo++ )...{
int idx=0;

for (int colNo=startCol;colNo<startCol+totalCol;colNo++)...{
Cell cell=sheet.getCell(colNo,rowNo);

if (cell instanceof Blank) ...{
continue;
}
TableColumn tdBean=((TableRow)tableRows[rowNo-startRow]).getColumns()[idx];
String title=ECSideUtils.specialHTMLToShowTEXT(tdBean.toPlainTextString());
Label label=new Label(colNo,rowNo,title,cellFormat);
sheet.addCell(label);
sheet.setColumnView(colNo, colWidth);
idx++;
int ce=Integer.parseInt(ECSideUtils.convertString(tdBean.getAttribute("colspan"),"1"))-1;
int re=Integer.parseInt(ECSideUtils.convertString(tdBean.getAttribute("rowspan"),"1"))-1;

if (ce>=1 || re>=1)...{
ce=ce<0?0:ce;
re=re<0?0:re;

mergeCells.add(new int[]...{colNo,rowNo,colNo+ce,rowNo+re});

if (ce<1 && re>=1)...{

for (int srowNo=1;srowNo<=re; srowNo++)...{
sheet.addCell(new Blank(colNo,rowNo+srowNo));
sheet.setColumnView(colNo, colWidth);
}
continue;

}else if (re<1 && ce>=1)...{

for (int scolNo=1;scolNo<=ce;scolNo++)...{
sheet.addCell(new Blank(colNo+scolNo,rowNo));
sheet.setColumnView(colNo+scolNo, colWidth);
}
colNo+=ce;
continue;

}else if (ce>=1 && re>=1)...{

for (int scolNo=1;scolNo<=ce;scolNo++)...{

for (int srowNo=1;srowNo<=re; srowNo++)...{
sheet.addCell(new Blank(colNo+scolNo,rowNo+srowNo));
sheet.setColumnView(colNo+scolNo, colWidth);
}
}
colNo+=ce;
continue;
}
}
}

}


for (int i=0;i<mergeCells.size();i++)...{
int[] mc=(int[])mergeCells.get(i);
sheet.mergeCells(mc[0],mc[1],mc[2],mc[3]);
}

return tableRows.length;
}

private void createHeader(TableModel model) throws RowsExceededException, WriteException ...{
rownum = 0;
cellnum = 0;
int etr=0;
//HSSFRow row = sheet.createRow(rownum);

WritableCellFormat cellFormat=new WritableCellFormat();
WritableFont arial10font = new WritableFont(WritableFont.ARIAL,WritableFont.DEFAULT_POINT_SIZE,WritableFont.BOLD);
cellFormat.setBackground(Colour.GRAY_25);
cellFormat.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.GRAY_50);
cellFormat.setFont(arial10font);
boolean showHeader=model.getTable().isShowHeader();

List columns = model.getColumnHandler().getHeaderColumns();

String extendRowTop=(String)(model.getTable().getAttribute("ExtendRowTop"));

try ...{
etr=createRow(sheet, getRows(extendRowTop,encoding),cellFormat, rownum,0);

} catch (Exception e) ...{
LogHandler.warnLog(logger, e);
etr=0;
}
rownum+=etr;


if (showHeader || etr<1)...{

for (Iterator iter = columns.iterator(); iter.hasNext();) ...{
Column column = (Column) iter.next();
String title = column.getCellDisplay();
Label label=new Label(cellnum,rownum,title,cellFormat);
sheet.addCell(label);
int valWidth = (title + "").length() ;
valWidth=1;
sheet.setColumnView(cellnum, valWidth*colWidth);
cellnum++;
}

}else...{

if (rownum>0)...{
rownum--;
}
}

}

public void body(TableModel model, Column column) ...{

if (column.isFirstColumn()) ...{
rownum++;
cellnum = 0;
}


try ...{

String value = ExportViewUtils.parseXLS(column.getCellDisplay());


if (column.isEscapeAutoFormat()) ...{

writeToCellAsText(value, null);


} else ...{
writeToCellFormatted(value, null);
}
cellnum++;


} catch (RowsExceededException e) ...{
// TODO Auto-generated catch block
LogHandler.errorLog(logger, e);

} catch (WriteException e) ...{
// TODO Auto-generated catch block
LogHandler.errorLog(logger, e);
}
}


public Object afterBody(TableModel model) ...{

if (model.getLimit().getTotalRows() != 0) ...{

try ...{
totals(model);

} catch (RowsExceededException e) ...{
// TODO Auto-generated catch block
LogHandler.errorLog(logger, e);

} catch (WriteException e) ...{
// TODO Auto-generated catch block
LogHandler.errorLog(logger, e);
}
}

try ...{
// int totalCol=model.getColumnHandler().getColumns().size();
rownum++;
String extendRowAfter=(String)(model.getTable().getAttribute("ExtendRowAfter"));
rownum+=createRow(sheet, getRows(extendRowAfter,encoding),(CellFormat)WritableWorkbook.NORMAL_STYLE, rownum,0);
wb.write();
wb.close();
out.flush();
out.close();

} catch (WriteException e) ...{
LogHandler.warnLog(logger, e);

} catch (IOException e) ...{
LogHandler.warnLog(logger, e);

} catch (Exception e) ...{
LogHandler.warnLog(logger, e);
}
return outputStreamOut;
}




private void writeToCellAsText( String value, WritableCellFormat styleModifier) throws RowsExceededException, WriteException ...{
// format text

if (value.trim().equals(NBSP)) ...{
value = "";
}
Label label=new Label(cellnum,rownum,value);

if (styleModifier!=null)...{
label.setCellFormat(styleModifier);
}
sheet.addCell(label);

}


private void writeToCellFormatted( String value, WritableCellFormat styleModifier) throws RowsExceededException, WriteException ...{
double numeric = NON_NUMERIC;


try ...{
numeric = Double.parseDouble(value);

} catch (Exception e) ...{
numeric = NON_NUMERIC;
}


if (value.startsWith("$") || value.endsWith("%") || value.startsWith("($")) ...{
boolean moneyFlag = (value.startsWith("$") || value.startsWith("($"));
boolean percentFlag = value.endsWith("%");

value = StringUtils.replace(value, "$", "");
value = StringUtils.replace(value, "%", "");
value = StringUtils.replace(value, ",", "");
value = StringUtils.replace(value, "(", "-");
value = StringUtils.replace(value, ")", "");


try ...{
numeric = Double.parseDouble(value);

} catch (Exception e) ...{
numeric = NON_NUMERIC;
}


if (moneyFlag) ...{
// format money
NumberFormat fivedps = new NumberFormat(moneyFormat);
WritableCellFormat fivedpsFormat = new WritableCellFormat(fivedps);
Number number = new Number(cellnum, rownum, numeric, fivedpsFormat);

if (styleModifier!=null)...{
number.setCellFormat(styleModifier);
}
sheet.addCell(number);

} else if (percentFlag) ...{
// format percent
numeric = numeric / 100;
NumberFormat fivedps = new NumberFormat(percentFormat);
WritableCellFormat fivedpsFormat = new WritableCellFormat(fivedps);
Number number = new Number(cellnum, rownum, numeric, fivedpsFormat);

if (styleModifier!=null)...{
number.setCellFormat(styleModifier);
}
sheet.addCell(number);
}

} else if (Math.abs(numeric - NON_NUMERIC) >= .0000001) ...{
// numeric != NON_NUMERIC
// format numeric
Number number = new Number(cellnum, rownum, numeric);

if (styleModifier!=null)...{
number.setCellFormat(styleModifier);
}
sheet.addCell(number);

} else ...{
// format text

if (value.trim().equals(NBSP)) ...{
value = "";
}
Label label=new Label(cellnum,rownum,value);

if (styleModifier!=null)...{
label.setCellFormat(styleModifier);
}
sheet.addCell(label);
}

}




// Add to export totals

public void totals(TableModel model) throws RowsExceededException, WriteException ...{
Column firstCalcColumn = model.getColumnHandler().getFirstCalcColumn();
WritableCellFormat cellFormatTotals=new WritableCellFormat();
cellFormatTotals.setBackground(Colour.GRAY_25);
cellFormatTotals.setBorder(Border.ALL, BorderLineStyle.THIN,Colour.GRAY_50);

if (firstCalcColumn != null) ...{
int rows = firstCalcColumn.getCalc().length;

for (int i = 0; i < rows; i++) ...{
rownum++;
cellnum = 0;

for (Iterator iter = model.getColumnHandler().getColumns().iterator(); iter.hasNext();) ...{
Column column = (Column) iter.next();

if (column.isFirstColumn()) ...{
String calcTitle = CalcUtils.getFirstCalcColumnTitleByPosition(model, i);

if (column.isEscapeAutoFormat()) ...{

writeToCellAsText(calcTitle, cellFormatTotals);


} else ...{
writeToCellFormatted(calcTitle, cellFormatTotals);
}
cellnum++;
continue;
}


if (column.isCalculated()) ...{

CalcResult calcResult = CalcUtils.getCalcResultsByPosition(model, column, i);
java.lang.Number value = calcResult.getValue();


if (value != null)...{
//if (column.isEscapeAutoFormat()) {
// writeToCellAsText( value.toString(), cellFormatTotals);
//} else {
// writeToCellFormatted( ExtremeUtils.formatNumber(column.getFormat(), value, model.getLocale()), cellFormatTotals);
// }

if (StringUtils.isNotBlank(column.getFormat()))...{
writeToCellFormatted( ExtremeUtils.formatNumber(column.getFormat(), value, model.getLocale()), cellFormatTotals);

}else...{
writeToCellAsText( value.toString(), cellFormatTotals);
}

} else ...{
Label label=new Label(cellnum,rownum,"n/a");
sheet.addCell(label);
}
cellnum++;

} else ...{
writeToCellFormatted( "", cellFormatTotals);
cellnum++;
}
}
}
}

}

}


/**//*
* Copyright 2006-2007 original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ecside.view;

import java.io.ByteArrayOutputStream;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.ecside.core.Preferences;



/** *//**
* @author Wei Zijun
* @editor by pharaohsprince 法老
* http://blog.csdn.net/pharaohsprince
* 2007.09.25 中秋节
*/


public class XlsViewResolver implements ViewResolver ...{

public void resolveView(ServletRequest request, ServletResponse response, Preferences preferences, Object viewData) throws Exception ...{

if (viewData!=null)...{
ByteArrayOutputStream out = (ByteArrayOutputStream)viewData;
byte[] contents = out.toByteArray();
response.setContentLength(contents.length);
response.getOutputStream().write(contents);
}
}
}


/**//*
* Copyright 2004 original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ecside.view;

import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.ecside.core.TableModel;
import org.ecside.core.bean.Column;
import org.ecside.core.bean.Export;
import org.ecside.table.calc.CalcResult;
import org.ecside.table.calc.CalcUtils;
import org.ecside.util.ExportViewUtils;
import org.ecside.util.ExtremeUtils;


/** *//**
* For producing a delimited datafile view of the table. Default delimiter is
* comma.
*
* @author Wei Zijun
* @editor by pharaohsprince 法老
* http://blog.csdn.net/pharaohsprince
* 2007.09.25 中秋节
*/

public class CsvView implements View ...{
public final static String DELIMITER = "delimiter";
final static String DEFAULT_DELIMITER = ",";
// private StringBuffer plainData = new StringBuffer();
private ByteArrayOutputStream outputStream ;
private ByteArrayOutputStream outputStreamOut;
private StringBuffer rowBuffer =null;
private PrintWriter out =null;
private String delimiter;


public void beforeBody(TableModel model) ...{
outputStream=new ByteArrayOutputStream();
outputStreamOut=outputStream;

/**//*
outputStream=ContextUtils.getResponseOutputStream(model.getContext());
outputStreamOut=null;
if (outputStream==null){
outputStream=new ByteArrayOutputStream();
outputStreamOut=outputStream;
}*/
out=new PrintWriter(outputStream);
Export export = model.getExportHandler().getCurrentExport();
delimiter = export.getAttributeAsString(DELIMITER);
List columns = model.getColumnHandler().getHeaderColumns();

if (StringUtils.isBlank(delimiter)) ...{
delimiter = DEFAULT_DELIMITER;
}
boolean isFirstColumn=true;
rowBuffer = new StringBuffer();

for (Iterator iter = columns.iterator(); iter.hasNext();) ...{
Column column = (Column) iter.next();
String value = ExportViewUtils.parseCSV(column.getCellDisplay());

if (!isFirstColumn)...{
rowBuffer.append(delimiter);
}
rowBuffer.append(value);
isFirstColumn=false;
}

if (columns.size()>0)...{
rowBuffer.append(ExportViewUtils.BR);
writeToOutputStream(rowBuffer.toString());
}

}


public void body(TableModel model, Column column) ...{
String value = ExportViewUtils.parseCSV(column.getCellDisplay());
rowBuffer.append(value);

if (column.isLastColumn()) ...{
rowBuffer.append(ExportViewUtils.BR);
writeToOutputStream(rowBuffer.toString());

}else...{
rowBuffer.append(delimiter);
}
}


public Object afterBody(TableModel model) ...{
totals(model);
out.flush();
out.close();
return outputStreamOut;
}

public void totals(TableModel model) ...{
rowBuffer = new StringBuffer();
Column firstCalcColumn = model.getColumnHandler().getFirstCalcColumn();


if (firstCalcColumn != null) ...{
int rows = firstCalcColumn.getCalc().length;

for (int i = 0; i < rows; i++) ...{


for (Iterator iter = model.getColumnHandler().getColumns().iterator(); iter.hasNext();) ...{

Column column = (Column) iter.next();

if (column.isFirstColumn()) ...{
String calcTitle = CalcUtils.getFirstCalcColumnTitleByPosition(model, i);
rowBuffer.append(ExportViewUtils.parseCSV(calcTitle) );
continue;
}
rowBuffer.append(delimiter);

if (column.isCalculated()) ...{
CalcResult calcResult = CalcUtils.getCalcResultsByPosition(model, column, i);
java.lang.Number value = calcResult.getValue();

if (value != null)...{

if (StringUtils.isNotBlank(column.getFormat()))...{
rowBuffer.append(ExportViewUtils.parseCSV(ExtremeUtils.formatNumber(column.getFormat(), value, model.getLocale())));

}else...{
rowBuffer.append(ExportViewUtils.parseCSV(value.toString()) );
}

} else ...{
rowBuffer.append(ExportViewUtils.parseCSV(""));
}

} else ...{
rowBuffer.append(ExportViewUtils.parseCSV(""));
}
}
rowBuffer.append(ExportViewUtils.BR);
writeToOutputStream(rowBuffer.toString());
}
}

}



public void writeToOutputStream(String rowContent)...{
out.print(rowContent);
rowBuffer = new StringBuffer();
}

}


/**//*
* Copyright 2004 original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ecside.view;

import java.io.ByteArrayOutputStream;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.ecside.core.Preferences;


/** *//**
* @author Jeff Johnston
*/

/** *//**
* @editor by pharaohsprince 法老
* http://blog.csdn.net/pharaohsprince
* 2007.09.25 中秋节
*/

public class CsvViewResolver implements ViewResolver ...{

public void resolveView(ServletRequest request, ServletResponse response, Preferences preferences, Object viewData) throws Exception ...{

if (viewData!=null)...{
ByteArrayOutputStream out = (ByteArrayOutputStream)viewData;
byte[] contents = out.toByteArray();
response.setContentLength(contents.length);
response.getOutputStream().write(contents);
}
}
}

------------------------------------------------------------------
说明:编译ECSIDE2.0RC1的源代码,把以上文件修改后编译,把新的CLASS复制到JAR文件里覆盖对应文件即可~
打包好的jar文件
参考CsvView,CsvViewResolver对XlsView,XlsViewResolver做了修改
删除了原有的log4j配置文件·
| ecside_2.0_RC1_by_pharaohs.jar |
| 描述: |
【完美解决ecside2.0RC1在weblogic8.1.6环境下导出xls,csv 文件为空的情况】~法老修正完整版之JAR包 |
 下载 |
| 文件名: |
ecside_2.0_RC1_by_pharaohs.jar |
| 文件大小: |
360 KB |
| 下载过的: |
文件被下载或查看 386 次 |
发表于 @ 2007年09月26日 00:15:00|评论(loading...)|收藏