perl : date from excel(.xlsx) not printed properly(format is changed)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl : date from excel(.xlsx) not printed properly(format is changed)
# 1  
Old 09-16-2012
perl : date from excel(.xlsx) not printed properly(format is changed)

I am trying to convert xlsx sheet to a csv file.
In .xlsx file there a cell with date
Code:
Mon 08/27/12

while reading this cell using Spreadsheet::XLSX, the output is display with numeric value i.e., 41148.


from Spreadsheet::XLSX module :

Code:
 use Text::Iconv;
 my $converter = Text::Iconv -> new ("utf-8", "windows-1251");
 
 # Text::Iconv is not really required.
 # This can be any object with the convert method. Or nothing.
 use Spreadsheet::XLSX;
 
 my $excel = Spreadsheet::XLSX -> new ('bandwidth-wan.xlsx', $converter);
 
 foreach my $sheet (@{$excel -> {Worksheet}}) {
 
        printf("Sheet: %s\n", $sheet->{Name});
        
        $sheet -> {MaxRow} ||= $sheet -> {MinRow};
        
         foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow}) {
         
                $sheet -> {MaxCol} ||= $sheet -> {MinCol};
                
                foreach my $col ($sheet -> {MinCol} ..  $sheet -> {MaxCol}) {
                
                        my $cell = $sheet -> {Cells} [$row] [$col];
 
                        if ($cell) {
                            printf("( %s , %s ) => %s\n", $row, $col, $cell -> {Val});
                        }
 
                } 
        }
 }

# 2  
Old 09-17-2012
Spreadsheet::XLSX is based on Spreadsheet::ParseExcel.

I think the conversion is not being carried out correctly because perl is failed to recognize the format of the date. Therefore its showing just the number ( which is actually used by the excel along with the format specifier ).

Try to change the date format for a while and check.
I would suggest the format MM/DD/YYYY. So in your case its 08/27/2012. Just don't add other other things like week name.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

2. 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

3. Shell Programming and Scripting

Perl : to get all the hyperlinks from the xlsx sheet(hyperlinks not visible in excel sheet directly)

Hi folks, I have a requirement in perl to print all the hyperlink from the spreadsheet(xlsx). Spreadsheet contains few lines of hyperlink data (pic attached). P.S. Hyperlink is behind the data and not visible in excel sheet directly. Now using perl script I need to copy the hyperlinks in... (3 Replies)
Discussion started by: scriptscript
3 Replies

4. Shell Programming and Scripting

Date format to be changed from DDMMYYYY to YYYYMMDD

My requirement is:- there will be files at a location each day with the date format DDMMYYYY. Novawise_Activity_Call_Notes_04022013.txt Novawise_Activity_Inbound_04022013.txt Novawise_Activity_Inbound_05022013.txt Novawise_Activity_Call_Notes_05022013.txt... (8 Replies)
Discussion started by: djrulz123
8 Replies

5. Shell Programming and Scripting

Perl :Is it possible to read the excel 2007 sheet on unix machine using spredsheet::xlsx module

I have an Excel 2007 excel sheet on windows machine and using Spreadsheet::XLSX I had written a script to read the excel sheet and was successful. My requirement is I need to generate another excel sheet from the old excel 2007 sheet on unix machine. Now is it possible to read the excel... (2 Replies)
Discussion started by: giridhar276
2 Replies

6. Shell Programming and Scripting

perl module to convert xlsx format to xls format

Hi Folks, I have written a perl script that reads data from excel sheet(.xls) using Spreadsheet::ParseExcel module. But the problem is this module doesn't work for excel sheets with extension .xlsx. I have gone through Spreadsheet::XLSX module with which we can read from .xlsx file directly.... (1 Reply)
Discussion started by: giridhar276
1 Replies

7. Shell Programming and Scripting

mailx not sending excel attachment properly

Hi, I am trying to send email with attachment using mailx command. I am using the folowing command: uuencode XX_HWSW_BUYERWISE_88963631_1.xls XX_HWSW_BUYERWISE_88963631_1.xls | mailx -s "Test Mail as Attachment" oracleams@xyz.com I get the email in the inbox. However, when I try to open the... (5 Replies)
Discussion started by: asp_julius
5 Replies

8. Shell Programming and Scripting

Different types of Date format in perl

I want to know the different types of date format possible in perl. Eg: yyyymmdd, yymmdd etc...Is there any format like YMD? Where can i find the list of all possibilites? Thanks in advance (1 Reply)
Discussion started by: irudayaraj
1 Replies

9. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

10. Shell Programming and Scripting

Date format in Perl

How do I display the date in the format "YYYY-Mmm-DD" using perl. e.g 2008-Jun-03 I have a perl command below which displays the date in the format "YYYY-MM-DD" but I want the month to be displayed as "Mmm" (The first 3 characters of the name of the month with the initial letter being upper... (2 Replies)
Discussion started by: stevefox
2 Replies
Login or Register to Ask a Question