public" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>jxl</em>可以导出2007的excel吗?如果我要导出2007的...-jxl e

<em>jxl</em>可以导出2007的excel吗?如果我要导出2007的...-jxl e

作者:乔山办公网日期:

返回目录:excel表格制作


我不知道,jxl支持不支持!

你可以试一下 poi 3.6以上的版本!

用里面的 xssf!

public String exportxm() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
// String wid=request.getParameter("wid");
String[] headers = { "项目名称", "填报人", "填报时间", "合同额", "预计毛利", "项目计划完成时间", "所属部门"};
String[] columns = { "sernum", "personer.name", "times","xsjobes", "xsb", "plannedate", "subdept.name"};
Map<String, Object> values = new HashMap<String, Object>();
//Page<Worktype> page1 = new Page<Worktype>(40);
// 设置默认排序方式
if (!page.isOrderBySetted()) {
page.setOrderBy("id");
page.setOrder(Page.DESC);
}
page.setPageSize(9999);
page = manager.searchWork(page, values);
String title="项目管理表";
// 生成Excel文件.
Workbook wb = new ExcelExport(title, headers,columns, page)
.exportExcelWorkbook();
// 输出Excel文件.
HttpServletResponse response = Struts2Utils.getResponse();
response.setContentType(ServletUtils.EXCEL_TYPE);
ServletUtils.setFileDownloadHeader(response, "项目管理-"+accountManager.getcurrentUser().getName()+".xls");
wb.write(response.getOutputStream());
response.getOutputStream().flush();
return null;
}

、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
/**
* 设置让浏览器弹出下载对话框的Header.
*
* @param fileName 下载后的文件名.
*/
public static void setFileDownloadHeader(HttpServletResponse response, String fileName) {
try {
//中文文件名支持
String encodedfileName = new String(fileName.getBytes(), "ISO8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedfileName + "\"");
} catch (UnsupportedEncodingException e) {
}
}
public static final String EXCEL_TYPE = "application/vnd.ms-excel";
、、、、、、、、、、、、、、、
/**
* 导出e799bee5baa6e78988e69d83336到excel
* @param title 标题
* @param headers 表格头
* @param result 数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public ExcelExport(String title,String[] headers,String[]columns, Page page){
this.title=title;
this.headers=headers;
this.result=transhashmap(columns, page.getResult());
}
/**
* 将listObject 转换为List<HashMap<Integer, Object>>
* @param columns
* @param olist
* @return
*/
private List<HashMap<Integer, Object>> transhashmap(String[] columns,List<Object> olist){
List<HashMap<Integer, Object>> result=Lists.newArrayList();
for(Object o:olist){
HashMap<Integer, Object> ht=this.transhashmap(columns, o);
result.add(ht);
}

return result;
}
/**
* 将object 转换为hashmap
* @param columns
* @param olist
* @return
*/
private HashMap<Integer, Object> transhashmap(String[] columns,Object o){
int col=0;
HashMap<Integer, Object> ht=new HashMap<Integer, Object>();
for(String column:columns){
//根据属性名称直接获取值
Object value=this.invokeGetterMethod(o, column);

ht.put(col,value);
col=col+1;
}
return ht;
}


public String exportxm() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
// String wid=request.getParameter("wid");
String[] headers = { "项目名称", "填报人", "填报时间", "合同额", "预计毛利", "项目计划完成时间", "所属部门"};
String[] columns = { "sernum", "personer.name", "times","xsjobes", "xsb", "plannedate", "subdept.name"};
Map<String, Object> values = new HashMap<String, Object>();
//Page<Worktype> page1 = new Page<Worktype>(40);
// 设置默认排序方式
if (!page.isOrderBySetted()) {
page.setOrderBy("id");
page.setOrder(Page.DESC);
}
page.setPageSize(9999);
page = manager.searchWork(page, values);
String title="项目管理表";
// 生成Excel文件.
Workbook wb = new ExcelExport(title, headers,columns, page)
.exportExcelWorkbook();
// 输出Excel文件.
HttpServletResponse response = Struts2Utils.getResponse();
response.setContentType(ServletUtils.EXCEL_TYPE);
ServletUtils.setFileDownloadHeader(response, "项目管理-"+accountManager.getcurrentUser().getName()+".xls");
wb.write(response.getOutputStream());
response.getOutputStream().flush();
return null;
}

、、e79fa5e98193e4b893e5b19e366、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
/**
* 设置让浏览器弹出下载对话框的Header.
*
* @param fileName 下载后的文件名.
*/
public static void setFileDownloadHeader(HttpServletResponse response, String fileName) {
try {
//中文文件名支持
String encodedfileName = new String(fileName.getBytes(), "ISO8859-1");
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedfileName + "\"");
} catch (UnsupportedEncodingException e) {
}
}
public static final String EXCEL_TYPE = "application/vnd.ms-excel";
、、、、、、、、、、、、、、、
/**
* 导出到excel
* @param title 标题
* @param headers 表格头
* @param result 数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public ExcelExport(String title,String[] headers,String[]columns, Page page){
this.title=title;
this.headers=headers;
this.result=transhashmap(columns, page.getResult());
}
/**
* 将listObject 转换为List<HashMap<Integer, Object>>
* @param columns
* @param olist
* @return
*/
private List<HashMap<Integer, Object>> transhashmap(String[] columns,List<Object> olist){
List<HashMap<Integer, Object>> result=Lists.newArrayList();
for(Object o:olist){
HashMap<Integer, Object> ht=this.transhashmap(columns, o);
result.add(ht);
}

return result;
}
/**
* 将object 转换为hashmap
* @param columns
* @param olist
* @return
*/
private HashMap<Integer, Object> transhashmap(String[] columns,Object o){
int col=0;
HashMap<Integer, Object> ht=new HashMap<Integer, Object>();
for(String column:columns){
//根据属性名称直接获取值
Object value=this.invokeGetterMethod(o, column);

ht.put(col,value);
col=col+1;
}
return ht;
}

相关阅读

  • office <em>2007</em>安装 SP3<em>补丁</em>

  • 乔山办公网excel表格制作
  • 我已经上zd传到附件(百度知道),手机无法查看、下载,请找电脑Microsoft Office 2007企业版官方版包含Word,Excel,Powerpoint,Access、OneNote、Outlook、Publisher、InfoPath、Project、Visio、Groove这所有组
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网