开发者

Excel to XML code in java?

开发者 https://www.devze.com 2022-12-14 13:20 出处:网络
I need code in java for Excel to XML conversion. where Excel sheet will be used as the input file and XML file as the output file.we have to read the Excel file Row and column wise and than write that

I need code in java for Excel to XML conversion. where Excel sheet will be used as the input file and XML file as the output file.we have to read the Excel file Row and column wise and than write that data to开发者_如何学JAVA XMl file.

please anybody give any Code or URL or any Repository of example,which would be appreciated.

Thanks,

Mishal Shah


Have a look at Apache POI. I'm sure there are some examples there.


This may not be the answer you were looking for, but Excel already has built-in support for XML. If you are using Excel 2007, you will need to enable the Developer tab on the ribbon. From there you can import and export XML schemas and files.

To enable the developer tab:

  1. Click the Microsoft button...

    Excel to XML code in java?

  2. Click Excel Options

  3. Check "Show Developer Tab in the Ribbon"

You will need to create a map by either importing an example XML file that is in the same format as the one you'd like to export, or you can click Source and use a schema (XSD) file.

From there, you just need to map the elements in your XML Map to the data in your sheet, then export the data to an XML file.


I did a "Read Excel into a DefaultTableModel" in about 20 lines with the JExcel API. It was very nice and simple to use.


JExcel is another option, although I think it has less features and doesn't support the latest excel format like the Apache POI does.


I have done conversion of Excel(xlsx) to xml in Java recently. I assumed each row in excel as a single object here. Here are the steps I followed:-

  1. Read Excel file using Apache POI
  2. Created a xsd file and generated corresponding classes
  3. Read each row created, created corresponding objects and initilaized values using the generated getter/setter methods in the classes
  4. Added the objects to an arraylist which holds only objects the same type
  5. Using Jaxb Marshelled the arraylist object to an output file

Ready to provide code if required Here's where you can start https://sites.google.com/site/arjunwebworld/Home/programming/jaxb-example

0

精彩评论

暂无评论...
验证码 换一张
取 消