| Spreadsheet-Engine documentation | Contained in the Spreadsheet-Engine distribution. |
Spreadsheet::Engine::Storage::SocialCalc - load SocialCalc files
use Spreadsheet::Engine::Storage::SocialCalc;
my Spreadsheet::Engine $sheet =
Spreadsheet::Engine:Storage::SocialCalc->load($file);
This instantiates a Spreadsheet::Engine from a saved file in the SocialCalc format.
my Spreadsheet::Engine $sheet =
Spreadsheet::Engine:Storage::SocialCalc->load($file);
Load a saved file.
This is a modified version of code from SocialCalc::DataFiles in SocialCalc 1.1.0
wikiCalc was developed by Dan Bricklin, at Software Garden, Inc.
SocialCalc 1.1.0 was developed by Dan Bricklin, Casey West, and Tony Bowden, at Socialtext, Inc.
Spreadsheet::Engine is developed and maintained by Tony Bowden <tony@tmtm.com>
Portions (c) Copyright 2005, 2006, 2007 Software Garden, Inc. All Rights Reserved.
Portions (c) Copyright 2007 Socialtext, Inc. All Rights Reserved.
Portions (c) Copyright 2007 Tony Bowden
The contents of this file are subject to the Artistic License 2.0; you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.perlfoundation.org/artistic_license_2_0
| Spreadsheet-Engine documentation | Contained in the Spreadsheet-Engine distribution. |
package Spreadsheet::Engine::Storage::SocialCalc; use strict; use warnings; use Carp; use IO::File; use Spreadsheet::Engine;
sub load { my ($class, $file) = @_; my $datafile = IO::File->new($file) or croak "Can't open $file: $!\n"; my ($line, $boundary); my ($headerlines, $sheetlines); while ($line = <$datafile>) { last if $line =~ m/^Content-Type:\smultipart\/mixed;/i; } $line =~ m/\sboundary=(\S+)/i; $boundary = $1 or croak "No boundary found in $file"; while ($line = <$datafile>) { $line =~ s/\r//g; last if $line =~ m/^--$boundary$/o; } while ($line = <$datafile>) { # go to blank line chomp $line; $line =~ s/\r//g; last unless $line; } my $bregex = qr/^--$boundary/; while ($line = <$datafile>) { # copy header lines last if $line =~ m/$bregex/; push @{$headerlines}, $line if $headerlines; } while ($line = <$datafile>) { # go to blank line chomp $line; $line =~ s/\r//g; last unless $line; } while ($line = <$datafile>) { # copy sheet lines last if $line =~ m/$bregex/; push @{$sheetlines}, $line; } return Spreadsheet::Engine->load_data($sheetlines); } 1;