I need to create a folder structure in the excel file .
To be precise, am working on Java sdk of business objecsts . i need some help in getting folder structure using this java .
Folder strcuture should look like following way in excel .
A(parent ) | | |_topfolder1__ | |__subfolder1__ | |__childrens |_topfolder2__ |__subfolder2__ |__sufolder2a__ |__childrens
And right now i have the following code, where am getting output in RAD console, but i need to display in excel such a way of folder hierarchy
Note : here all HSSF lines are half done, pls bear with that !!
if(topFolders.size() < 1)</br> { System.out.println("no top level folders"); } else { HSSFFont font = wb.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setFont(font); HSSFCell cell; HSSFRow row1 = sheet.createRow(1); sheet.createFreezePane(1,1,1,1); for( i=0; i<topFolders.size(); i++) { IInfoObject topFolder = (IInfoObject) topFolders.get(i); System.out.println("Top level folders"+topFolder.getTitle()); row3=sheet.createRow(i); row3.createCell(0).setCellValue(topFolder.getTitle()); if(topFolder.getKind()!="FOLDER") { childcount=getchilds(boInfoStore,topFolder.getID() ); System.out.println("no.of childs"+childcount); } count++; int subfoldercount=GetSubFolders(boInfoStore, topFolder.getID()); System.out.println("no.of.subfolders"+subfoldercount); } System.out.println("total no .of topfolder"+count); } FileOutputStream fileOut = new FileOutputStream("c://"); wb.write(fileOut); fileOut.close(); } catch(Exception e) { System.out.println("--------------"+e.getMessage()); } } static int GetSubFolders(IInfoStore oInfoStore, int folderID) { String query = "select * from ci_infoobjects where si_kind='folder' and +folderid IInfoObjects folders = oInfoStore.query(query); if(folders.size() < 1) return 0; else { for(int i=0; i<folders.size(); i++) { IInfoObject SubFolder = (IInfoObject)folders.get(i); System.out.println("_subfolders"+SubFolder.getTitle()); //HSSFRow row4=sheet.createRow(i+1); //row4.createCell(1).setCellValue(SubFolder.getTitle()); if(SubFolder.getKind()!="Folder") { int num=getchilds(oInfoStore,SubFolder.getID() ); System.out.println("childrens"+num); } int subfolder2=GetSubFolders(oInfoStore,((IInfoObject)folders.get(i)).getID()); System.out.println("Number of SUBFOLDERS"+subfolder2); } return folders.size(); } } static int getchilds(IInfoStore ooInfoStore,int childid ) { String query3="select * from ci_infoobjects where si_parentid="+ childid; IInfoObjects childrens = ooInfoStore.query(query3); if(childrens.size() < 1) { return 0; } else { //int m=1; for(int l=0; l<childrens.size(); l++) { IInfoObject childs = (IInfoObject)childrens.get(l); System.out.println("childreports"+childs.getTitle()); HSSFRow rowchild=sheet.createRow(l+1); rowchild.createCell(1).setCellValue(childs.getTitle()); } } return childrens.size(); } }
I need to create a folder structure in the excel file .
To be precise, am working on Java sdk of business objecsts . i need some help in getting folder structure using this java .
Folder strcuture should look like following way in excel .
A(parent ) | | |_topfolder1__ | |__subfolder1__ | |__childrens |_topfolder2__ |__subfolder2__ |__sufolder2a__ |__childrens
And right now i have the following code, where am getting output in RAD console, but i need to display in excel such a way of folder hierarchy
Note : here all HSSF lines are half done, pls bear with that !!
if(topFolders.size() < 1)</br> { System.out.println("no top level folders"); } else { HSSFFont font = wb.createFont(); font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD); HSSFCellStyle style = wb.createCellStyle(); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); style.setFont(font); HSSFCell cell; HSSFRow row1 = sheet.createRow(1); sheet.createFreezePane(1,1,1,1); for( i=0; i<topFolders.size(); i++) { IInfoObject topFolder = (IInfoObject) topFolders.get(i); System.out.println("Top level folders"+topFolder.getTitle()); row3=sheet.createRow(i); row3.createCell(0).setCellValue(topFolder.getTitle()); if(topFolder.getKind()!="FOLDER") { childcount=getchilds(boInfoStore,topFolder.getID() ); System.out.println("no.of childs"+childcount); } count++; int subfoldercount=GetSubFolders(boInfoStore, topFolder.getID()); System.out.println("no.of.subfolders"+subfoldercount); } System.out.println("total no .of topfolder"+count); } FileOutputStream fileOut = new FileOutputStream("c://"); wb.write(fileOut); fileOut.close(); } catch(Exception e) { System.out.println("--------------"+e.getMessage()); } } static int GetSubFolders(IInfoStore oInfoStore, int folderID) { String query = "select * from ci_infoobjects where si_kind='folder' and +folderid IInfoObjects folders = oInfoStore.query(query); if(folders.size() < 1) return 0; else { for(int i=0; i<folders.size(); i++) { IInfoObject SubFolder = (IInfoObject)folders.get(i); System.out.println("_subfolders"+SubFolder.getTitle()); //HSSFRow row4=sheet.createRow(i+1); //row4.createCell(1).setCellValue(SubFolder.getTitle()); if(SubFolder.getKind()!="Folder") { int num=getchilds(oInfoStore,SubFolder.getID() ); System.out.println("childrens"+num); } int subfolder2=GetSubFolders(oInfoStore,((IInfoObject)folders.get(i)).getID()); System.out.println("Number of SUBFOLDERS"+subfolder2); } return folders.size(); } } static int getchilds(IInfoStore ooInfoStore,int childid ) { String query3="select * from ci_infoobjects where si_parentid="+ childid; IInfoObjects childrens = ooInfoStore.query(query3); if(childrens.size() < 1) { return 0; } else { //int m=1; for(int l=0; l<childrens.size(); l++) { IInfoObject childs = (IInfoObject)childrens.get(l); System.out.println("childreports"+childs.getTitle()); HSSFRow rowchild=sheet.createRow(l+1); rowchild.createCell(1).setCellValue(childs.getTitle()); } } return childrens.size(); } }