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 )

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 a month 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
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
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
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
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
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
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
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
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
Error in POI - Java Beginners
Error in POI  Hi friend, I am working with Excel using POI API.I need to read an excel file and do some modifications and save this file into different location. Along with this I need to remove the extra sheets which
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
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
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
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
poi & class path - Java Beginners
poi & class path  This is the same problem regarding POI , Sir , i...://www.mirrorgeek.com/apache.org/poi/dev/bin/ i dont know wether...-FINAL-20081019.jar and poi-scratchpad-3.2-FINAL-20081019.jar files into lib folder
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
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
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
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
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
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
Read Simple Excel(.xls) document using Apache POI
Read Simple Excel(.xls) document using Apache POI In this section, you will learn how to read Excel file having .xls extension using Apache POI library... POI version 3.7. For downloading the above library click here. The code
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
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
image save to folder in java
image save to folder in java  Hi, I am working with java. In my application i want to give facility to user to add and change image. I use open... is open select any image i want to store that selected image into specified
How to read a rows which have a values in a excel file using apache poi - JSP-Servlet
How to read a rows which have a values in a excel file using apache poi  Dear sir, How to read excel file in that only a rows which are having some values using apache poi...please help me sir. Thanks and Regards
Advertisements
 

 

 

DMCA.com