Writing from an Oracle Database to an Excel File.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newtechiebug
    New Member
    • Mar 2007
    • 6

    Writing from an Oracle Database to an Excel File.

    I am really new with Perl and I am trying to write data from an Oracle database to an Excel Spreadsheet simply by clicking on a link. I have read over CPAN Spreadsheet::Wr iteExcel and I really am not sure where to even begin. Do I have to write a .pl page for this Write Excel or can I write to an Excel file from an ASPX or ASP page? Also will it be one page that I create or multiple pages?
    I'm assuming this task shouldn't be too difficult, but I can't even wrap my head around where to begin. Any direction at all would be great or any code snippets to get me started would be appreciated as well.
    Thanks!
  • tifoso
    New Member
    • Apr 2007
    • 41

    #2
    Not clear if u want to do it on the fly or write and actual file, it sounds like reading Oracle is no issue., writing to a file -> quickest way write to a comma separated field file and named it with extension CSV. XL will read it fine.

    You can do it cleaner from ASPX with an object but since this is a perl section my guess is you want perl to do it.

    Cheers

    Becker

    Comment

    • newtechiebug
      New Member
      • Mar 2007
      • 6

      #3
      Whatever is the easiest way to accomplish this task is what I'm interested in.
      I have a table conferences and in this table I have 4 columns (1,2,3,4) that I want to write to a csv, xls, tab delimited. What I'm hoping to happen is for a person to click on a link that says "Click here for data" and when they click a file is created which they can then view in Excel. I understand that .NET would be so much easier unfortunately it has to be done from a PERL page.
      Any suggestions?
      Thanks!

      Originally posted by tifoso
      Not clear if u want to do it on the fly or write and actual file, it sounds like reading Oracle is no issue., writing to a file -> quickest way write to a comma separated field file and named it with extension CSV. XL will read it fine.

      You can do it cleaner from ASPX with an object but since this is a perl section my guess is you want perl to do it.

      Cheers

      Becker

      Comment

      • newtechiebug
        New Member
        • Mar 2007
        • 6

        #4
        This is what I currently have and it is not working. What might I be missing or am I overlooking something altogether?
        Thanks,
        Katie

        #!/afs/isis.unc.edu/pkg/perl-582/bin/perl

        use Spreadsheet::Wr iteExcel::FromD B;

        use Spreadsheet::Wr iteExcel::FromD B::Query;

        my $dbh = DBI->connect("dbi:O racle:oracle.un c.edu",'usernam e','password',
        { RaiseError => 0, AutoCommit => 0, LongReadLen => 16384 } ) ||
        &do_error("Logg ing in to database: $DBI::errstr");

        $query = q{'SELECT dateadded, totalpeople, miles, totalsaved FROM OWNER.Conferenc e ORDER BY dateadded'};
        my $ss = Spreadsheet::Wr iteExcel::FromD B->read($dbh, $query);

        print $ss->write_xls('sav ings.xls');

        Comment

        Working...