if ( -d $dest ) { was not needed, the previous chdir would have failed if $dest was not a directory.
chomp $file is not needed, a trailing newline is an acceptable (if not appreciated) character in a directory entry
Be reluctant to use system calls in a perlscript. In this case, my $sheetname = `basename $file | cut -d. -f1`; was replaced by $file =~ s{\..*$}{}; as $file is already a "basename" and you were just trimming off everything after the first ".".
Hi,
I have a question about using C to write excel file.
There is a way to write into a sheet into a file excel, like this:
FILE * File;
pMyFile = fopen("test.xls", "w+");
fprintf(File, "\n\n"); /* go to the row 2 of the column A*/
fprintf(File, "%s", "Hi pippo!"); /* write... (7 Replies)
Hi,
There is this requirement to create multiple work sheets in an MS Excel file through UNIX.
We normally can create one work sheet in unix by either tab or comma delimiting and appending .xls or .csv to the file name, but can we create multiple work sheets.
Regards,
Puspendu (1 Reply)
Hi,
I have generated an excel sheet using a shell script. i have converted the output text file to an excel and got the desired output. However, in a particular column in the excel the values of the numbers start with 0.
e.g. 078393343, 00342442, etc.
But, in the resulting excel I get as... (2 Replies)
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)
Hi,
I need your help in sedning sql queries output to different excel sheets.
My requirement is like this:
Query1: Select name from table1 where status = 'Complete'
Query2: Select name from table1 where status = 'Failed'
Query3: Select name from table1 where status = 'Ignored'
... (4 Replies)
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)
Hi UNIX Gods!
Is it possible to merge two cells in .csv file using unix commands?
Imagine that this is my present csv file opened via excel:
Gate Reports| |
fatal alerts | 200 |
is is possible to make it look like this using unix?
Gate Reports |
fatal... (1 Reply)
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)
I have requirement to write two CSV files to one single excel with multiple sheets.
Data present in the two files should sit in excel as different sheets.
How can we achieve this using shell script?
1.csv 2. csv
1,2,3,4 5,6,7,8
XXXXX YYYYY
Res.excel
1.csv data... (1 Reply)
Dear all,
I have a large dictionary database which has the following structure
source word=target word
e.g.
book=livre
Since the database is very large in spite of all the care taken, it so happens that at times the source word is repeated
e.g.
book=livre
book=tome
Since I want to... (7 Replies)
Discussion started by: gimley
7 Replies
LEARN ABOUT DEBIAN
spreadsheet::parseexcel::saveparser
Spreadsheet::ParseExcel::SaveParser(3pm) User Contributed Perl Documentation Spreadsheet::ParseExcel::SaveParser(3pm)NAME
Spreadsheet::ParseExcel::SaveParser - Rewrite an existing Excel file.
SYNOPSIS
Say we start with an Excel file that looks like this:
-----------------------------------------------------
| | A | B | C |
-----------------------------------------------------
| 1 | Hello | ... | ... | ...
| 2 | World | ... | ... | ...
| 3 | *Bold text* | ... | ... | ...
| 4 | ... | ... | ... | ...
| 5 | ... | ... | ... | ...
Then we process it with the following program:
#!/usr/bin/perl
use strict;
use warnings;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::SaveParser;
# Open an existing file with SaveParser
my $parser = Spreadsheet::ParseExcel::SaveParser->new();
my $template = $parser->Parse('template.xls');
# Get the first worksheet.
my $worksheet = $template->worksheet(0);
my $row = 0;
my $col = 0;
# Overwrite the string in cell A1
$worksheet->AddCell( $row, $col, 'New string' );
# Add a new string in cell B1
$worksheet->AddCell( $row, $col + 1, 'Newer' );
# Add a new string in cell C1 with the format from cell A3.
my $cell = $worksheet->get_cell( $row + 2, $col );
my $format_number = $cell->{FormatNo};
$worksheet->AddCell( $row, $col + 2, 'Newest', $format_number );
# Write over the existing file or write a new file.
$template->SaveAs('newfile.xls');
We should now have an Excel file that looks like this:
-----------------------------------------------------
| | A | B | C |
-----------------------------------------------------
| 1 | New string | Newer | *Newest* | ...
| 2 | World | ... | ... | ...
| 3 | *Bold text* | ... | ... | ...
| 4 | ... | ... | ... | ...
| 5 | ... | ... | ... | ...
DESCRIPTION
The "Spreadsheet::ParseExcel::SaveParser" module rewrite an existing Excel file by reading it with "Spreadsheet::ParseExcel" and rewriting
it with "Spreadsheet::WriteExcel".
METHODS Parser
new()
$parse = new Spreadsheet::ParseExcel::SaveParser();
Constructor.
Parse()
$workbook = $parse->Parse($sFileName);
$workbook = $parse->Parse($sFileName , $formatter);
Returns a "Workbook" object. If an error occurs, returns undef.
The optional $formatter is a Formatter Class to format the value of cells.
Workbook
The "Parse()" method returns a "Spreadsheet::ParseExcel::SaveParser::Workbook" object.
This is a subclass of the Spreadsheet::ParseExcel::Workbook and has the following methods:
worksheets()
Returns an array of "Worksheet" objects. This was most commonly used to iterate over the worksheets in a workbook:
for my $worksheet ( $workbook->worksheets() ) {
...
}
worksheet()
The "worksheet()" method returns a single "Worksheet" object using either its name or index:
$worksheet = $workbook->worksheet('Sheet1');
$worksheet = $workbook->worksheet(0);
Returns "undef" if the sheet name or index doesn't exist.
AddWorksheet()
$workbook = $workbook->AddWorksheet($name, %properties);
Create a new Worksheet object of type "Spreadsheet::ParseExcel::Worksheet".
The %properties hash contains the properties of new Worksheet.
AddFont
$workbook = $workbook->AddFont(%properties);
Create new Font object of type "Spreadsheet::ParseExcel::Font".
The %properties hash contains the properties of new Font.
AddFormat
$workbook = $workbook->AddFormat(%properties);
The %properties hash contains the properties of new Font.
Worksheet
Spreadsheet::ParseExcel::SaveParser::Worksheet
Worksheet is a subclass of Spreadsheet::ParseExcel::Worksheet. And has these methods :
The "Worksbook::worksheet()" method returns a "Spreadsheet::ParseExcel::SaveParser::Worksheet" object.
This is a subclass of the Spreadsheet::ParseExcel::Worksheet and has the following methods:
AddCell
$workbook = $worksheet->AddCell($row, $col, $value, $format [$encoding]);
Create new Cell object of type "Spreadsheet::ParseExcel::Cell".
The $format parameter is the format number rather than a full format object.
To specify just same as another cell, you can set it like below:
$row = 0;
$col = 0;
$worksheet = $template->worksheet(0);
$cell = $worksheet->get_cell( $row, $col );
$format_number = $cell->{FormatNo};
$worksheet->AddCell($row +1, $coll, 'New data', $format_number);
TODO
Please note that this module is currently (versions 0.50-0.60) undergoing a major restructuring and rewriting.
Known Problems
You can only rewrite the features that Spreadsheet::WriteExcel supports so macros, graphs and some other features in the original Excel
file will be lost. Also, formulas aren't rewritten, only the result of a formula is written.
Only last print area will remain. (Others will be removed)
AUTHOR
Maintainer 0.40+: John McNamara jmcnamara@cpan.org
Maintainer 0.27-0.33: Gabor Szabo szabgab@cpan.org
Original author: Kawai Takanori kwitknr@cpan.org
COPYRIGHT
Copyright (c) 2009-2010 John McNamara
Copyright (c) 2006-2008 Gabor Szabo
Copyright (c) 2000-2002 Kawai Takanori and Nippon-RAD Co. OP Division
All rights reserved.
You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.
perl v5.10.1 2010-09-17 Spreadsheet::ParseExcel::SaveParser(3pm)