Hi,
Il giorno 16/ott/09, alle ore 20:48, David Fisher ha scritto:
The excel file is generated automatically and come from a source. I
do not want
to modify it or manually open it.
Of course not. We all must automate, that's why we use POI.
The data I need exists in the Pivot Tables and that can change.
I want to do the equivalent of opening an test.xlsx file in Excel
2007 and
Saving AS a test.xml file but programatically so I can use the data
on the
server for further use.
Understood.
Let me know if that can be done using the Apache POI API.
To do so would require modifying the code that Roberto donated to
perform Excel's default behavior.
my code requires a user defined mapping in which the user can select
which part of the XSLX will be extracted and set an custom output XML
Schema.
The 'save as xml' feature, i think, is much more simple (fixed mapping
and fixed schema) and requires few lines of code to implement it.
It can be implemented like this:
- Create a DOM node
-for each Sheet
- create a SHEET element in the DOM
- for each row in the sheet
- create a ROW element in the SHEET element
- for each column in the row
- create a COLUMN element (or attribute) in the ROW element
and set the cell identified by the row and column value in it
- serialize the DOM
for both on DOM management and XFFSWorbook tree navigation you can
find some examples in my class:
http://svn.apache.org/repos/asf/poi/trunk/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java
Cheers,
Roberto
If you would like to try that would be great, otherwise you can file
a bugzilla report and include an example xlsx and xml files and code
that you have tried. That way this issue won't get lost, and has a
chance of being eventually resolved.
Now if you know where in the xlsx the cells are then I'm sure you
can extract those and then output in xml from your program. Not a
general solution, and not nearly as elegant, but you could get that
done with POI as it is now.
These links to examples might be a starting point for you:
http://poi.apache.org/spreadsheet/how-to.html#xssf_sax_api
These examples are HSSF, but SS combined versions can be done.
http://poi.apache.org/spreadsheet/converting.html
http://poi.apache.org/spreadsheet/quick-guide.html#Iterator
http://poi.apache.org/spreadsheet/quick-guide.html#CellContents
http://poi.apache.org/spreadsheet/quick-guide.html#TextExtraction
Thanks for all the help.
You're welcome
Regards,
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
For additional commands, e-mail: user-h...@poi.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@poi.apache.org
For additional commands, e-mail: user-h...@poi.apache.org
--
Roberto Manicardi
=
=
=
========================================================================
http://www.jugroma.it
http://roma.javaday.it
JUG Roma Coordinator