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);
}