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









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
Excel Created using POI and HSSF - Development process
Excel Created using POI and HSSF  Hi i ceated excel file using jakarta poi library i want to add Percentage formula to cell i am not able to do that can you please suggest me how do i add formula c3.setCellValue("Percentage
Advertisements
POI and HSSF - Development process
POI and HSSF  Hi i ceated excel file using jakarta poi library i want to add Percentage formula to cell i am not able to do that can you please suggest me how do i add formula c3.setCellValue("Percentage"); cell3.setCellType
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
HSSF WORKSHEET FORMATTING - Java Beginners
HSSF WORKSHEET FORMATTING  I am using the following code in my jsp to import thr o/p to excel on the server... the properties of the cols in excel through my code. properties: text should be bold
How to set background of an excel sheet using POI - Java Magazine
How to set background of an excel sheet using POI  Hi, i am trying to format the excel using java. How to set the background color of an excel sheet( complete sheet which includes all cells). i am using poi2.5.1. Thanks
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
Apache POI Excel creation - Development process
Apache POI Excel creation  Hi i am creating Excel sheet using Apache POI. i could able to generate Excel sheet and saving it in mentioned physical...; Hi friend, Code to help creating excel sheet using POI
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
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
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" %> <
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
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... we can check out if our folder exists in Java by the help of source code... to byte code that helps to run any Java virtual machine. Java is one of the most
Apache POI Excel Maximum Row - JSP-Servlet
Apache POI Excel Maximum Row  I am using Apache POI lib for export jsp results to excel file. I am getting error : Row number must be between 0... row value ? and How can I change that ? Thanks in advance Regards
code for recently created file from a folder in java - Java Beginners
code for recently created file from a folder in java  how to get the recently created file from a folder in java?  Hi friend, Code... str[] = file.list(); for( int i = 0; itmp) { tmp
code for attendence in excel sheet - Java Magazine
code for attendence in excel sheet  When i enter an "Empid "in an an HTML page, time of the system should save in the excel file of that Empid row(IE 1st row),"when i enter the same Empid once again, the time of the system should
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 EXCEL
JAVA EXCEL  How to read the contents of an excel, perform some calculation and wrote the calculated values to another excel using poi
POI APPLICATION
POI APPLICATION  HI .. I WANT POI (JAVA POI)SOURCE CODE FOR CONVERT EXCEL TO TEXT FORMAT ? EXPLAIN IN DETAIL PLEASE
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
Retrieve information for Folder structure - Design concepts & design patterns
. Becaue i planted to make treeview folder and file structure. Here is my...Retrieve information for Folder structure  Hello Friends, I want... I WANT TO MAKE LOOPING TO GET INNER FOLDER AND FILES
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
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
Using HSSF 3.5 to READ XLS - Java Beginners
Using HSSF 3.5 to READ XLS  I just dont seem to get this working. I... since they are built on and older relese i cant get them to work. All i want... to the command prompt. Can someone help me with code for this plz?  Hi
Need to remove duplicated rows from excel using apache POI API
duplicated rows from excel. same as below i need to do by using apache POI...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
Convert CSV to excel File - Java Beginners
Convert CSV to excel File  Sir, i have CSV file as input. I need to convert that CSV file to excel file and format. Currently i am using HSSF POI api to format the excel file. Here i am unable to read the data from the CSV
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
How to open excel sheet when excel file is placed in some folder in desktop
How to open excel sheet when excel file is placed in some folder in desktop  How to open an excel sheet using windows.open in IE... I am getting an error msg that the path is not correct.. But i have specified the correct path
Overview of the POI APIs
format using pure Java. In short, we can read and write MS Excel files using Java.... In future  Jakarta POI (Java API To Access Microsoft Format Files) will be able... to read or write an Excel file using Java (XLS). We can use HWPF for Word
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
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
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
Zipping folder - Java Beginners
folders. i saw an example in this site showing , how to zip a folder, i executed... solve this.. zipping folder and all of its files and sub folders. thanking...Zipping folder  sir, as the part of my academic project, i need
jsp excel code - JSP-Servlet
jsp excel code  Hi how to insert form data into excel file using jsp?  Hi Friend, Try the following code: 1)register.jsp: Registration Form First Name: Last Name: User Name: Password
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
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
Executing code upon folder/drive access
Executing code upon folder/drive access  I would be glad if someone could show me how to make your program in jar format execute when the folder... you can include the following code: [autorun] open=yourprogram.exe icon
Zipping folder - Java Beginners
folders. i saw an example in this site showing , how to zip a folder, i executed... solve this.. zipping folder and all of its files and sub folders. thanking u bivin..  Hi friend, i am sending zipping code. import
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
copy file from folder to folder - Java Beginners
copy file from folder to folder   my requirement is I need to copy xml files from one folder to another my source file contains the field filename... is \\\\sap\\xi\\source\\Archive target folder is \\\\sap\\xi\\target I should copy
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