This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Flex and the fly likes How to convert an excel data to XML to use it in a Flex application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "How to convert an excel data to XML to use it in a Flex application?" Watch "How to convert an excel data to XML to use it in a Flex application?" New topic
Author

How to convert an excel data to XML to use it in a Flex application?

Senguttuvan Paramasivam
Greenhorn

Joined: Feb 20, 2010
Posts: 7
I have data in excel 2007 spreadsheet in a server, I want to convert the excel data into XML, which is used in the Flex front-end for displaying at the client side. Also, I want to do few calculations during the display of the excel data. Can anyone give me idea how to implement this?

I have decided to place the excel spreadsheet at server side and deploy a java server application using POI in a web container in the same server. When I execute the flex application at client side, it will connect to java application at server side. The java application will convert the data from excel to XML , then the flex code will use the XML data for display. Will this approach work for me? Do you have any other suggestion, please reply to me.

Thanks!!
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11285
    
  59

This all sounds reasonable at a high level.

Senguttuvan wrote:I want to do few calculations during the display of the excel data. Can anyone give me idea how to implement this?

Your question is far too broad at present to give any detailed ideas. Assuming you only want high level concepts, I can see two straightforward options:
  • Perform the calculations Java side prior to sending the XML to your flex app.
  • Perform the calculations in the Flex application.


  • Several things to consider:
  • Calculations client side would result in less network traffic.
  • Calculations server side will result in more work on the server.
  • Work performed server side could easily be persisted in the Excel spreadsheet (or elsewhere)
  • Less work client side will leave the interface cleaner, making it easier to change the view at a later time (e.g. if you wanted to change to an HTML 5 solution instead of Flex)


  • Senguttuvan wrote:I have decided to [...] Will this approach work for me?

    Again - this is very high level. But the overall approach sounds reasonable.


    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Senguttuvan Paramasivam
    Greenhorn

    Joined: Feb 20, 2010
    Posts: 7
    Hi Andrew,

    Thanks for your reply. As you said, this is truly a high level design. However, I want to go bit low level. My Question is...When I generate XML at server side, where should I keep the XML to make use of it in FLEX at client side. It should be either at client side or at server side? If I keep the XML at server side, then the flex will connect to server for each client request (even if it is a small operation). On the other side, to keep the XML at client side, what will be the best way to send the whole XML to each requested clients? When I keep the XML at client side, it will be easy for FLEX to get and display the data. Can you please give me any suggestion where should I keep the server generated XML file?

    Thanks
    Senguttuvan



    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11285
        
      59

    As a general rule, you probably want to push the bare minimum amount of data over to the client. If all you were doing was displaying the data, you might choose to send only enough information needed to display a screen's worth of data. If you decide to go down a thick-client route, you might increase that to all the rows needed to display a screen's worth of data (assuming that you are calculating data on a row-by-row basis).
    Senguttuvan Paramasivam
    Greenhorn

    Joined: Feb 20, 2010
    Posts: 7
    Hi Andrew,

    Thanks again for your update. I have deployed a java web application in tomcat server. Also, My Excel file has been placed in the same server in a physical path. I have to connect with the java object in the server when I execute the FLEX ( swf file) from client side. I am using Flex 3 and tomcat 7. The java object, which is in the server, will use POI API to read Excel spreadhsheet and convert it into XML file at very first time.

    For the rest of the flex request, the corresponding java object will process the XML data and send necessary data to Client (Flex). Do you have any idea how does the Flex interact with the Java code? Do you have any efficient way to implement this?

    Thanks
    Senguttuvan
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11285
        
      59

    Personally I like to use REST - using Jersey it is simple to create an API that can be consumed by many clients. The only problem is that (at least in Flex 3) the communication is limited to GET and POST (no PUT or DELETE). This may not be a problem for you - you can workaround these problems by adding parameters to your POST, or use something like restHttpService).

    A lot of people using Flex and Java prefer to use BlazeDS. My understanding is that this is not quite as open, but it may be an easier route.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: How to convert an excel data to XML to use it in a Flex application?
     
    Similar Threads
    Webservice calling
    Parsing excel data - Urgent
    POI and Excel formulas
    display output table in excel file format
    using ms excel as a database