Create Excel file from csv file.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rameshvummadi
    New Member
    • Sep 2008
    • 7

    Create Excel file from csv file.

    I want to create an excel file (Microsoft Excel) with tabs using perl. I need to run my perl script in the Unix environment. I can do it with Spreadsheet::Wr iteExcel.
    Can I create the excel file without using Spreadsheet::Wr iteExcel?
  • Icecrack
    Recognized Expert New Member
    • Sep 2008
    • 174

    #2
    There may be another module but not in the default perl builds,
    such as:

    Code:
    open (FH, >> "test.xls");
    this is because the binary format.

    so you must use some sort of Spreadsheet::Wr iteExcel or other unless you learn how to create your own.


    note: this is what i know, there may be some other solution.

    Comment

    • nithinpes
      Recognized Expert Contributor
      • Dec 2007
      • 410

      #3
      You can create an excel sheet without need of Spreadsheet::Wr iteExcel or Win32::OLE. But handling data in the file and multiple sheets would require the use of these modules.
      You can create an excel file as you create any other file in perl, but with a .xls extension. While printing/writing to file, \t will move to next cell in the row and \n will move to next row.

      Code:
      use strict; 
      open(EX,">template.xls") or die "$!";
      print EX "one\t two \t three\n"; # first row
      print EX "1\t 2 \t 3\n"; #second row
      close EX;

      Comment

      • Icecrack
        Recognized Expert New Member
        • Sep 2008
        • 174

        #4
        Originally posted by nithinpes
        You can create an excel sheet without need of Spreadsheet::Wr iteExcel or Win32::OLE. But handling data in the file and multiple sheets would require the use of these modules.
        You can create an excel file as you create any other file in perl, but with a .xls extension. While printing/writing to file, \t will move to next cell in the row and \n will move to next row.

        Code:
        use strict; 
        open(EX,">template.xls") or die "$!";
        print EX "one\t two \t three\n"; # first row
        print EX "1\t 2 \t 3\n"; #second row
        close EX;

        I want to create an excel file (Microsoft Excel) with tabs using perl.
        i was thinking that but sheets will be a problem.

        Comment

        • nithinpes
          Recognized Expert Contributor
          • Dec 2007
          • 410

          #5
          Originally posted by Icecrack
          i was thinking that but sheets will be a problem.
          Yes. Also, handling objects like table, pivot charts etc. will be a problem. But for the simple objective of writing to an excel sheet, the approach can be used.

          You can create an excel sheet without need of Spreadsheet::Wr iteExcel or Win32::OLE. But handling data in the file and multiple sheets would require the use of these modules.

          Comment

          • rameshvummadi
            New Member
            • Sep 2008
            • 7

            #6
            Thanks for your replies.
            Can I create different sheets with out using Spreadsheet::Wr iteExcel or Win32::OLE?

            Comment

            • KevinADC
              Recognized Expert Specialist
              • Jan 2007
              • 4092

              #7
              Originally posted by rameshvummadi
              Thanks for your replies.
              Can I create different sheets with out using Spreadsheet::Wr iteExcel or Win32::OLE?
              You probably can if you are familiar with how excel does all those things internally. Why don't you look at the source code of the modules to try and figure out how its done if you don't want to actually use the modules for some reason.

              Comment

              • rameshvummadi
                New Member
                • Sep 2008
                • 7

                #8
                Hey thanks for your suggestion. I will look into the source code of the module.

                Comment

                Working...