write to existing Excel file using Perl under FreeBSD + Perl 5.005_03

Posted on 2006-05-17
Last Modified: 2013-12-25
I have an existing Excel template file, and I would like to update it via web form.

How can this be done?
Question by:jay28lee
    LVL 8

    Expert Comment

    Are you using an XML file for the template? You could probably use XML::Simple to read the XML file and get it into a CGI form you can use to update it with once again useing XML::Simple. Then you can possibly use the Excel::Template module to create the excel file.

    Author Comment

    Is there a simple example coding of actual usage that you can show me?

    I'm not familiar with these modules.
    LVL 8

    Accepted Solution

    Both of the module documentations have code examples. If you don't actually need to create the excel file from the template at the time of the update then there is no need to use the Excel::Templat module at all. I'll use the example from the XML::Simple module, the xml file:


    <config logdir="/var/log/foo/" debugfile="/tmp/foo.debug">
      <server name="sahara" osname="solaris" osversion="2.6">
      <server name="gobi" osname="irix" osversion="6.5">
      <server name="kalahari" osname="linux" osversion="2.0.34">

    the outline of a script to get the file into a form:

    use strict;
    use warnings;
    use CGI;
    use XML::Simple;
    #use Data::Dumper;
    my $q = new CGI;
    my $config = XMLin();
    my @fields = qw(logdir debugfile);

    print $q->header,
          $q->start_form(-action => '');
    foreach my $fields (@fields) {
       print "$fields: ",
       '<br />';  
    print $q->submit(),

    then gets the form data and reopens the xml file, plugs the new values into the appropriate variables, and saves the data back to the xml file using the XMLout() function. Hope that gets you started.  

    ***I wish this forum had a preview option***

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
    Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
    Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now