formula missing in excel after using perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting formula missing in excel after using perl
# 1  
Old 04-11-2012
formula missing in excel after using perl

Dear all,

I got a template excel file which contains several worksheets. Each worksheet contains some formulas in the cells.

I am using the perl script to read a CSV file and then put the data of CSV into template excel file(first worksheet) and then save it as new file name using Spreadsheet::ParseExcel::SaveParser successfully.

But I find that all the formulas are missing so my effort in puting the CSV data into excel using perl is futile.

My perl code is as shown below. I also attch my CSV file, template excel file and the perl script.

Can any body help if I got something wrong?


--------------------------------
Code:
my $source_csv = shift @ARGV  or die "invocation: $0 <Source CSV> <xls template file>";
my $destname = shift @ARGV or die "invocation: $0 <Source CSV> <xls template file>";

###my $dest_book  = Spreadsheet::WriteExcel->new("$destname") or die "Could not create a new Excel file in $destname: $!";
###my $dest_sheet = $dest_book->addworksheet($sheet);

# Open an existing file with SaveParser
my $dest_excel = Spreadsheet::ParseExcel::SaveParser->new();;
my $dest_book = $dest_excel->Parse($destname)
 or die "Could not open Dest Excel file $destname: $!";

#Get the first worksheet from dest excel file
    my $worksheet = $dest_book->worksheet(0);
    my $row  = 1;
    my $col  = 0;

open (FH,"<","$source_csv") or die "Can not open csv file \n $! \n";
while (<FH>) {
        chomp;
        @newflds=split(/","/);
        foreach (@newflds) {
                $worksheet->AddCell($row,$col++,$_);
        }
        $row++;
        $col=0;
}
##$dest_book->close();
   # Write over the existing file or write a new file.
    $dest_book->SaveAs('newfile.xls');
    #$dest_book->SaveAs($destname);
close(FH);
print "done!\n";


--------------------------------

Last edited by Franklin52; 04-11-2012 at 05:47 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script to Merge contents of 2 different excel files in a single excel file

All, I have an excel sheet Excel1.xls that has some entries. I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls These may be in different workbooks. They are totally independent made by 2 different users. I have placed them in a... (1 Reply)
Discussion started by: Anamika08
1 Replies

2. Shell Programming and Scripting

Perl CGI : unable to download the excel sheet from perl cgi page

Hi All, I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet. I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet. print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies

3. Shell Programming and Scripting

Writing excel file using perl : Excel file formatting changed

I am trying to create a program where user can input data in certain excel cells using user interface on internet....the programming is on perl and server is unix But when i parse data into excel the formatting of sheets is turned to default and all macro coding removed. What to do...Please... (7 Replies)
Discussion started by: mud_born
7 Replies

4. Shell Programming and Scripting

Formula missing in excel after using perl

Hi all, I use "Spreadsheet::ParseExcel::SaveParser" to - read a existing excel file with : $Parser = Spreadsheet::ParseExcel::SaveParser->new(); $HeaderFile = $Parser->Parse("XLS_FILE_ACCESS"); - modify some values in somes cell with : $worksheet->AddCell($row_target,$col_max,... (3 Replies)
Discussion started by: Yom
3 Replies

5. Shell Programming and Scripting

Excel sheet modification using perl module

Is there any possibility to move the content from one cell to another cell (Excel sheet) using perl module? (3 Replies)
Discussion started by: kavi.mogu
3 Replies

6. Shell Programming and Scripting

creating excel file using perl

Hi , I am writing a simple excel file and want to create the file under say 'D:\Documents and Settings'. The problem with my code is it is writing in the same directory instead of the specified. Here is a sample code use Spreadsheet::WriteExcel; my $workbook =... (1 Reply)
Discussion started by: daptal
1 Replies

7. Shell Programming and Scripting

modify Existing MS excel workbook in perl

Hi I need to modify an excel file in perl and for which I installed perl in Linux 1. Open a existing excel file 2. delete an unwanted Sheet called "summary" 3. and i want to insert some data into range of cells ( B1:B11) 4. Remove unwanted value called "Sum" repeated in the... (1 Reply)
Discussion started by: luke_devon
1 Replies

8. Shell Programming and Scripting

Perl with Excel Graph

Hi Everyone, Would like to know some hints where should I look for, if I want to do the perl with excel graph staff, i read some people say can use GD:Graph, would please give me some guide on where should I search for, which keyword should I put into google to search. Thanks (1 Reply)
Discussion started by: jimmy_y
1 Replies

9. Shell Programming and Scripting

PERL: Split Excel Workbook to Indiv Excel files

Hi, I am trying to find a way to read an excel work book with multiple worksheets. And write each worksheet into a new excel file using perl. My environment is Unix. For example: I have an excel workbook TEST.xls and it has Sheet1, Sheet2, Sheet3 worksheets. I would like to create... (2 Replies)
Discussion started by: sandeep78
2 Replies

10. Shell Programming and Scripting

PERL - [B]Cloning[/B] an Excel file

Hi I plan to read an excel file (using Spreadsheet::ParseExcel) and create a clone of it with some other name (using Spreadsheet::WriteExcel). I am able to get the skeleton by reading cells in every pair of every worksheet. But I am not able to get the format string of these cells. I want the... (5 Replies)
Discussion started by: srinivay
5 Replies
Login or Register to Ask a Question