DBD::Excel(3pm) | User Contributed Perl Documentation | DBD::Excel(3pm) |
DBD::Excel - A class for DBI drivers that act on Excel File.
This is still alpha version.
use DBI; my $dbh = DBI->connect("DBI:Excel:file=test.xls") or die "Cannot connect: " . $DBI::errstr; my $sth = $dbh->prepare("CREATE TABLE a (id INTEGER, name CHAR(10))") or die "Cannot prepare: " . $dbh->errstr(); $sth->execute() or die "Cannot execute: " . $sth->errstr(); $sth->finish(); $dbh->disconnect();
This is still alpha version.
The DBD::Excel module is a DBI driver. The module is based on these modules:
reads Excel files.
writes Excel files.
a simple SQL engine.
Of course. :-)
This module assumes TABLE = Worksheet. The contents of the first row of each worksheet are used as column name.
Adding that, this module accepts a temporary table definition in the "connect" method with the "xl_vtbl" option.
Example:
my %options = ( xl_vtbl => { # define temporary tables here TESTV => { # temporary table name => options sheetName => 'TEST_V', # actual Excel sheet name ttlRow => 5, startCol => 1, colCnt => 4, datRow => 6, datLmt => 4, } } ); my $dbh = DBI->connect("DBI:Excel:file=dbdtest.xls", undef, undef, \%options);
For more information please refer to the file sample/tex.pl which is included in this distribution.
The following attributes are handled by DBI itself and not by DBD::Excel, thus they all work like expected:
Active ActiveKids CachedKids CompatMode (Not used) InactiveDestroy Kids PrintError RaiseError Warn (Not used)
The following DBI attributes are handled by DBD::Excel:
These attributes and methods are not supported:
bind_param_inout CursorName LongReadLen LongTruncOk
Additional to the DBI attributes, you can use the following attributes:
If you want to read the subdirectories of another directory, use
my($drh) = DBI->install_driver("Excel"); my(@list) = $drh->data_sources( { xl_dir => '/usr/local/xl_data' } );
my $dbh = DBI->connect("DBI:Excel:file=test.xls"); my @list = $dbh->func('list_tables');
Kawai Takanori (Hippo2000) originally created this module. Currently maintained by Alexander Becker.
DBI, Spreadsheet::WriteExcel, Spreadsheet::ParseExcel, SQL::Statement
Copyright (c) 2001 KAWAI,Takanori 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.
2024-02-18 | perl v5.38.2 |