DBD::Excel(3pm)
π DBD::Excel π
okay bestie, so this is DBD::Excel β a class for DBI drivers that act on Excel File β¨ and yes it is still alpha version, she's a work in progress and we love her anyway π
(also this whole page lives in the User Contributed Perl Documentation section, iykyk π )
β¨ SYNOPSIS β¨
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();
like look at her go, connecting, preparing, executing, finishing, disconnecting β full main character arc fr fr π
πΈ DESCRIPTION πΈ
okay so first things first: this is still alpha version. not me warning you twice, it's just that important π«Ά
The DBD::Excel module is a DBI driver. The module is based on these modules:
Spreadsheet::ParseExcelβ reads Excel files πSpreadsheet::WriteExcelβ writes Excel files βοΈSQL::Statementβ a simple SQL engine π§DBIβ Of course. :-) π
This module assumes TABLE = Worksheet. The contents of the first row of each worksheet are used as column name. yes, first row = your column names, that's the vibe β¨
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. go read it bestie, it's right there π
π¦ Metadata π¦
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:
AutoCommitβ Always on β‘ChopBlanksβ Works βNUM_OF_FIELDSβ Valid after"$sth->execute"NUM_OF_PARAMSβ Valid after"$sth->prepare"NAMEβ Valid after"$sth->execute";"undef"for Non-Select statements.NULLABLEβ Not really working, always returns an array ref of one's. Valid after"$sth->execute";"undef"for Non-Select statements. π she's doing her best
These attributes and methods are not supported:
bind_param_inout
CursorName
LongReadLen
LongTruncOk
Additional to the DBI attributes, you can use the following attributes:
xl_fmtβ This attribute is used for setting the formatter class for parsing.xl_dirβ This attribute is used only with"data_sources"on setting the directory where Excel files ('*.xls') are searched. It defaults to the current directory (".").xl_vtblβ assumes specified area as a table. Seesample/tex.pl.xl_skiphiddenβ skip hidden rows(=row height is 0) and hidden columns(=column width is 0). Seesample/thidden.pl.xl_ignorecaseβ set casesensitive or not about table name and columns. Default is sensitive (maybe asSQL::Statement). Seesample/thidden.pl.
π Driver private methods π
data_sourcesβ The"data_sources"method returns a list of'*.xls'files of the current directory in the form"DBI:Excel:xl_dir=$dirname".
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' } );
list_tablesβ This method returns a list of sheet names contained in the"$dbh-"{file}>. Example:
my $dbh = DBI->connect("DBI:Excel:file=test.xls");
my @list = $dbh->func('list_tables');
β TODO β
- More tests β First of all... π
- Type and Format β The current version not support date/time and text formatting. π«π
- Joins β The current version of the module works with single table SELECT's only, although the basic design of the
SQL::Statementmodule allows joins and the likes.
π KNOWN BUGS π
- There are too many TODO things. So I can't determine what is BUG. :-) π iconic honestly
π AUTHOR π
Kawai Takanori (Hippo2000) originally created this module. Currently maintained by Alexander Becker. π«Ά
π₯ SEE ALSO π₯
DBI, Spreadsheet::WriteExcel, Spreadsheet::ParseExcel, SQL::Statement
π COPYRIGHT π
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.
and that's the whole page bestie π this was DBD::Excel(3pm) from perl v5.38.2, dated 2024-02-18. slay, go parse some spreadsheets, ily π¦β¨
π¦ where this page comes from
- debian trixie: libdbd-excel-perl 0.07-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libdbd-excel-perl 0.07-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdbd-excel-perl 0.07-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdbd-excel-perl 0.07-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms