[ECSide] ecside 下载 cvs 报表 格式出错

foreverpassion 2014-09-24
各位好:
现有一个问题 ecside  下载 报表 格式出错
问题:现在我们下载 cvs 文件,我们需要的格式为数字,现在文件里面的格式为:/t数字,所以用excell 打开cvs的时候,此列不能统计

我们配置为:
1:jsp界面
<ec:column width="20%" property="primary.lowPrice[=][double]" title="低价" style="text-align:right;padding-right:5px">									<fmt:formatNumber value="${quotation.applyUnit}" pattern="#,##0" />												</ec:column>


2:CsvView.java  代码为:
public class CsvView implements View {
 public void beforeBody(TableModel model) {
		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();
    	ThreadStore.put("ecsideColumns", columns);
        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());
        }
        ThreadStore.put("beforeBody_out", out);
             
    }


ThreadStore.java

package gnnt.MEBS.base.util;

import java.util.HashMap;
import java.util.Map;

public class ThreadStore {
	private static ThreadLocal<Map<String, Object>> tl = new ThreadLocal<Map<String, Object>>();// 私有静态变量

	public static Map get() {
		return tl.get();
	}

	public static void set(Map map) {
		tl.set(map);
	}

	public static void put(String key, Object value) {
		Map map = get();
		if (map == null) {
			map = new HashMap<String, Object>();
		}

		map.put(key, value);
		set(map);
	}

	public static Object get(String key) {
		Object o = null;
		Map map = get();
		if (map != null) {
			o = map.get(key);
		}
		return o;

	}

	public static void clear() {
		set(null);
	}
}


我们配置了一个拦截器:
<action name="list" class="inventoryAction" method="list">
				<interceptor-ref name="defaultStack" />
				<interceptor-ref name="typeExportInterceptor" />
				<result >/exchange/inventory/inventoryList.jsp</result>
		</action>


拦截器的代码为:
public String intercept(ActionInvocation invocation) throws Exception {
String result = invocation.invoke();
[b]PrintWriter out = (PrintWriter)ThreadExchange.get("beforeBody_out");[/b]

out.print(a.substring(0, a.length()-1)+"\r\n");//重写cvs
}finally{
				out.flush();
				out.close();
			}


现在的问题是:out 写的内容和界面上显示的内容不是一个格式

分析原因:out 放入ThreadStore ,和在拦截器里面取出的,不是一个值;其中out里面的某个属性是空,所以 导致显示的值 是另一个,请教各位 解决办法

Global site tag (gtag.js) - Google Analytics