XLSX to XML
Wednesday, 6 April 2016 · 9 messages · last reply 11 Apr 2016
FE
Florian Eckey6 Apr 2016 12:18 #
Hi guys,
are there any ideas how to convert excel's xlsx (not xls) files to xml with XQuery or to use a Java library which can be imported? It looks like BaseX has no internal functions as for instance MarkLogic.
Any ideas or example implementations to do that in XQuery or Java?
Best,
Florian
DK
Dirk Kirsten6 Apr 2016 12:26 #
Hello Florian,
xlsx is just a zip file containing many xml files. you can simply unzip the xlsx (e.g. by using the BaseX zip module), modify the xml files inside using standard XQuery and rezip it again as xslx.
Cheers
Dirk
Quoted text · Florian Eckey · 11 lines
On 04/06/2016 12:18 PM, Florian Eckey wrote: > Hi guys, > > are there any ideas how to convert excel's xlsx (not xls) files to xml > with XQuery or to use a Java library which can be imported? It looks > like BaseX has no internal functions as for instance MarkLogic. > > Any ideas or example implementations to do that in XQuery or Java? > > Best, > Florian
--
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
CG
Hi Florian,
We frequently use XQuery to read and update Excel files in our commercial projects. We haven’t made the code open source yet, though. As Dirk indicated, office files are unzipped, modified and written back, using e.g. our Archive Module and XQuery Update.
Hope this helps,
Christian
Quoted text · Florian Eckey · 12 lines
On Wed, Apr 6, 2016 at 12:18 PM, Florian Eckey <florian.eckey at googlemail.com> wrote: > Hi guys, > > are there any ideas how to convert excel's xlsx (not xls) files to xml with > XQuery or to use a Java library which can be imported? It looks like BaseX > has no internal functions as for instance MarkLogic. > > Any ideas or example implementations to do that in XQuery or Java? > > Best, > Florian
DK
Dirk Kirsten6 Apr 2016 12:43 #
Hello Florian,
please remember to always include the list when replying as it allows others to benefit from our exchange as well and also allows others to help you.
I just want to point out, again, that you it doesn't make sense to say "convert the excel file to xml", because it already is XML. Yes, there might be multiple XML files and they reference each other, but this is just a very normal thing for XML and for every reasonably complex system to reference each other.
So I guess what you really want is an XQuery module which allows you to easily manipulate xlsx files without the need to worry about internal ooxml format stuff like shared strings. This if course makes a lot of sense! However, as the format is ridiculously complicated it is a hard task to write a general-purpose library for all kinds of manipulations. As Christian indicated we wrote for ourself some small helpers functions which dies the stuff we need in our projects, but is very far from being complete on the xlsx standard.
Cheers
Dirk
Quoted text · Florian Eckey · 41 lines
On 04/06/2016 12:35 PM, Florian Eckey wrote: > Hello Dirk, > > thanks. That was my idea as well. But the format xlsx is really complicated, because the content (sheet01.xml) in the cells is referenced to an other document (stringValues.xml) using an index. I guess anyone has implemented a simple xquery to convert the excel file to xml? > But if nobody has done that before, i have to spend time for the implementation on my own. :) > > Thanks, best, > Florian > > > > > Am 06.04.16, 12:26 schrieb "Dirk Kirsten" <dk at basex.org>: > >> Hello Florian, >> >> xlsx is just a zip file containing many xml files. you can simply unzip >> the xlsx (e.g. by using the BaseX zip module), modify the xml files >> inside using standard XQuery and rezip it again as xslx. >> >> Cheers >> Dirk >> >> On 04/06/2016 12:18 PM, Florian Eckey wrote: >>> Hi guys, >>> >>> are there any ideas how to convert excel's xlsx (not xls) files to xml >>> with XQuery or to use a Java library which can be imported? It looks >>> like BaseX has no internal functions as for instance MarkLogic. >>> >>> Any ideas or example implementations to do that in XQuery or Java? >>> >>> Best, >>> Florian >> -- >> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >>
--
Dirk Kirsten, BaseX GmbH, http://basexgmbh.de
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
CG
Christian Grün6 Apr 2016 12:48 #
Hi Florian,
Out of interest: Could you tell us a little about your experiences with the MarkLogic Excel module? Does it e.g. support updates as well?
Thanks in advance,
Christian
Quoted text · Dirk Kirsten · 74 lines
On Wed, Apr 6, 2016 at 12:43 PM, Dirk Kirsten <dk at basex.org> wrote: > Hello Florian, > > please remember to always include the list when replying as it allows > others to benefit from our exchange as well and also allows others to > help you. > > I just want to point out, again, that you it doesn't make sense to say > "convert the excel file to xml", because it already is XML. Yes, there > might be multiple XML files and they reference each other, but this is > just a very normal thing for XML and for every reasonably complex system > to reference each other. > > So I guess what you really want is an XQuery module which allows you to > easily manipulate xlsx files without the need to worry about internal > ooxml format stuff like shared strings. This if course makes a lot of > sense! However, as the format is ridiculously complicated it is a hard > task to write a general-purpose library for all kinds of manipulations. > As Christian indicated we wrote for ourself some small helpers functions > which dies the stuff we need in our projects, but is very far from being > complete on the xlsx standard. > > Cheers > Dirk > > On 04/06/2016 12:35 PM, Florian Eckey wrote: >> Hello Dirk, >> >> thanks. That was my idea as well. But the format xlsx is really complicated, because the content (sheet01.xml) in the cells is referenced to an other document (stringValues.xml) using an index. I guess anyone has implemented a simple xquery to convert the excel file to xml? >> But if nobody has done that before, i have to spend time for the implementation on my own. :) >> >> Thanks, best, >> Florian >> >> >> >> >> Am 06.04.16, 12:26 schrieb "Dirk Kirsten" <dk at basex.org>: >> >>> Hello Florian, >>> >>> xlsx is just a zip file containing many xml files. you can simply unzip >>> the xlsx (e.g. by using the BaseX zip module), modify the xml files >>> inside using standard XQuery and rezip it again as xslx. >>> >>> Cheers >>> Dirk >>> >>> On 04/06/2016 12:18 PM, Florian Eckey wrote: >>>> Hi guys, >>>> >>>> are there any ideas how to convert excel's xlsx (not xls) files to xml >>>> with XQuery or to use a Java library which can be imported? It looks >>>> like BaseX has no internal functions as for instance MarkLogic. >>>> >>>> Any ideas or example implementations to do that in XQuery or Java? >>>> >>>> Best, >>>> Florian >>> -- >>> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >>> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >>> > > -- > Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >
LV
Florian,
The xsl-excel-engine project might help you get started working with xlsx files:
https://github.com/foglcz/xsl-excel-engine
xsl-excel-engine is for writing XML files so it does not do what you are asking, but the wiki documentation provides an introduction to the Excel file format. It includes scripts to parse stringValues.xml which you might be able to use.
Vincent
Quoted text · basex-talk-bounces at mailman.uni-konstanz.de · 70 lines
From: basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] On Behalf Of Dirk Kirsten Sent: Wednesday, April 06, 2016 6:44 AM To: Florian Eckey <florian.eckey at googlemail.com>; basex-talk at mailman.uni-konstanz.de Subject: Re: [basex-talk] XLSX to XML Hello Florian, please remember to always include the list when replying as it allows others to benefit from our exchange as well and also allows others to help you. I just want to point out, again, that you it doesn't make sense to say "convert the excel file to xml", because it already is XML. Yes, there might be multiple XML files and they reference each other, but this is just a very normal thing for XML and for every reasonably complex system to reference each other. So I guess what you really want is an XQuery module which allows you to easily manipulate xlsx files without the need to worry about internal ooxml format stuff like shared strings. This if course makes a lot of sense! However, as the format is ridiculously complicated it is a hard task to write a general-purpose library for all kinds of manipulations. As Christian indicated we wrote for ourself some small helpers functions which dies the stuff we need in our projects, but is very far from being complete on the xlsx standard. Cheers Dirk On 04/06/2016 12:35 PM, Florian Eckey wrote: > Hello Dirk, > > thanks. That was my idea as well. But the format xlsx is really complicated, because the content (sheet01.xml) in the cells is referenced to an other document (stringValues.xml) using an index. I guess anyone has implemented a simple xquery to convert the excel file to xml? > But if nobody has done that before, i have to spend time for the implementation on my own. :) > > Thanks, best, > Florian > > > > > Am 06.04.16, 12:26 schrieb "Dirk Kirsten" <dk at basex.org<mailto:dk at basex.org>>: > >> Hello Florian, >> >> xlsx is just a zip file containing many xml files. you can simply unzip >> the xlsx (e.g. by using the BaseX zip module), modify the xml files >> inside using standard XQuery and rezip it again as xslx. >> >> Cheers >> Dirk >> >> On 04/06/2016 12:18 PM, Florian Eckey wrote: >>> Hi guys, >>> >>> are there any ideas how to convert excel's xlsx (not xls) files to xml >>> with XQuery or to use a Java library which can be imported? It looks >>> like BaseX has no internal functions as for instance MarkLogic. >>> >>> Any ideas or example implementations to do that in XQuery or Java? >>> >>> Best, >>> Florian >> -- >> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de<http://basexgmbh.de> >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >> -- Dirk Kirsten, BaseX GmbH, http://basexgmbh.de<http://basexgmbh.de> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22
AB
Florian,
The joined module transforms an excel file (saved in XML spreadsheet 2003, and imported in the IN db) into a XML file.
I hope it could help.
André
Quoted text · Dirk Kirsten · 30 lines
> Le 6 avr. 2016 à 12:26, Dirk Kirsten <dk at basex.org> a écrit : > > Hello Florian, > > xlsx is just a zip file containing many xml files. you can simply unzip > the xlsx (e.g. by using the BaseX zip module), modify the xml files > inside using standard XQuery and rezip it again as xslx. > > Cheers > Dirk > > On 04/06/2016 12:18 PM, Florian Eckey wrote: >> Hi guys, >> >> are there any ideas how to convert excel's xlsx (not xls) files to xml >> with XQuery or to use a Java library which can be imported? It looks >> like BaseX has no internal functions as for instance MarkLogic. >> >> Any ideas or example implementations to do that in XQuery or Java? >> >> Best, >> Florian > > -- > Dirk Kirsten, BaseX GmbH, http://basexgmbh.de > |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz > |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: > | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle > `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >
FE
Hi Christian,
I have only seen that there exists a function in MarkLogic for reading excel files or especially convert excel to xhtml, but it looks like (as in the example) MarkLogic can only process xls files, not xlsx. https://docs.marklogic.com/xdmp.excelConvert
Looks like it does not support updates.
As soon as I get more experience, i will share it here.
Best,
Florian
Quoted text · 12:48 · 85 lines
Am 06.04.16, 12:48 schrieb "Christian Grün" <christian.gruen at gmail.com>: >Hi Florian, > >Out of interest: Could you tell us a little about your experiences >with the MarkLogic Excel module? Does it e.g. support updates as well? > >Thanks in advance, >Christian > > > >On Wed, Apr 6, 2016 at 12:43 PM, Dirk Kirsten <dk at basex.org> wrote: >> Hello Florian, >> >> please remember to always include the list when replying as it allows >> others to benefit from our exchange as well and also allows others to >> help you. >> >> I just want to point out, again, that you it doesn't make sense to say >> "convert the excel file to xml", because it already is XML. Yes, there >> might be multiple XML files and they reference each other, but this is >> just a very normal thing for XML and for every reasonably complex system >> to reference each other. >> >> So I guess what you really want is an XQuery module which allows you to >> easily manipulate xlsx files without the need to worry about internal >> ooxml format stuff like shared strings. This if course makes a lot of >> sense! However, as the format is ridiculously complicated it is a hard >> task to write a general-purpose library for all kinds of manipulations. >> As Christian indicated we wrote for ourself some small helpers functions >> which dies the stuff we need in our projects, but is very far from being >> complete on the xlsx standard. >> >> Cheers >> Dirk >> >> On 04/06/2016 12:35 PM, Florian Eckey wrote: >>> Hello Dirk, >>> >>> thanks. That was my idea as well. But the format xlsx is really complicated, because the content (sheet01.xml) in the cells is referenced to an other document (stringValues.xml) using an index. I guess anyone has implemented a simple xquery to convert the excel file to xml? >>> But if nobody has done that before, i have to spend time for the implementation on my own. :) >>> >>> Thanks, best, >>> Florian >>> >>> >>> >>> >>> Am 06.04.16, 12:26 schrieb "Dirk Kirsten" <dk at basex.org>: >>> >>>> Hello Florian, >>>> >>>> xlsx is just a zip file containing many xml files. you can simply unzip >>>> the xlsx (e.g. by using the BaseX zip module), modify the xml files >>>> inside using standard XQuery and rezip it again as xslx. >>>> >>>> Cheers >>>> Dirk >>>> >>>> On 04/06/2016 12:18 PM, Florian Eckey wrote: >>>>> Hi guys, >>>>> >>>>> are there any ideas how to convert excel's xlsx (not xls) files to xml >>>>> with XQuery or to use a Java library which can be imported? It looks >>>>> like BaseX has no internal functions as for instance MarkLogic. >>>>> >>>>> Any ideas or example implementations to do that in XQuery or Java? >>>>> >>>>> Best, >>>>> Florian >>>> -- >>>> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >>>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>>> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >>>> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >>>> >> >> -- >> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >>
EK
Eliot Kimber11 Apr 2016 21:10 #
I've written some XSLT to handle some of XSLX in the context of my Word-to-DITA transformation framework:
https://github.com/dita4publishers/org.dita4publishers.word2dita/tree/devel op/xsl
The business logic should be relatively easy to recode as Xquery if appropriate.
In addition, the Apache POI project provides pretty robust Java code reading and writing Office documents including Excel files. It should be relatively easy to use it from BaseX as a Java extension.
Cheers,
Eliot
----
Eliot Kimber, Owner
Contrext, LLC
http://contrext.com
On 4/11/16, 6:00 AM, "Florian Eckey"
<basex-talk-bounces at mailman.uni-konstanz.de on behalf of
Quoted text · Florian Eckey · 115 lines
florian.eckey at googlemail.com> wrote: >Hi Christian, > >I have only seen that there exists a function in MarkLogic for reading >excel files or especially convert excel to xhtml, but it looks like (as >in the example) MarkLogic can only process xls files, not xlsx. >https://docs.marklogic.com/xdmp.excelConvert > >Looks like it does not support updates. >As soon as I get more experience, i will share it here. > >Best, >Florian > > > > >Am 06.04.16, 12:48 schrieb "Christian Grün" <christian.gruen at gmail.com>: > >>Hi Florian, >> >>Out of interest: Could you tell us a little about your experiences >>with the MarkLogic Excel module? Does it e.g. support updates as well? >> >>Thanks in advance, >>Christian >> >> >> >>On Wed, Apr 6, 2016 at 12:43 PM, Dirk Kirsten <dk at basex.org> wrote: >>> Hello Florian, >>> >>> please remember to always include the list when replying as it allows >>> others to benefit from our exchange as well and also allows others to >>> help you. >>> >>> I just want to point out, again, that you it doesn't make sense to say >>> "convert the excel file to xml", because it already is XML. Yes, there >>> might be multiple XML files and they reference each other, but this is >>> just a very normal thing for XML and for every reasonably complex >>>system >>> to reference each other. >>> >>> So I guess what you really want is an XQuery module which allows you to >>> easily manipulate xlsx files without the need to worry about internal >>> ooxml format stuff like shared strings. This if course makes a lot of >>> sense! However, as the format is ridiculously complicated it is a hard >>> task to write a general-purpose library for all kinds of manipulations. >>> As Christian indicated we wrote for ourself some small helpers >>>functions >>> which dies the stuff we need in our projects, but is very far from >>>being >>> complete on the xlsx standard. >>> >>> Cheers >>> Dirk >>> >>> On 04/06/2016 12:35 PM, Florian Eckey wrote: >>>> Hello Dirk, >>>> >>>> thanks. That was my idea as well. But the format xlsx is really >>>>complicated, because the content (sheet01.xml) in the cells is >>>>referenced to an other document (stringValues.xml) using an index. I >>>>guess anyone has implemented a simple xquery to convert the excel file >>>>to xml? >>>> But if nobody has done that before, i have to spend time for the >>>>implementation on my own. :) >>>> >>>> Thanks, best, >>>> Florian >>>> >>>> >>>> >>>> >>>> Am 06.04.16, 12:26 schrieb "Dirk Kirsten" <dk at basex.org>: >>>> >>>>> Hello Florian, >>>>> >>>>> xlsx is just a zip file containing many xml files. you can simply >>>>>unzip >>>>> the xlsx (e.g. by using the BaseX zip module), modify the xml files >>>>> inside using standard XQuery and rezip it again as xslx. >>>>> >>>>> Cheers >>>>> Dirk >>>>> >>>>> On 04/06/2016 12:18 PM, Florian Eckey wrote: >>>>>> Hi guys, >>>>>> >>>>>> are there any ideas how to convert excel's xlsx (not xls) files to >>>>>>xml >>>>>> with XQuery or to use a Java library which can be imported? It looks >>>>>> like BaseX has no internal functions as for instance MarkLogic. >>>>>> >>>>>> Any ideas or example implementations to do that in XQuery or Java? >>>>>> >>>>>> Best, >>>>>> Florian >>>>> -- >>>>> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >>>>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>>>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>>>> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >>>>> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >>>>> >>> >>> -- >>> Dirk Kirsten, BaseX GmbH, http://basexgmbh.de >>> |-- Firmensitz: Blarerstrasse 56, 78462 Konstanz >>> |-- Registergericht Freiburg, HRB: 708285, Geschäftsführer: >>> | Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle >>> `-- Phone: 0049 7531 91 68 276, Fax: 0049 7531 20 05 22 >>> > >
Written for BaseX 8.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery