package com.vci.client.portal.platformPortal;
|
|
import java.util.List;
|
|
import com.vci.corba.portal.data.PortalVI;
|
|
public class AllExportExcel {
|
List<PortalVI> objList ;
|
|
private int typeFlag ;
|
private int portalViIndex = 0;
|
public AllExportExcel(int typeFlag){
|
this.typeFlag = typeFlag;
|
}
|
|
|
public boolean export(){
|
return true;
|
}
|
// public boolean export(){
|
// JFileChooser jf = new JFileChooser();
|
// jf.setDialogTitle("打开");
|
// jf.removeChoosableFileFilter(jf.getFileFilter());
|
// jf.setFileFilter(new FileFilter() {
|
//
|
// @Override
|
// public String getDescription() {
|
// return "xls";
|
// }
|
//
|
// @Override
|
// public boolean accept(File f) {
|
// if(f.isDirectory()||f.getName().endsWith(".xls")){
|
// return true;
|
// }else{
|
// return false;
|
// }
|
// }
|
// });
|
// int showOpenDialog = jf.showOpenDialog(LogonApplication.frame);
|
// String xfileName = "";
|
// String prmFileName = "";
|
// if (showOpenDialog == JFileChooser.APPROVE_OPTION) {
|
// File file = jf.getSelectedFile();
|
// xfileName = file.getAbsolutePath();
|
// if(!xfileName.endsWith(".xls")){
|
// xfileName = xfileName+".xls";
|
// }
|
// }
|
// HSSFWorkbook workbook = new HSSFWorkbook();
|
// HSSFSheet sheet_btmName = workbook.createSheet();
|
// workbook.setSheetName(0, "btmName");
|
//
|
// HSSFSheet sheet = workbook.createSheet();
|
// workbook.setSheetName(1, "portalvi");
|
//
|
//
|
// HSSFSheet qtdSheet = workbook.createSheet();
|
// workbook.setSheetName(2, "QTD");
|
//
|
// String btmName = "";
|
// if(typeFlag==0){
|
// BtmItem[] allBtItems = BtmProvider.getInstance().getAllBtmItems();
|
// for(int i = 0;i < allBtItems.length;i ++){
|
// btmName = allBtItems[i].name;
|
// HSSFRow row = sheet_btmName.createRow(i);
|
// HSSFCell cell = row.createCell(0);
|
// cell.setCellValue(btmName);
|
// allExport(xfileName, workbook, sheet, btmName, qtdSheet);
|
// }
|
// }else if(typeFlag==1){
|
// LinkType[] linkTypes = LinkTypeProvider.getInstance().getLinkTypes();
|
// for(int i = 0;i < linkTypes.length;i ++){
|
// btmName = linkTypes[i].name;
|
// HSSFRow row = sheet_btmName.createRow(i);
|
// HSSFCell cell = row.createCell(0);
|
// cell.setCellValue(btmName);
|
// allExport(xfileName, workbook, sheet, btmName, qtdSheet);
|
// }
|
// }
|
// return true;
|
// }
|
//
|
// private boolean allExport(String xfileName, HSSFWorkbook workbook,
|
// HSSFSheet sheet, String btmName, HSSFSheet qtdSheet) {
|
// String prmFileName;
|
// PortalVI[] objList = new PortalVI[0];
|
// try {
|
// objList = Tool.getService().getPortalVIArrayByTypeName(btmName);
|
// } catch (VCIError e2) {
|
// e2.printStackTrace();
|
// }
|
// for(int i=0;i<objList.length;i++){
|
// HSSFRow row = sheet.createRow(i+portalViIndex);
|
// PortalVI portalVI = objList[i];
|
//// HSSFCell cell = row.createCell(0);
|
//// cell.setCellValue(portalVI.id);
|
// HSSFCell cell = row.createCell(0);
|
// cell.setCellValue(portalVI.typeName);
|
// cell = row.createCell(1);
|
// cell.setCellValue(portalVI.viName);
|
// cell = row.createCell(2);
|
// cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
|
// cell.setCellValue(portalVI.viType);
|
// cell = row.createCell(3);
|
// cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
|
// cell.setCellValue(portalVI.typeFlag);
|
// cell = row.createCell(4);
|
// String prmStr = portalVI.prm;
|
// String qtName = "";
|
// if(portalVI.viType ==0){
|
// PRM prmObj = Tool.getPRM(prmStr);
|
// List<PRMItem> prmItemList = prmObj.getPrmItemList();
|
// for(int j=0;j<prmItemList.size();j++){
|
// PRMItem pit = prmItemList.get(j);
|
// qtName = pit.getItemQtName();
|
// PortalVI[] portalViInfos = new PortalVI[0];
|
// try {
|
// portalViInfos = Tool.getService().getPortalVIArrayByTypeName(portalVI.typeName);
|
// for(PortalVI pv : portalViInfos){
|
// if(pit.getItemInObj().equals(pv.id)){
|
// pit.setItemInObj(portalVI.typeName+":"+pv.viName);
|
// }
|
// }
|
// } catch (VCIError e) {
|
// e.printStackTrace();
|
// }
|
// }
|
// try {
|
// prmStr = Tool.getPRMText(prmObj);
|
// } catch (Throwable e1) {
|
// e1.printStackTrace();
|
// }
|
// }
|
// prmFileName = System.currentTimeMillis() + ".txt";
|
// String prmFileAllName = xfileName + "." + prmFileName;
|
//// FileOutputStream fop = null;
|
// BufferedWriter fbw = null;
|
// try {
|
// File prmFile = new File(prmFileAllName);
|
// fbw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(prmFile), "utf-8"));
|
// if(!prmFile.exists()){
|
// prmFile.createNewFile();
|
// }
|
//// byte[] connentBytes = prmStr.getBytes();
|
// fbw.write(prmStr);
|
// fbw.flush();
|
// cell.setCellValue(prmFileName);
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// return false;
|
// }finally{
|
// if(fbw!=null){
|
// try {
|
// fbw.close();
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// }
|
// }
|
//// cell.setCellValue(prmStr);
|
// String btmname = "";
|
// String linkname = "";
|
// AttribItem[] btAbItems=null;
|
// if(portalVI.typeFlag==0){
|
// btmname = portalVI.typeName;
|
// btAbItems = BtmProvider.getInstance().getBtAbItems(btmname);
|
// }else if(portalVI.typeFlag==1){
|
// try {
|
// LinkType linkType = LinkTypeProvider.getInstance().getLinkTypeByName(portalVI.typeName);
|
// btmname = linkType.name;
|
// linkname = linkType.name;
|
// btAbItems = ApProvider.getInstance().getAttribItemsByNames(LinkTypeProvider.getInstance().getAbNames(linkType));
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// } catch (Throwable e) {
|
// e.printStackTrace();
|
// }
|
// }
|
//
|
// String attr = "";
|
// for(AttribItem ait : btAbItems){
|
// attr += ait.name +",";
|
// }
|
// //类型属性:以字符串形式存在
|
// cell = row.createCell(5);
|
// if(attr==null||"".equals(attr)){
|
// cell.setCellValue("");
|
// }else{
|
// cell.setCellValue(attr.substring(0,attr.length()-1));
|
// }
|
// //查询模板名称
|
// cell = row.createCell(6);
|
// cell.setCellValue(qtName);
|
// BufferedWriter qtbw = null;
|
// try {
|
// QTInfo qt = QTClient.getService().getQT(qtName);
|
// if(qt!=null){
|
// //查询模板名称
|
// cell = row.createCell(7);
|
// String qtFileName = "a" + System.currentTimeMillis() + ".txt";
|
// String qtFileNameAllName = xfileName + "." + qtFileName;
|
//// FileOutputStream qtfop = null;
|
// File prmFile = new File(qtFileNameAllName);
|
// qtbw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(prmFile), "utf-8"));
|
// if(!prmFile.exists()){
|
// prmFile.createNewFile();
|
// }
|
//// byte[] connentBytes = qt.qtText.getBytes();
|
// qtbw.write(qt.qtText);
|
// qtbw.flush();
|
// qtbw.close();
|
// cell.setCellValue(qtFileName);
|
// //查询模板的业务对象名称
|
// cell = row.createCell(8);
|
// cell.setCellValue(qt.btmName);
|
//
|
// //导出查询模板定义
|
// QTD[] qtdsByBtmName = QTDClient.getService().getQTDSByBtmName(btmname);
|
// for(int qtdIndex =0;qtdIndex<qtdsByBtmName.length;qtdIndex++){
|
// HSSFRow qtdRow = qtdSheet.createRow(qtdIndex);
|
// QTD qtd = qtdsByBtmName[qtdIndex];
|
// HSSFCell qtdCell = qtdRow.createCell(0);
|
// qtdCell.setCellValue(qtd.btmName);
|
// qtdCell = qtdRow.createCell(1);
|
// qtdCell.setCellValue(qtd.linkTypeName);
|
// qtdCell = qtdRow.createCell(2);
|
// qtdCell.setCellValue(qtd.name);
|
// qtdCell = qtdRow.createCell(3);
|
// String qtdattr = "";
|
// for(String str : qtd.abNames){
|
// qtdattr += str+",";
|
// }
|
// if(qtdattr==null||"".equals(qtdattr)){
|
// qtdCell.setCellValue("");
|
// }else{
|
// qtdCell.setCellValue(qtdattr.substring(0,qtdattr.length()-1));
|
// }
|
// }
|
// QTD[] qtdsByLinkTypeName = QTDClient.getService().getQTDSByLinkTypeName(linkname);
|
// for(int qtdLinkIndex =0;qtdLinkIndex<qtdsByLinkTypeName.length;qtdLinkIndex++){
|
// HSSFRow qtdRow = qtdSheet.createRow(qtdLinkIndex);
|
// QTD qtd = qtdsByLinkTypeName[qtdLinkIndex];
|
// HSSFCell qtdCell = qtdRow.createCell(0);
|
// qtdCell.setCellValue(qtd.btmName);
|
// qtdCell = qtdRow.createCell(1);
|
// qtdCell.setCellValue(qtd.linkTypeName);
|
// qtdCell = qtdRow.createCell(2);
|
// qtdCell.setCellValue(qtd.name);
|
// qtdCell = qtdRow.createCell(3);
|
// String qtdattr = "";
|
// for(String str : qtd.abNames){
|
// qtdattr += str+",";
|
// }
|
// if(qtdattr==null||"".equals(qtdattr)){
|
// qtdCell.setCellValue("");
|
// }else{
|
// qtdCell.setCellValue(qtdattr.substring(0,qtdattr.length()-1));
|
// }
|
// }
|
// }
|
// } catch (VCIError e) {
|
// e.printStackTrace();
|
// } catch (FileNotFoundException e) {
|
// e.printStackTrace();
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// }
|
// }
|
//
|
// if(objList.length>0){
|
// portalViIndex+=objList.length;
|
// }
|
// try {
|
// FileOutputStream fout = new FileOutputStream(xfileName);
|
// workbook.write(fout);
|
// fout.flush();
|
// fout.close();
|
// System.out.println("文件生成.....");
|
// return true;
|
// } catch (FileNotFoundException e) {
|
// e.printStackTrace();
|
// return false;
|
// } catch (IOException e) {
|
// e.printStackTrace();
|
// return false;
|
// }
|
// }
|
}
|