I can only think of two ways using POI, one of which I do not know would even
be possible.

The first would involve a great deal of work as you would be using
hyperlinks (http://poi.apache.org/spreadsheet/quick-guide.html#Hyperlinks);
clicking on a hyperlink would allow you to go down a level of detail within
the file system by 'taking' you onto a different sheet within a different
workbook (probably). All of the hyperlinks will have to be created manually
and positioned on the sheets which will themselves have to be created
manually. To automate the process, you could parse something like an xml
file which contains markup that describes the tree structure. Assuming you
have something like this to hand, your code could contain rules that say,
for example, 'when you encounter a new folder, create a new workbook'. Of
course you are not limited to xml but you do need some descriptive structure
that your code can walk through, interpreting the instructions it contains
and creating the workbooks in response.

There is a part two of the first option as well. Take a look at the concept
of outlining (http://poi.apache.org/spreadsheet/quick-guide.html#Outlining).
I can imagine this being used to describe one level of information within a
folder. Still going to be quite complex to work out the structure though.
Still, you are going to have to write the code that will walk through the
description of the file structure and converts it into a representation on
the worksheets using POI.

Option two would be to use an object - such as a directory browser which i
am sure that someone somewhere has implemented in Java - and to embed that
into a cell on a workbook as a control. If that is possible - and that is an
if as I have never tried anything like this at all - then the control can
manage the task of browsing the file structure. The one limitation that I
can think of with regard to this is that the file structure must be live -
i.e. it must physically exist somewhere rather than being a description of a
file structure. Furthermore, I think that you would have to use one of
Microsoft's visual tols for something like this or work with Excel itself
directly. They make controls available which you can position onto a
worksheet. 

Best place to start in my opinion is not with POI. Have you tried to realise
the sort of structure you require using Excel yet? All you need to do is
work with Excel directly to build something like you - or your employer -
wishes to see. If it is possible using Excel then it should be possible
using POI. That is always where I would start when faced with a task like
this one as you may find it simply is not possible to achieve what you are
after using Excel and then, of course, no amount of time working with POI
will change that. If it is possible using Excel, then you know what you want
to do and have agood idea of where to start working with the API.

Also, it may be worthwhile looking for graphical tools that *do* allow you
to represent a tree like structure. Java has one in the form of the JTree
(http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html) and I
can imagine how this could be used to do exactly what you are after.
Construct an object to hold the tree's data (the model which describes the
file structure and would, possibly, be something ike a series of linked
ArrayLists) and simply pass it to the JTree which controls the process of
displaying other levels to the user and handling their interactions with the
data (the old Model View Controller pattern). I have never tried this but
you might even be able to embed the JTree into a web page and then embed
that web page into a sheet. Might be worth a punt I guess. Also, it is well
worth looking to see if anyone offers a tree control that can be embedded
directly into a web page. This control may expose an interface that you can
interact with using Java and it might - that is a big might - even be
possible to work with the control through POI.

Do not know if any of this helps.

Yours

Mark B

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/mapping-binary-tree-to-excel-tp5709943p5709951.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to