NC 前后台文件传输

NC 后台获取登录用户

String userName= InvocationInfoProxy.getInstance().getUserId();

提示前台异常

throw new BusinessException(“异常内容”);

前后台传输文件流byte[] excel样例

	//后台
	File file=new File(basePath+"/resources/excel/data.xlsx");
	String path = file.getPath().toLowerCase();
	// 通过输入流读取文件中的内容并且解析
	FileInputStream fis = new FileInputStream(path3);
	//压缩文件
	byte[] zipByte = ZipTools.zipFileData(fis);



	
			
//前台
byte[] zipByte  =  service.ExcelTODataSer(serverUrl, file2.getName(), zipByte2);			
if(zipByte!=null){
				MessageDialog.showHintDlg(tp, "警告", "导入信息存在错误,请保存文件后在文件最后一列查看错误信息!");
				String filePath = null;
				if(zipByte!=null){
					getChooser().setSelectedFile(new File("错误信息"));
					/*getChooser().setSelectedFile(new File("导入模板"));
					IHiofferMaintain service = NCLocator.getInstance().lookup(IHiofferMaintain.class);
					byte[] byteData = service.getfile();*/
					// 打开保存模态框
					if (getChooser().showSaveDialog(tp) == JFileChooser.CANCEL_OPTION) {
						return;
					}
					// 获的输入框内的文件名及路径
					filePath = getChooser().getSelectedFile().toString();
					if (filePath == null) {
						MessageDialog.showHintDlg(tp, "警告", "请输入文件名保存!");
						return;
					}
					FileOutputStream fos = null;
					
					fos = new FileOutputStream(filePath+".xlsx");

					String path = fos.toString();
					//File targetFile = new File(path);
					//FileOutputStream fos2 = new FileOutputStream(targetFile);
					ZipTools.unZipFileData(zipByte, fos);
					FileInputStream in = new FileInputStream(path);
					XSSFWorkbook excelWorkbook = new XSSFWorkbook(in);
					//excelWorkbook.write(fos2);
					excelWorkbook.write(fos);
				}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值