分类: Java
2009-12-01 17:44:31
1. 新建文件:打开一个空白页面,URL跳转到
2. 开启文件:打开指定路径上本地excel文件,将相关参数存储在内存中
3. 存档关闭:存储当前文件,并跳转到一个空白页面
1. 新建文件
2. 开启文件
3. 存档关闭
1. 新建文件
| ?/** |
| ? * 函数说明:新增空白页 |
| ? * @param event |
| ? * @return |
| ? * |
| ? * @author? fisher |
| ? */ |
| ?public void onBwFileNew() { |
| ??bwSendRedirect("index.zul"); |
| ?} |
2. 开启文件
| ?/** |
| ? * 函数说明:打开xls文件 |
| ? * |
| ? * @param event |
| ? * @return |
| ? * |
| ? * @author? fisher |
| ? */ |
| ?public void onBwOpenFile() { |
| ??/* |
| ?? * 打开文件 |
| ?? */ |
| ??try { |
| ???// 弹出ZSS文件浏览框 |
| ???Object ss = Fileupload.get(); |
| ???// 浏览选择文件点击上传后,跳到下一步处理 |
| ???if (ss == null) |
| ????return; |
| ???// 导入的文件的名称 |
| ???String filename = ((Media) ss).getName(); |
| ???if (filename == null) { |
| ????System.out.println("cannot found file: " + filename); |
| ????return; |
| ???} |
| ???// 获取导入文件流 |
| ???InputStream iStream = ((Media) ss).getStreamData(); |
| ???if (iStream == null) { |
| ????System.out.println("cannot import to iStream: " + filename); |
| ????return; |
| ???} |
| ???// 打开文件,存储相关数据到内存(后期考虑换其他存储模式) |
| ???openSpreadsheetFromStream(iStream, filename); |
| ??} catch (Exception e) { |
| ???e.printStackTrace(); |
| ??} |
| ?} |
3. 存档关闭
| ??public void onBwFileSaveClose(ForwardEvent event) { |
| ??try { |
| ???onBwSaveBook(); |
| ??} catch (InterruptedException e) { |
| ???e.printStackTrace(); |
| ??} |
| ??onBwFileNew(); |
| ?} |
其他相关
| ?public void bwSendRedirect(String url) { |
| ??// 页面跳转 |
| ??//TODO: 这里跳转之后,会再访问多一次数据库获取数据,多余,后期完善 |
| ??Executions.getCurrent().sendRedirect(url); |
| ?} |