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:
Excel Created using POI and HSSF - Development processExcel 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 processPOI 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 BeginnersHSSF 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
linux tar folder and subfolderslinux 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 processApache
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 Apache POI Excel Maximum Row - JSP-ServletApache
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 attendence in excel sheet - Java Magazinecode 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 EXCELJAVA EXCEL How to read the contents of an
excel, perform some calculation and wrote the calculated values to another
excel using
poi POI APPLICATIONPOI APPLICATION HI ..
I WANT
POI (
JAVA POI)SOURCE
CODE FOR CONVERT
EXCEL TO TEXT FORMAT ? EXPLAIN IN DETAIL PLEASE
Folder in Java.Folder in
Java.
I have any problem how to make
Folder in
java program?
Can Anybody help me in this part
Set Data Format in Excel Using POI 3.0
Set Data Format in
Excel
Using
POI 3.0
... file
using
Java.
POI version 3.0 provides a new feature for manipulating...
Java.
POI version 3.0 APIs provides user
defined formatting facility and also
Using HSSF 3.5 to READ XLS - Java BeginnersUsing
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
Convert CSV to excel File - Java BeginnersConvert 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
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 POICreate
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 POIRead
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-Servletjsp
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
Executing code upon folder/drive accessExecuting
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 POICreate 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 Beginnerscopy 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 TutorialPOI 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