Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Development-process Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


muthu kumaran
Java sdk/java poi hssf code to creat excel with folder structure,( i,e folders, subfolders and childrens )
0 Answer(s)      2 years and 6 months ago
Posted in : Development process


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

Advertisement
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
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
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
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
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
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" %> <
POI APPLICATION
POI APPLICATION  HI .. I WANT POI (JAVA POI)SOURCE CODE FOR CONVERT EXCEL TO TEXT FORMAT ? EXPLAIN IN DETAIL PLEASE
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
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
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
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
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
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
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
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
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
 

 

 

DMCA.com