View on
MetaCPAN
Klaus Eichner > Win32-Scsv > Win32::Scsv

Download:
Win32-Scsv-0.39.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.39   Source  

NAME ^

Win32::Scsv - Convert from and to *.xls, *.csv using Win32::OLE

SYNOPSIS ^

    use Win32::Scsv qw(
      xls_2_csv xls_all_csv csv_2_xls xls_2_vbs slurp_vbs import_vbs_book empty_xls
      get_xver get_book get_last_row get_last_col tmp_book open_excel
      get_lang XLRef XLConst ftranslate get_excel set_style_R1C1 restore_style
    );

    my $CN = XLConst();
    print 'xlNormal = ', $CN->{'xlNormal'}, "\n";

    my ($ver, $product) = get_xver;

    xls_2_csv('Test1.xls');
    xls_2_csv('Test1.xls' => 'dummy.csv');
    csv_2_xls('dummy.csv' => 'Test2.xls');
    xls_2_vbs('Test1.xls' => 'dummy.vbs');
    empty_xls('Test2.xls');

    print $_->{'NAME'}, ' => ', $_->{'CODE'}, "\n" for @{slurp_vbs('Test3.xls')};

    xls_2_csv('Abc.xls%Tab01' => 'data01.csv', { cpy => 'all' }); # copy values *AND* format...
    xls_2_csv('Abc.xls%Tab02' => 'data02.csv', { cpy => 'val' }); # copy only values...
    xls_2_csv('Abc.xls%Tab03' => 'data03.csv'); # ...same as { cpy => 'val' }, which is the default...

    xls_2_csv('Abc.xls%Tab04' => 'data04.csv', { rmc => 1 }); # remove CRLF from all cells...
    xls_2_csv('Abc.xls%Tab05' => 'data05.csv', { clc => 1 }); # force recalculation...

    xls_all_csv('Abc.xls' => 'result_*.csv', { cpy => 'all' }); # copy all sheets in one operation...

    csv_2_xls('dummy.csv' => 'New.xlsx%Tab9', {
      'tpl'  => 'Template.xls',
      'prot' => 1,
      'csz'  => [
         ['H:H' => 13.71],
         ['A:D' => 3],
      ],
      'fmt'  => [
         ['A:A' => '#,##0.000'],
         ['B:B' => '\\<@\\>'],
         ['C:C' => 'dd/mm/yyyy hh:mm:ss'],
      ],
    });

    my $ob = get_book('Test01.xls');
    my $os = $ob->Worksheets('Sheet5') or die "Can't find Sheet";

    my $last_col = get_last_col($os); # returns zero for an empty sheet...
    my $last_row = get_last_row($os); # returns zero for an empty sheet...

    print 'last col = ', $last_col, ', last row = ', $last_row, "\n";
    print 'XLRef = ', XLRef($last_col, $last_row), "\n";

    $ob->Close;

    open_excel('C:\Data\Test01.xls');

AUTHOR ^

Klaus Eichner <klaus03@gmail.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2009-2011 by Klaus Eichner

All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the artistic license 2.0, see http://www.opensource.org/licenses/artistic-license-2.0.php

syntax highlighting: