Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )

Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )

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();
   } 
   }
View Answers

Ads









Related Tutorials/Questions & Answers:
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )   I need to create a folder structure... on Java sdk of business objecsts . i need some help in getting folder structure using
create folders and sub folders based on excel data
by line and based on that how can i create folder structure same as the excel...create folders and sub folders based on excel data  Hi, i have... to create folders and subfolders. here the excel sheet looks like
Advertisements
linux tar folder and subfolders
linux tar folder and subfolders  Hi, I am new to Linux operating..., I want a simple way to compress these files preserving the directory structure so that when it is extracted I get the same structure. What are the options
how to count no.of sheets in excel through POI jar as well as through Java?
how to count no.of sheets in excel through POI jar as well as through Java... will be dynamic ) .I want to read all sheets one by one in java by using POI jar. I... know the method to count the no.of sheets in excel through POI jar or else java
Error in reading Excel data using jsp even having .xls and POI Library in respective folders
Error in reading Excel data using jsp even having .xls and POI Library in respective folders  Hi, hello.xls and POI library files are there in respective folders. the printStackTrce() method shows the following Error message
Video Tutorial: How to check if a folder exists in Java through a source code
How to check if a folder exists in Java through a source code Java is an all... if our folder exists in Java by the help of source code in a few simple steps... to byte code that helps to run any Java virtual machine. Java is one of the most
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code   //here my file...); } } } sir, the above code is my sample code for reading excel file
Creat a folder, inside it upload and download files in jsp and mysql
Creat a folder, inside it upload and download files in jsp and mysql  Create one or more folder .inside it we can upload and download multiple files... to download any file. 1)page.jsp: <%@ page language="java" %> <
JAVA EXCEL
JAVA EXCEL  How to read the contents of an excel, perform some calculation and wrote the calculated values to another excel using poi
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
how to creat ftp server on java
how to creat ftp server on java  ftp server investigation requirment ER diagram flow chart source code
Java Util Zip. Zip files/folders inside a folder, without zipping the original source folder.
Java Util Zip. Zip files/folders inside a folder, without zipping the original...); } } } } This is my Zipping code and i'll tell you i am having such a time, i give the method a very static scenario. I want to take the files inside the folder
Folder in Java.
Folder in Java.  I have any problem how to make Folder in java program? Can Anybody help me in this part
Need to remove duplicate rows from the Excel Sheet using the Apache POI API
Need to remove duplicate rows from the Excel Sheet using the Apache POI API   Hi There, Is any one aware of java code on how to find the duplicate rows in excel.I am using the Apache POI API to achieve the same have googled
Set Data Format in Excel Using POI 3.0
Set Data Format in Excel Using POI 3.0   ... file using JavaPOI version 3.0 provides a new feature for manipulating... Java. POI version 3.0 APIs provides user defined formatting facility and also
Need to remove duplicated rows from excel using apache POI API
Need to remove duplicated rows from excel using apache POI API  Hi, Need help from you. I am able to generate excel sheet with data also... to remove duplicated rows from excel sheet by using apache poi api oe jxl api
java program to take the backup of folders and copy the folder in different location without deleting the existing one
java program to take the backup of folders and copy the folder in different... the backup of folders and copy the folder in different location without deleting the existing one   Have a look at the following link: Java Copy one folder
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?   i have an excel sheet, whose data in each cell has... the rows of an excel sheet. Need the source code
Java lock file or folder.
Java lock file or folder.  Is it possible to create a desktop application to lock or encrypt file or folder in windows by using java code?? if possible can provide some reference?? because i can't find it... thanks
Create Excel(.xlsx) document using Apache POI
Create Excel(.xlsx) document using Apache POI In this section, you will learn how to create a Excel sheet having .xlsx extension using Apache POI library..., i have used Apache POI version 3.7. For downloading the above library
sir, how to convert excel file to csv file using java? please send me sample code.
sir, how to convert excel file to csv file using java? please send me sample code.  please send me sample code for converting excel file into csv file uisng java
Read Excel(.xlsx) document using Apache POI
Read Excel(.xlsx) document using Apache POI In this section, you will learn how to read Excel file having .xlsx extension using Apache POI library..., boolean  as well as text cells. In the below example, i have used Apache POI
insert checkbox in cell using POI api in java
insert checkbox in cell using POI api in java  I need to insert checkbox in excel cell using POI and java. Any one help me on this. Ashok S
Create Simple Excel(.xls) document using Apache POI
Create Simple Excel(.xls) document using Apache POI In this section, you... POI library. In the given below example, we will going to create a simple excel...;. In the below example, i have used Apache POI version 3.7. For downloading
POI Tutorial
POI Tutorial  Hi, How to access the Excel file in Java? I have heard about POI in Java. Can anyone share me the url of the tutorial? Thanks   Hi, Yes you can use the POI api for reading and writing Excel file. Check

Ads