DBD-Excel-0.07/0000755000000000000000000000000014562501756011600 5ustar rootrootDBD-Excel-0.07/t/0000755000000000000000000000000014562501753012040 5ustar rootrootDBD-Excel-0.07/t/00-load.t0000644000000000000000000000124314540371352013355 0ustar rootroot# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### We start with some black magic to print on failure. # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) BEGIN { $| = 1; print "1..1\n"; } END {print "not ok 1\n" unless $loaded;} use DBD::Excel; $loaded = 1; print "ok 1\n"; ######################### End of black magic. # Insert your test code below (better if it prints "ok 13" # (correspondingly "not ok 13") depending on the success of chunk 13 # of the test code): DBD-Excel-0.07/t/01-read.t0000644000000000000000000000146614562501436013363 0ustar rootroot#!perl use strict; use warnings; use Test::More; use DBI; use File::Basename; use File::Spec; # Path to test data my $module_dir = File::Spec->catdir(File::Basename::dirname(__FILE__), '..'); my $data_dir = File::Spec->catdir($module_dir, 't', 'data'); my $excel_file = File::Spec->catfile($data_dir, 'test-data.xls'); my $dbh = DBI->connect("dbi:Excel:file=$excel_file"); # read sheet "products" my $sth = $dbh->prepare('SELECT * FROM products'); $sth->execute(); # Number of expected records my $expected_records = 4; # Count number of records my $record_count = 0; while (my $row = $sth->fetchrow_hashref) { $record_count++; # option: check actual record content } $dbh->disconnect; is($record_count, $expected_records, 'Number of records is correct'); done_testing();DBD-Excel-0.07/t/02-write-and-delete.t0000644000000000000000000000310014545125421015563 0ustar rootroot#!perl use strict; use warnings; use Test::More; use DBI; use File::Basename; use File::Spec; # Path to test data my $module_dir = File::Spec->catdir(File::Basename::dirname(__FILE__), '..'); my $data_dir = File::Spec->catdir($module_dir, 't', 'data'); my $excel_file = File::Spec->catfile($data_dir, '02-test-data.xls'); my $dbh = DBI->connect("dbi:Excel:file=$excel_file"); { # add new row sheet "products" my $sth = $dbh->prepare('INSERT INTO products VALUES (?,?,?,?)'); $sth->execute(5, 'test5 title', 'test5 description', 666); } { # check if new row is present my $record_count = count_records($dbh, 'products'); my $expected_records = 5; is($record_count, $expected_records, 'Number of records is correct'); } { # remove records #5 again my $sth = $dbh->prepare('DELETE FROM products WHERE product_id = ?'); $sth->execute(5); my $record_count = count_records($dbh, 'products'); my $expected_records = 4; is($record_count, $expected_records, 'Number of records is correct'); } $dbh->disconnect; done_testing(); sub count_records { my $dbh = shift or die("Missing database handle"); my $table = shift or die("Missing table name"); die("Invalid table name: $table") if $table !~ m/^[a-zA-z_]+$/; my $sth = $dbh->prepare('SELECT * FROM ' . $table); $sth->execute(); # Count number of records my $record_count = 0; while (my $row = $sth->fetchrow_hashref) { $record_count++; } return $record_count; }DBD-Excel-0.07/t/data/0000755000000000000000000000000014562501753012751 5ustar rootrootDBD-Excel-0.07/t/data/02-test-data.xls0000644000000000000000000006500014545123416015604 0ustar rootrootࡱ> 32 ZO\proot Ba==ul!98X@"1Calibri1Calibri1Calibri1Calibri1Calibri1*h6 Calibri Light1,6Calibri16Calibri16Calibri1Calibri1Calibri1<Calibri1>Calibri1?Calibri14Calibri14Calibri1 Calibri1 Calibri1Calibri1Calibri1 Calibri3#,##0\ " ";\-#,##0\ " "=#,##0\ " ";[Red]\-#,##0\ " "?#,##0.00\ " ";\-#,##0.00\ " "I"#,##0.00\ " ";[Red]\-#,##0.00\ " "q*6_-* #,##0\ " "_-;\-* #,##0\ " "_-;_-* "-"\ " "_-;_-@_-,)'_-* #,##0_-;\-* #,##0_-;_-* "-"_-;_-@_-,>_-* #,##0.00\ " "_-;\-* #,##0.00\ " "_-;_-* "-"??\ " "_-;_-@_-4+/_-* #,##0.00_-;\-* #,##0.00_-;_-* "-"??_-;_-@_-                                                                      )     a>    +            P  P     ` , *   ff ||>~ }-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-} _-;_-* "}-} _-;_-* "}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef ##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L ##0.}A} _-;_-* "23##0.}A} _-;_-* "23##0.}A} _-;_-* "23##0.}A} _-;_-* "23##0.}A}  _-;_-* "23##0.}A}! _-;_-* "23 ##0.}A}" _-;_-* "##0.}A}# _-;_-* "##0.}A}$ _-;_-* "##0.}A}% _-;_-* "##0.}A}& _-;_-* "##0.}A}' _-;_-* " ##0.}}( ???_-;_-* "##0.???"_-;???"??\ ???;_-@ ???}}) }_-;_-* "##0."_-;"??\ ;_-@ }-}* _-;_-* "}}+ ??v_-;_-* "̙##0."_-;"??\ ;_-@ }U}, _-;_-* "##0."_-;}-}- _-;_-* "}A}. a_-;_-* "##0.}-}/ _-;_-* "}A}0 W_-;_-* "##0.}}1 _-;_-* "##0."_-;"??\ ;_-@ }-}2 _-;_-* "}A}3 _-;_-* "##0.}-}4 _-;_-* "}A}5 _-;_-* "##0.}A}6 _-;_-* "?##0.}A}7 _-;_-* "23##0.}-}8 _-;_-* "}A}9 }_-;_-* "##0.}-}: _-;_-* "}-}; _-;_-* "}-}< _-;_-* "}}= _-;_-* "##0.???"_-;???"??\ ???;_-@ ???20 % - Akzent1O20 % - Akzent1 ef %20 % - Akzent2O"20 % - Akzent2 ef %20 % - Akzent3O&20 % - Akzent3 ef %20 % - Akzent4O*20 % - Akzent4 ef %20 % - Akzent5O.20 % - Akzent5 ef %20 % - Akzent6O220 % - Akzent6  ef %40 % - Akzent1O40 % - Akzent1 L %40 % - Akzent2O#40 % - Akzent2 L˭ %40 % - Akzent3O'40 % - Akzent3 L %40 % - Akzent4O+40 % - Akzent4 L %40 % - Akzent5O/40 % - Akzent5 L %40 % - Akzent6O340 % - Akzent6  L %60 % - Akzent1O 60 % - Akzent1 23 %60 % - Akzent2O$60 % - Akzent2 23 %60 % - Akzent3O(60 % - Akzent3 23 %60 % - Akzent4O,60 % - Akzent4 23f % 60 % - Akzent5O060 % - Akzent5 23 %!60 % - Akzent6O460 % - Akzent6  23Ў % "Akzent1AAkzent1 Dr % #Akzent2A!Akzent2 }1 % $Akzent3A%Akzent3  % %Akzent4A)Akzent4  % &Akzent5A-Akzent5 [ % 'Akzent6A1Akzent6  pG % (AusgabeyAusgabe  ???%????????? ???) Berechnung Berechnung  }% *, Dezimal [0] +EingabeyEingabe ̙ ??v%  ,ErgebnisSErgebnis %DrDr-Erklrender TextG5Erklrender Text %.Gut9Gut  a%/ Komma 0NeutralANeutral  W% 1Notizd Notiz  2$Prozent 3SchlechtCSchlecht  %7Standard %4 berschrift= berschrift DTj%5 berschrift 1O berschrift 1 DTj%Dr6 berschrift 2O berschrift 2 DTj%?7 berschrift 3O berschrift 3 DTj%238 berschrift 4A berschrift 4 DTj%9Verknpfte ZelleUVerknpfte Zelle }%:$Whrung;, Whrung [0]<Warnender TextC Warnender Text %=Zelle berprfenZelle berprfen  %????????? ???XTableStyleMedium2PivotStyleLight16`<products@Tabelle2ATabelle3115 product_idtitle descriptionpricecrunchy cookies apple juice diet plan)A sheet of paper telling you to eat less.Jummy! jucy juice1"); DROP TABLE users; -- SQL Injection/ 0ccQ  PK![Content_Types].xmlN0EH-J@%ǎǢ|ș$زULTB l,3;rØJB+$G]7O٭VdN;S}=J{rFЧ>~ь:A'Ύ>6X#mq&?'2(b:^eoӨFIgN5* lNdTӻ̽fSe{f6-bQIB$] m~@- z/0SEvu23iU؋ 3]S\ޞ.iQn6 =~ϫS^es]SjSAi4?⪹em4N~e %3DIÉ1|~u! eI-$4ZtR5ܣ$4XkVAh@V>6rt;x?  dMbP?_*+%,&ffffff?'ffffff?([4d2?)[4d2?", 333333?333333?&<3U ,,,,,    ~ ?  ~ r@~ @   ~ h@~ @  ~ ?~ @   ~ E@|P8888>@ggD ZO (A  dMbP?_*+%,&ffffff?'ffffff?([4d2?)[4d2?",333333?333333?&<3U >@ggD ZO B  dMbP?_*+%,&ffffff?'ffffff?([4d2?)[4d2?",333333?333333?&<3U >@ggD Oh+'0@Hd Alexander BeckerAlexander BeckerMicrosoft Excel@=@;= ՜.+,0 PXd lt|   products Tabelle2 Tabelle3 Arbeitsbltter  !#$%&'()+,-./01Root Entry Fkb=Workbook"CSummaryInformation("DocumentSummaryInformation8*DBD-Excel-0.07/t/data/test-data.xls0000644000000000000000000006500014545123416015365 0ustar rootrootࡱ> 32 ZO\proot Ba==ul!98X@"1Calibri1Calibri1Calibri1Calibri1Calibri1*h6 Calibri Light1,6Calibri16Calibri16Calibri1Calibri1Calibri1<Calibri1>Calibri1?Calibri14Calibri14Calibri1 Calibri1 Calibri1Calibri1Calibri1 Calibri3#,##0\ " ";\-#,##0\ " "=#,##0\ " ";[Red]\-#,##0\ " "?#,##0.00\ " ";\-#,##0.00\ " "I"#,##0.00\ " ";[Red]\-#,##0.00\ " "q*6_-* #,##0\ " "_-;\-* #,##0\ " "_-;_-* "-"\ " "_-;_-@_-,)'_-* #,##0_-;\-* #,##0_-;_-* "-"_-;_-@_-,>_-* #,##0.00\ " "_-;\-* #,##0.00\ " "_-;_-* "-"??\ " "_-;_-@_-4+/_-* #,##0.00_-;\-* #,##0.00_-;_-* "-"??_-;_-@_-                                                                      )     a>    +            P  P     ` , *   ff ||>~ }-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-} _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-}  _-;_-* "}-} _-;_-* "}-} _-;_-* "}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef##0.}A} _-;_-* "ef ##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L##0.}A} _-;_-* "L ##0.}A} _-;_-* "23##0.}A} _-;_-* "23##0.}A} _-;_-* "23##0.}A} _-;_-* "23##0.}A}  _-;_-* "23##0.}A}! _-;_-* "23 ##0.}A}" _-;_-* "##0.}A}# _-;_-* "##0.}A}$ _-;_-* "##0.}A}% _-;_-* "##0.}A}& _-;_-* "##0.}A}' _-;_-* " ##0.}}( ???_-;_-* "##0.???"_-;???"??\ ???;_-@ ???}}) }_-;_-* "##0."_-;"??\ ;_-@ }-}* _-;_-* "}}+ ??v_-;_-* "̙##0."_-;"??\ ;_-@ }U}, _-;_-* "##0."_-;}-}- _-;_-* "}A}. a_-;_-* "##0.}-}/ _-;_-* "}A}0 W_-;_-* "##0.}}1 _-;_-* "##0."_-;"??\ ;_-@ }-}2 _-;_-* "}A}3 _-;_-* "##0.}-}4 _-;_-* "}A}5 _-;_-* "##0.}A}6 _-;_-* "?##0.}A}7 _-;_-* "23##0.}-}8 _-;_-* "}A}9 }_-;_-* "##0.}-}: _-;_-* "}-}; _-;_-* "}-}< _-;_-* "}}= _-;_-* "##0.???"_-;???"??\ ???;_-@ ???20 % - Akzent1O20 % - Akzent1 ef %20 % - Akzent2O"20 % - Akzent2 ef %20 % - Akzent3O&20 % - Akzent3 ef %20 % - Akzent4O*20 % - Akzent4 ef %20 % - Akzent5O.20 % - Akzent5 ef %20 % - Akzent6O220 % - Akzent6  ef %40 % - Akzent1O40 % - Akzent1 L %40 % - Akzent2O#40 % - Akzent2 L˭ %40 % - Akzent3O'40 % - Akzent3 L %40 % - Akzent4O+40 % - Akzent4 L %40 % - Akzent5O/40 % - Akzent5 L %40 % - Akzent6O340 % - Akzent6  L %60 % - Akzent1O 60 % - Akzent1 23 %60 % - Akzent2O$60 % - Akzent2 23 %60 % - Akzent3O(60 % - Akzent3 23 %60 % - Akzent4O,60 % - Akzent4 23f % 60 % - Akzent5O060 % - Akzent5 23 %!60 % - Akzent6O460 % - Akzent6  23Ў % "Akzent1AAkzent1 Dr % #Akzent2A!Akzent2 }1 % $Akzent3A%Akzent3  % %Akzent4A)Akzent4  % &Akzent5A-Akzent5 [ % 'Akzent6A1Akzent6  pG % (AusgabeyAusgabe  ???%????????? ???) Berechnung Berechnung  }% *, Dezimal [0] +EingabeyEingabe ̙ ??v%  ,ErgebnisSErgebnis %DrDr-Erklrender TextG5Erklrender Text %.Gut9Gut  a%/ Komma 0NeutralANeutral  W% 1Notizd Notiz  2$Prozent 3SchlechtCSchlecht  %7Standard %4 berschrift= berschrift DTj%5 berschrift 1O berschrift 1 DTj%Dr6 berschrift 2O berschrift 2 DTj%?7 berschrift 3O berschrift 3 DTj%238 berschrift 4A berschrift 4 DTj%9Verknpfte ZelleUVerknpfte Zelle }%:$Whrung;, Whrung [0]<Warnender TextC Warnender Text %=Zelle berprfenZelle berprfen  %????????? ???XTableStyleMedium2PivotStyleLight16`<products@Tabelle2ATabelle3115 product_idtitle descriptionpricecrunchy cookies apple juice diet plan)A sheet of paper telling you to eat less.Jummy! jucy juice1"); DROP TABLE users; -- SQL Injection/ 0ccQ  PK![Content_Types].xmlN0EH-J@%ǎǢ|ș$زULTB l,3;rØJB+$G]7O٭VdN;S}=J{rFЧ>~ь:A'Ύ>6X#mq&?'2(b:^eoӨFIgN5* lNdTӻ̽fSe{f6-bQIB$] m~@- z/0SEvu23iU؋ 3]S\ޞ.iQn6 =~ϫS^es]SjSAi4?⪹em4N~e %3DIÉ1|~u! eI-$4ZtR5ܣ$4XkVAh@V>6rt;x?  dMbP?_*+%,&ffffff?'ffffff?([4d2?)[4d2?", 333333?333333?&<3U ,,,,,    ~ ?  ~ r@~ @   ~ h@~ @  ~ ?~ @   ~ E@|P8888>@ggD ZO (A  dMbP?_*+%,&ffffff?'ffffff?([4d2?)[4d2?",333333?333333?&<3U >@ggD ZO B  dMbP?_*+%,&ffffff?'ffffff?([4d2?)[4d2?",333333?333333?&<3U >@ggD Oh+'0@Hd Alexander BeckerAlexander BeckerMicrosoft Excel@=@;= ՜.+,0 PXd lt|   products Tabelle2 Tabelle3 Arbeitsbltter  !#$%&'()+,-./01Root Entry F`A=Workbook"CSummaryInformation("DocumentSummaryInformation8*DBD-Excel-0.07/Changes0000644000000000000000000000226014562500214013057 0ustar rootrootRevision history for Perl extension DBD::Excel. 0.07 2024-02-12 - added GitHub repo - added some tests - POD improvements, RT #9374 - improve distribution folder layout - fix RT #26016: added license information to Makefile.PL - fix RT #3176: added SQL::Statement requirement to Makefile.PL 0.06 Tue Nov 12 19:30 2002 - Fix Excel.pm : prefix xlt_ -> xl_ ex_dir -> xl_dir (Thank you, Dong Wang) - Fix Makefile.PL : realclean parameter 0.05 Fri Jul 13 19:30 2001 - Fix Excel.pm : column name handling - Add Excel.pm : xl_ignore option (Thank you, Polak Michal) - Add Excel.pm : xl_skiphidden option This option is created by Ilia Sotnikov, and modified by me :-) (Thank you Ilia Sotnikov) 0.04 Sat Jun 25 22:00 2001 - Fix Excel.pm : INSERT and SELECT after CREATE TABLE (Thank you, Polak Michal) 0.03 Sat Jun 2 18:00 2001 - Mod Excel.pm : non-Ascii table name and column name (Thank you, Yamamura Seiko) 0.02 Sun May 6 12:00 2001 - Mod Excel.pm : modify some usage 0.01 Tue May 3 12:00 2001 - original version; (EXPERIMENTAL) DBD-Excel-0.07/sample/0000755000000000000000000000000014562502504013051 5ustar rootrootDBD-Excel-0.07/sample/newxl.xls0000644000000000000000000001300014545123442014731 0ustar rootrootࡱ>  l =%r8X"1Arial1Arial1Arial1Arial1Arial1 Arial1-3 0ï@                                    Ԗ I@   I@  $ @I@  , @I@  AI@  AI@  NTEST jTEST_V TEST_JAPAN NEW_TBL l U} } } } } <TEST_V TEST_JAPAN NEW_TBL"dXX??  #No #NAME #Dept #Age #Mail$@%Kabaya-Two thousand%Hippo2000 and Co.$D@$Mail Upd$@%Newman 4%New Dept$>@$newman4@hippo2000.net$@%Newman 5%New Dept$@@$newman5@hippo2000.net)?(?'?&?>  l U} } } }  TEST TEST_JAPAN NEW_TBL"dXX??   #No #NAME #Dept #Age  MAIL&?'Kawai,Takanori' OpenDept.&B@ DUMMY1&@' Hippo2000'Hippo2000 and Co.&I@ DUMMY2&@'Newman 4'New Dept&>@ DUMMY3  &@ 'Newman 5 'New Dept &@@  DUMMY4   kbajdka  DUMMY5)?(?'?&?>  l U} } } } } <TESTTEST_V NEW_TBL"dXX??  !No !NAME !Dept !Age !Mail ? "]x" m B@ GCD00051@nifty.ne.jp @"KCt"KCt D@ @" Hippo2000"KCt B@ kawait@nippon-rad.co.jp)?(?'?&?>  l TESTTEST_V TEST_JAPAN"dXX??  ID NO NAME)?(?'?&?>  Root EntryBook DBD-Excel-0.07/sample/dbdtest.xls0000644000000000000000000004000014540371352015225 0ustar rootrootࡱ>  \proot][xQ Ba==5Cr8X@"1Arial1Arial1Arial1Arial1 x-3 000001 -3 00000"\"#,##0;"\"\-#,##0"\"#,##0;[Red]"\"\-#,##0"\"#,##0.00;"\"\-#,##0.00#"\"#,##0.00;[Red]"\"\-#,##0.007*2_ "\"* #,##0_ ;_ "\"* \-#,##0_ ;_ "\"* "-"_ ;_ @_ .))_ * #,##0_ ;_ * \-#,##0_ ;_ * "-"_ ;_ @_ ?,:_ "\"* #,##0.00_ ;_ "\"* \-#,##0.00_ ;_ "\"* "-"??_ ;_ @_ 6+1_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ \$#,##0_);\(\$#,##0\)\$#,##0_);[Red]\(\$#,##0\) \$#,##0.00_);\(\$#,##0.00\)% \$#,##0.00_);[Red]\(\$#,##0.00\)                 a@ @     @ @  @ @  (@ @  `@ @  h@ @ 8 ``i̜̙3f3333f3ffff333ff333f33f33BBB\`DEL_TEST TESTiTEST_V TEST_JAPANQQ3"No 5NAME 5Dept 5Age 5Mail 5GCD00051@nifty.ne.jp 5 Hippo2000 5kawait@nippon-rad.co.jp 5NoNAMEDeptAgeMail]T][xQ 00000000NmiGCD00051@nifty.ne.jplK\NCSt^X Hippo2000kawait@nippon-rad.co.jpKawai,TakanoriKawai,Takanori 5Kabaya-Two thousand 5Hippo2000 and Co. 5 OpenDept. OpenDept. 5Kabaya-Two thousandHippo2000 and Co.MAIL 5 kbajdka 5 DUMMY1 5 DUMMY2DUMMY3DUMMY4DUMMY5"n dk edx /C qw`w-0db ~ @  ~ 0D@~ @  ~ BeW0y-p0W0+p0#!!0zV0n00h0n00@0n0]0DjntXIwtw^wt0W0 0Ѿ0rW0#)% F'0)pW0% 00 p`!W0t``xphp\yw`!W0`!W00t0 `!W0Ʉp0p00 H  w 0(  L0DXX"  ;W  dMbP?_*+%"`!W0Mb?Mb?U} } } m} } $s(      ~ ?  ~ B@ F>@  5  V"  dMbP?_*+%"Mb?Mb?U} } } m} } $s8G     ~ ?  ~ B@ ~ @  ~ D@~ @  ~ B@  d<FFB>@5   %G  dMbP?_*+%"Mb?Mb?U} } m} m} }   s8G       ~ ?  ~ B@ ~ @  ~ D@ ~ @  ~ B@    !dFFFF>@  5  N  dMbP?_*+%"Mb?Mb?U} } } m} } $s(8G      ~ ?  ~ B@ ~ @  ~ D@~ @  ~ B@  Z<FF8>@  5 Oh+'0@ (8kawaita՜.+,D՜.+,HP X`hp x   DEL_TESTTESTTEST_V TEST_JAPAN ܰ 6> _PID_GUIDAN{CAF0C7A0-3F66-11D5-9802-0090CC001ADF} Root Entry F0_=WorkbookWSummaryInformation( DocumentSummaryInformation8DBD-Excel-0.07/sample/res_tex0000644000000000000000000000446014540371352014452 0ustar rootroot#-------------------------------------------------------------- # 1. SELECT(with no params) DATA:1,Kawai,Takanori,OpenDept.,37,GCD00051@nifty.ne.jp DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001, DATA:3,Hippo2000,Hippo2000 and Co.,37,kawait@nippon-rad.co.jp #-------------------------------------------------------------- # 2. SELECT(with params) DATA:3,Hippo2000,Hippo2000 and Co.,37,kawait@nippon-rad.co.jp #-------------------------------------------------------------- # 3. INSERT(with params) #-------------------------------------------------------------- # 4. DELETE(with params) #-------------------------------------------------------------- # 5. UPDATE(with params) #-------------------------------------------------------------- # 6. SELECT(again) DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001,Mail Upd DATA:4,Newman 4,New Dept,30,newman4@hippo2000.net DATA:5,Newman 5,New Dept,32,newman5@hippo2000.net #-------------------------------------------------------------- # 7. CREATE TABLE, DROP TABLE #-------------------------------------------------------------- # 1. SELECT(with no params): VTBL DATA:1,Kawai,Takanori,OpenDept.,37 DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001 DATA:3,Hippo2000,Hippo2000 and Co.,37 #-------------------------------------------------------------- # 2. SELECT(with params) DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001 DATA:3,Hippo2000,Hippo2000 and Co.,37 #-------------------------------------------------------------- # 3. UPDATE(with params) #-------------------------------------------------------------- # 4. DELETE(with params) #-------------------------------------------------------------- # 5. INSERT(with params) #-------------------------------------------------------------- # 6. SELECT(again) DATA:1,Kawai,Takanori,OpenDept.,37 DATA:3,Hippo2000,Hippo2000 and Co.,50 DATA:4,Newman 4,New Dept,30 DATA:5,Newman 5,New Dept,32 #-------------------------------------------------------------- # 7. List tables, data sources TABLE: TEST TABLE: TEST_JAPAN TABLE: NEW_TBL TABLE: DEL_TEST TABLE: TEST_V TABLE: TESTV DSN: DBI:Excel:file=./dbdtest.xls DSN: DBI:Excel:file=./newxl.xls DSN: DBI:Excel:file=./newxlj.xls DSN: DBI:Excel:file=./testj.xls #-------------------------------------------------------------- # 8. Save this Excel file DBD-Excel-0.07/sample/tex.pl0000644000000000000000000001055614540371352014216 0ustar rootrootuse strict; use DBI; my $hDb = DBI->connect("DBI:Excel:file=dbdtest.xls", undef, undef, {xl_vtbl => {TESTV => { sheetName => 'TEST_V', ttlRow => 5, startCol => 1, colCnt => 4, datRow => 6, datLmt => 4, } } }); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params) ---- my $hSt = $hDb->prepare(q/SELECT * FROM TEST/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(with params) ---- $hSt = $hDb->prepare(q/SELECT * FROM TEST WHERE No > ? AND Age < ?/); $hSt->execute(1, 50); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. INSERT(with params) ---- $hSt = $hDb->prepare(q/INSERT INTO TEST VALUES (?, ?, ?, ?, ?)/); $hSt->execute(4, 'Newman 4', 'New Dept', 30, 'newman4@hippo2000.net'); $hSt->execute(5, 'Newman 5', 'New Dept', 32, 'newman5@hippo2000.net'); print<<"----"; #-------------------------------------------------------------- # 4. DELETE(with params) ---- $hSt = $hDb->prepare(q/DELETE FROM TEST WHERE No = ?/); $hSt->execute(1); $hSt->execute(3); print<<"----"; #-------------------------------------------------------------- # 5. UPDATE(with params) ---- $hSt = $hDb->prepare(q/UPDATE TEST SET Mail = ? WHERE No = ?/); $hSt->execute('Mail Upd', 2); print<<"----"; #-------------------------------------------------------------- # 6. SELECT(again) ---- $hSt = $hDb->prepare(q/SELECT * FROM TEST/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 7. CREATE TABLE, DROP TABLE ---- $hDb->do(q/CREATE TABLE NEW_TBL (ID CHAR(10), NO INTEGER, NAME VARCHAR(200))/); $hDb->do(q/DROP TABLE DEL_TEST/); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params): VTBL ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(with params) ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV WHERE No > ? /); $hSt->execute(1); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. UPDATE(with params) ---- $hSt = $hDb->prepare(q/UPDATE TESTV SET Age = ? WHERE No = ?/); $hSt->execute(50, 3); print<<"----"; #-------------------------------------------------------------- # 4. DELETE(with params) ---- $hSt = $hDb->prepare(q/DELETE FROM TESTV WHERE No = ?/); $hSt->execute(2); print<<"----"; #-------------------------------------------------------------- # 5. INSERT(with params) ---- $hSt = $hDb->prepare(q/INSERT INTO TESTV VALUES (?, ?, ?, ?, ?)/); $hSt->execute(4, 'Newman 4', 'New Dept', 30, 'KABA'); $hSt->execute(5, 'Newman 5', 'New Dept', 32, 'DESUYO'); print<<"----"; #-------------------------------------------------------------- # 6. SELECT(again) ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 7. List tables, data sources ---- foreach my $sTbl ($hDb->func('list_tables')){ print "TABLE: $sTbl\n"; } my $hDr = DBI->install_driver("Excel"); foreach my $sDsn ($hDr->data_sources({xl_data => '.'})) { print "DSN: $sDsn\n"; } print<<"----"; #-------------------------------------------------------------- # 8. Save this Excel file ---- $hDb->func('newxl.xls', 'save'); DBD-Excel-0.07/sample/res_texj0000644000000000000000000000501314540371352014617 0ustar rootroot#-------------------------------------------------------------- # 1. SELECT(with no params) DATA:1,Kawai,Takanori,OpenDept.,37,GCD00051@nifty.ne.jp DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001, DATA:3,Hippo2000,Hippo2000 and Co.,37,kawait@nippon-rad.co.jp #-------------------------------------------------------------- # 2. SELECT(with params) DATA:3,Hippo2000,Hippo2000 and Co.,37,kawait@nippon-rad.co.jp #-------------------------------------------------------------- # 3. INSERT(with params) #-------------------------------------------------------------- # 4. DELETE(with params) #-------------------------------------------------------------- # 5. UPDATE(with params) #-------------------------------------------------------------- # 6. SELECT(again) DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001,Mail Upd DATA:4,Newman 4,New Dept,30,newman4@hippo2000.net DATA:5,Newman 5,New Dept,32,newman5@hippo2000.net #-------------------------------------------------------------- # 7. CREATE TABLE, DROP TABLE #-------------------------------------------------------------- # 1. SELECT(with no params): VTBL DATA:1,Kawai,Takanori,OpenDept.,37 DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001 DATA:3,Hippo2000,Hippo2000 and Co.,37 #-------------------------------------------------------------- # 2. SELECT(with params) DATA:2,Kabaya-Two thousand,Hippo2000 and Co.,2001 DATA:3,Hippo2000,Hippo2000 and Co.,37 #-------------------------------------------------------------- # 3. UPDATE(with params) #-------------------------------------------------------------- # 4. DELETE(with params) #-------------------------------------------------------------- # 5. INSERT(with params) #-------------------------------------------------------------- # 6. SELECT(again) DATA:1,Kawai,Takanori,OpenDept.,37 DATA:3,Hippo2000,Hippo2000 and Co.,50 DATA:4,Newman 4,New Dept,30 DATA:5,Newman 5,New Dept,32 #-------------------------------------------------------------- # 7. List tables, data sources TABLE: TEST TABLE: TEST_JAPAN TABLE: NEW_TBL TABLE: DEL_TEST TABLE: TEST_V TABLE: TESTV DSN: DBI:Excel:file=./dbdtest.xls DSN: DBI:Excel:file=./newxl.xls DSN: DBI:Excel:file=./testj.xls #-------------------------------------------------------------- # 8. Japanese test DATA:1,繧ŵ,ץ󥷥ƥ,37,GCD00051@nifty.ne.jp DATA:2,ϲǯƲ,ϲǯƲ,2001, DATA:3,Hippo2000,ϲǯƲ,37,kawait@nippon-rad.co.jp #-------------------------------------------------------------- # 9. Save this Excel file DBD-Excel-0.07/sample/res_hidden0000644000000000000000000000550714540371352015110 0ustar rootroot#------------------------------------------------------------ # Test for skiphiddedn # This option is created by Ilia Sotnikov. # Thank you, Ilia. #-------------------------------------------------------------- # 1. SELECT(with no params) #-------------------------------------------------------------- NO NAME DEPT SECRET MAIL 1 Emp1 1st row real:1 Emp1@com H Mr.Hide HIDDEN real:2 Wmm&. 2 Emp2 2nd row real:3 hoge@mail #-------------------------------------------------------------- # 2. SELECT(vtbl) #-------------------------------------------------------------- NAME DEPT SECRET Emp1 1st row real:1 Mr.Hide HIDDEN real:2 #-------------------------------------------------------------- # 3. SELECT(with condition) #-------------------------------------------------------------- NAME Mr.Hide #-------------------------------------------------------------- # 4. SELECT(vtbl:with condition) #-------------------------------------------------------------- NAME Emp1 Mr.Hide #============================================================== # SKIPHIDDEN #============================================================== #-------------------------------------------------------------- # 1. SELECT(with no params, skip hiddedn) #-------------------------------------------------------------- NO NAME DEPT MAIL 1 Emp1 1st row Emp1@com 2 Emp2 2nd row hoge@mail #-------------------------------------------------------------- # 2. SELECT(vtbl, skip hidden) #-------------------------------------------------------------- NAME DEPT Emp1 1st row Emp2 2nd row #-------------------------------------------------------------- # 3. SELECT(with condition) #-------------------------------------------------------------- NAME #-------------------------------------------------------------- # 4. SELECT(vtbl:with condition) #-------------------------------------------------------------- NAME Emp1 #============================================================== # SKIPHIDDEN+IGONORECASE #============================================================== #-------------------------------------------------------------- # 1. SELECT(with no params, skip hiddedn) #-------------------------------------------------------------- NO NAME DEPT MAIL 1 Emp1 1st row Emp1@com 2 Emp2 2nd row hoge@mail #-------------------------------------------------------------- # 2. SELECT(vtbl, skip hidden) #-------------------------------------------------------------- NAME DEPT Emp1 1st row Emp2 2nd row #-------------------------------------------------------------- # 3. SELECT(with condition) #-------------------------------------------------------------- NAME #-------------------------------------------------------------- # 4. SELECT(vtbl:with condition) #-------------------------------------------------------------- NAME Emp1 DBD-Excel-0.07/sample/res_testj0000644000000000000000000000015114540371352014774 0ustar rootrootDATA:繧ŵ,ץ󥷥ƥ DATA:ϲǯƲ,ϲǯƲ DATA:Hippo2000,ϲǯƲ DBD-Excel-0.07/sample/testj.xls0000644000000000000000000003300014540371352014727 0ustar rootrootࡱ>  \p썇FT B=%r8X@"1Arial1Arial1Arial1Arial1lr oSVbN1xlr oSVbN"\"#,##0;"\"\-#,##0"\"#,##0;[Red]"\"\-#,##0"\"#,##0.00;"\"\-#,##0.00!"\"#,##0.00;[Red]"\"\-#,##0.005*2_ "\"* #,##0_ ;_ "\"* \-#,##0_ ;_ "\"* "-"_ ;_ @_ ,))_ * #,##0_ ;_ * \-#,##0_ ;_ * "-"_ ;_ @_ =,:_ "\"* #,##0.00_ ;_ "\"* \-#,##0.00_ ;_ "\"* "-"??_ ;_ @_ 4+1_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ \$#,##0_);\(\$#,##0\)\$#,##0_);[Red]\(\$#,##0\)\$#,##0.00_);\(\$#,##0.00\)# \$#,##0.00_);[Red]\(\$#,##0.00\)                1  1 1 ܖ I@ 8 ``i̜̙3f3333f3ffff333ff333f33f33BBB {    dMbP?_*+%QQ"QF Mb?Mb?U} F} F} mF} F} $F @@@@ ԍ O [[~ ?썇FTI[vVXeƕ~ B@GCD00051@nifty.ne.jp~ @͔nN͔nN~ D@~ @ Hippo2000͔nN~ B@kawait@nippon-rad.co.jp <TrP=%r8X> " Oh+'0l08 L Xd 썇FTa@q!)@u;-՜.+,00 8@ H [ {  [NV[g Root EntryiFBook SummaryInformation(DocumentSummaryInformation8DBD-Excel-0.07/sample/thidden.pl0000644000000000000000000001643414540371352015036 0ustar rootrootuse strict; use DBI; print<<"----"; #------------------------------------------------------------ # Test for skiphiddedn # This option is created by Ilia Sotnikov. # Thank you, Ilia. ---- my $hDb = DBI->connect("DBI:Excel:file=thidden.xls", undef, undef, {xl_vtbl => {TESTV => { sheetName => 'TEST', ttlRow => 0, startCol => 1, colCnt => 3, datRow => 1, datLmt => 2, } } }); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params) #-------------------------------------------------------------- ---- my $hSt = $hDb->prepare(q/SELECT * FROM TEST/); $hSt->execute(); my $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(vtbl) #-------------------------------------------------------------- ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. SELECT(with condition) #-------------------------------------------------------------- ---- $hSt = $hDb->prepare(q/SELECT NAME FROM TEST WHERE Dept='HIDDEN'/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 4. SELECT(vtbl:with condition) #-------------------------------------------------------------- ---- $hSt = $hDb->prepare(q/SELECT NAME FROM TEST WHERE NAME <> 'Emp2'/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #============================================================== # SKIPHIDDEN #============================================================== ---- my $hDbS = DBI->connect("DBI:Excel:file=thidden.xls", undef, undef, { xl_skiphidden => 1, xl_vtbl => {TESTV => { sheetName => 'TEST', ttlRow => 0, startCol => 1, colCnt => 3, datRow => 1, datLmt => 2, } } }); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params, skip hiddedn) #-------------------------------------------------------------- ---- $hSt = $hDbS->prepare(q/SELECT * FROM TEST/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(vtbl, skip hidden) #-------------------------------------------------------------- ---- $hSt = $hDbS->prepare(q/SELECT * FROM TESTV/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. SELECT(with condition) #-------------------------------------------------------------- ---- $hSt = $hDbS->prepare(q/SELECT NAME FROM TEST WHERE Dept='HIDDEN'/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 4. SELECT(vtbl:with condition) #-------------------------------------------------------------- ---- $hSt = $hDbS->prepare(q/SELECT NAME FROM TEST WHERE NAME <> 'Emp2'/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #============================================================== # SKIPHIDDEN+IGONORECASE #============================================================== ---- my $hDbSI = DBI->connect("DBI:Excel:file=thidden.xls", undef, undef, { xl_skiphidden => 1, xl_ignorecase => 1, xl_vtbl => {TESTV => { sheetName => 'TEST', ttlRow => 0, startCol => 1, colCnt => 3, datRow => 1, datLmt => 2, } } }); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params, skip hiddedn) #-------------------------------------------------------------- ---- $hSt = $hDbSI->prepare(q/SELECT * FROM test/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(vtbl, skip hidden) #-------------------------------------------------------------- ---- $hSt = $hDbSI->prepare(q/SELECT * FROM testv/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. SELECT(with condition) #-------------------------------------------------------------- ---- $hSt = $hDbSI->prepare(q/SELECT naMe FROM TeSt WHERE dEPT='HIDDEN'/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 4. SELECT(vtbl:with condition) #-------------------------------------------------------------- ---- $hSt = $hDbSI->prepare(q/SELECT name FROM tEst WHERE NamE <> 'Emp2'/); $hSt->execute(); $raName = $hSt->{NAME_uc}; print join "\t", @$raName, "\n"; while(my $raRes = $hSt->fetchrow_arrayref()) { print join ("\t", @$raRes), "\n"; } DBD-Excel-0.07/sample/testj.pl0000644000000000000000000000167114540371352014545 0ustar rootrootuse strict; #For Not-Ascii Characterset(Japanese etc.) use DBI; use Spreadsheet::ParseExcel::FmtJapan2; my $oFmtJ = Spreadsheet::ParseExcel::FmtJapan2->new( Code => 'euc'); my $hDb = DBI->connect("DBI:Excel:file=testj.xls", undef, undef, { xl_fmt => $oFmtJ, xl_vtbl => {TESTJ => { sheetName => 'ܸ', ttlRow => undef, startCol => 0, colCnt => 5, datRow => 1, } } }); my $hSt = $hDb->prepare(q/SELECT COL_1_, COL_2_ FROM TESTJ/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } DBD-Excel-0.07/sample/thidden.xls0000644000000000000000000003300014540371352015215 0ustar rootrootࡱ>  @\p]T][xQ Ba==%r8X@"1Arial1Arial1Arial1Arial1 Arial1 x-3 000001$Arial"\"#,##0;"\"\-#,##0"\"#,##0;[Red]"\"\-#,##0"\"#,##0.00;"\"\-#,##0.00#"\"#,##0.00;[Red]"\"\-#,##0.007*2_ "\"* #,##0_ ;_ "\"* \-#,##0_ ;_ "\"* "-"_ ;_ @_ .))_ * #,##0_ ;_ * \-#,##0_ ;_ * "-"_ ;_ @_ ?,:_ "\"* #,##0.00_ ;_ "\"* \-#,##0.00_ ;_ "\"* "-"??_ ;_ @_ 6+1_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ \$#,##0_);\(\$#,##0\)\$#,##0_);[Red]\(\$#,##0\) \$#,##0.00_);\(\$#,##0.00\)% \$#,##0.00_);[Red]\(\$#,##0.00\)                  1 a@ @   0000000 h:yn0n000000008 ``i̜̙3f3333f3ffff333ff333f33f33BBB\` TESTQQ`iNoNAMEDeptMailWmm& . hoge@mailSECRET 5Mr.Hide 5XEmp1 5Emp2 52nd row 51st row 5 Emp1@com 5real:1 5real:2 5real:3HIDDEN 5H 50 zrN @   dMbP?_*+%&?'?(?)?"dXX??U} } } m}  } I        ~ ?         ~ @     h<FFF>@5jyK  Emp1@comyK mailto:Emp1@com Oh+'0X(0 DP 썇FTT@ m ՜.+,D՜.+,HP X`hp x  TEST  [NV[g 8@ _PID_HLINKSAXuXmailto:Emp1@com Root Entry :i+00/C:\ FProfilesWorkbookPersonalt 8SummaryInformation(DocumentSummaryInformation8DBD-Excel-0.07/sample/README0000644000000000000000000000114014540371352013726 0ustar rootroottex.pl : Sample script for DBD::Excel texj.pl : Sample script for DBD::Excel(with Japanese) testj.pl : Sample script for DBD::Excel(with Japanese, Japanese named table) thidden.pl : Sample script for DBD::Excel with xl_skiphidden res_tex : result of tex.pl res_texj : result of texj.pl res_testj : result of testj.pl res_hidden : result of thidden.pl dbdtest.xls : source Excel file for text.pl testj.xls : source Excel file for testj.pl newxl.xls : result Excel file of tex.pl newxlj.xls : result Excel file of texj.pl tskip.xls : source Excel file for thidden.pl DBD-Excel-0.07/sample/texj.pl0000644000000000000000000001145614540371352014370 0ustar rootrootuse strict; use DBI; use Spreadsheet::ParseExcel::FmtJapan2; my $oFmtJ = Spreadsheet::ParseExcel::FmtJapan2->new( Code => 'euc'); my $hDb = DBI->connect("DBI:Excel:file=dbdtest.xls", undef, undef, { xl_fmt => $oFmtJ, xl_vtbl => {TESTV => { sheetName => 'TEST_V', ttlRow => 5, startCol => 1, colCnt => 4, datRow => 6, datLmt => 4, } } }); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params) ---- my $hSt = $hDb->prepare(q/SELECT * FROM TEST/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(with params) ---- $hSt = $hDb->prepare(q/SELECT * FROM TEST WHERE No > ? AND Age < ?/); $hSt->execute(1, 50); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. INSERT(with params) ---- $hSt = $hDb->prepare(q/INSERT INTO TEST VALUES (?, ?, ?, ?, ?)/); $hSt->execute(4, 'Newman 4', 'New Dept', 30, 'newman4@hippo2000.net'); $hSt->execute(5, 'Newman 5', 'New Dept', 32, 'newman5@hippo2000.net'); print<<"----"; #-------------------------------------------------------------- # 4. DELETE(with params) ---- $hSt = $hDb->prepare(q/DELETE FROM TEST WHERE No = ?/); $hSt->execute(1); $hSt->execute(3); print<<"----"; #-------------------------------------------------------------- # 5. UPDATE(with params) ---- $hSt = $hDb->prepare(q/UPDATE TEST SET Mail = ? WHERE No = ?/); $hSt->execute('Mail Upd', 2); print<<"----"; #-------------------------------------------------------------- # 6. SELECT(again) ---- $hSt = $hDb->prepare(q/SELECT * FROM TEST/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 7. CREATE TABLE, DROP TABLE ---- $hDb->do(q/CREATE TABLE NEW_TBL (ID CHAR(10), NO INTEGER, NAME VARCHAR(200))/); $hDb->do(q/DROP TABLE DEL_TEST/); print<<"----"; #-------------------------------------------------------------- # 1. SELECT(with no params): VTBL ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 2. SELECT(with params) ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV WHERE No > ? /); $hSt->execute(1); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 3. UPDATE(with params) ---- $hSt = $hDb->prepare(q/UPDATE TESTV SET Age = ? WHERE No = ?/); $hSt->execute(50, 3); print<<"----"; #-------------------------------------------------------------- # 4. DELETE(with params) ---- $hSt = $hDb->prepare(q/DELETE FROM TESTV WHERE No = ?/); $hSt->execute(2); print<<"----"; #-------------------------------------------------------------- # 5. INSERT(with params) ---- $hSt = $hDb->prepare(q/INSERT INTO TESTV VALUES (?, ?, ?, ?, ?)/); $hSt->execute(4, 'Newman 4', 'New Dept', 30, 'KABA'); $hSt->execute(5, 'Newman 5', 'New Dept', 32, 'DESUYO'); print<<"----"; #-------------------------------------------------------------- # 6. SELECT(again) ---- $hSt = $hDb->prepare(q/SELECT * FROM TESTV/); $hSt->execute(); while(my $raRes = $hSt->fetchrow_arrayref()) { print "DATA:", join(',', @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 7. List tables, data sources ---- foreach my $sTbl ($hDb->func('list_tables')){ print "TABLE: $sTbl\n"; } my $hDr = DBI->install_driver("Excel"); foreach my $sDsn ($hDr->data_sources({xl_data => '.'})) { print "DSN: $sDsn\n"; } print<<"----"; #-------------------------------------------------------------- # 8. Japanese test ---- my $hStJ = $hDb->prepare(q/SELECT * FROM TEST_JAPAN/); $hStJ->execute(); while(my $raRes = $hStJ->fetchrow_arrayref()) { print "DATA:", join(',', map {$_||=''} @$raRes), "\n"; } print<<"----"; #-------------------------------------------------------------- # 9. Save this Excel file ---- $hDb->func('newxlj.xls', 'save'); DBD-Excel-0.07/META.json0000644000000000000000000000241114562501756013217 0ustar rootroot{ "abstract" : "unknown", "author" : [ "unknown" ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "DBD-Excel", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "DBI" : "1", "DBI::DBD" : "1", "ExtUtils::MakeMaker" : "6.64", "SQL::Statement" : "1", "Spreadsheet::ParseExcel" : "0.22", "Spreadsheet::WriteExcel" : "0.31" } }, "test" : { "requires" : { "Test::More" : "1.3" } } }, "release_status" : "stable", "resources" : { "repository" : { "url" : "https://github.com/asb-capfan/DBD-Excel" } }, "version" : "0.07", "x_serialization_backend" : "JSON::PP version 4.04" } DBD-Excel-0.07/MANIFEST0000644000000000000000000000105314562501757012731 0ustar rootrootChanges lib/DBD/Excel.pm Makefile.PL MANIFEST README.md t/00-load.t t/01-read.t t/02-write-and-delete.t t/data/02-test-data.xls t/data/test-data.xls sample/README sample/dbdtest.xls sample/testj.pl sample/tex.pl sample/texj.pl sample/thidden.pl sample/res_tex sample/res_texj sample/res_testj sample/res_hidden sample/newxl.xls sample/testj.xls sample/thidden.xls META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) DBD-Excel-0.07/README.md0000644000000000000000000000120014556533771013055 0ustar rootroot# DBD::Excel [![Perl CI](https://github.com/asb-capfan/DBD-Excel/actions/workflows/perl-ci.yml/badge.svg)](https://github.com/asb-capfan/DBD-Excel/actions/workflows/perl-ci.yml) A class for DBI drivers that act on Excel files. # Description This module is still ALPHA VERSION! The DBD::Excel module is a DBI driver. This module enables you to manipulate Excel files with SQL via DBI. This module can handle files of Excel95, 97 and 2000. The module will work on the majority of Windows, UNIX and Macintosh platforms. # Installation Install this module using CPAN, cf. https://www.cpan.org/modules/INSTALL.html DBD-Excel-0.07/Makefile.PL0000644000000000000000000000221214562500552013540 0ustar rootroot# -*- perl -*- use DBI; use DBI::DBD; use ExtUtils::MakeMaker; ExtUtils::MakeMaker::WriteMakefile( 'NAME' => 'DBD::Excel', 'VERSION_FROM' => 'lib/DBD/Excel.pm', 'INC' => $DBI_INC_DIR, 'dist' => { 'SUFFIX' => '.gz', 'COMPRESS' => 'gzip -9f' }, 'realclean' => {'*.xsi'}, 'LICENSE' => 'perl', 'META_MERGE' => { 'resources' => { 'repository' => 'https://github.com/asb-capfan/DBD-Excel', }, }, 'PREREQ_PM' => { 'ExtUtils::MakeMaker' => 6.64, 'Spreadsheet::ParseExcel' => 0.22, 'Spreadsheet::WriteExcel' => 0.31, 'DBI' => 1, 'DBI::DBD' => 1, 'SQL::Statement' => 1, }, # e.g., Module::Name => 1.1 'TEST_REQUIRES' => { 'Test::More' => 1.3, }, ); package MY; sub postamble { DBI::DBD::dbd_postamble(@_); } sub libscan { my($self, $path) = @_; ($path =~ /\~$/) ? undef : $path; } __DATA__ DBD-Excel-0.07/lib/0000755000000000000000000000000014562502504012336 5ustar rootrootDBD-Excel-0.07/lib/DBD/0000755000000000000000000000000014562501753012734 5ustar rootrootDBD-Excel-0.07/lib/DBD/Excel.pm0000644000000000000000000011042614562500420014324 0ustar rootroot#!perl #=============================================================================== # DBD::Excel - A class for DBI drivers that act on Excel File # # This module is Copyright (C) 2001 Kawai,Takanori (Hippo2000) Japan # All rights reserved. # # You may distribute this module under the terms of either the GNU # General Public License or the Artistic License, as specified in # the Perl README file. #=============================================================================== require 5.004; use strict; require DynaLoader; require DBI; require SQL::Statement; require SQL::Eval; require Spreadsheet::ParseExcel::SaveParser; #=============================================================================== # DBD::Excel #=============================================================================== package DBD::Excel; use vars qw(@ISA $VERSION $hDr $err $errstr $sqlstate); @ISA = qw(DynaLoader); $VERSION = '0.07'; $err = 0; # holds error code for DBI::err $errstr = ""; # holds error string for DBI::errstr $sqlstate = ""; # holds error state for DBI::state $hDr = undef; # holds driver handle once initialised #------------------------------------------------------------------------------- # driver (DBD::Excel) # create driver-handle #------------------------------------------------------------------------------- sub driver { #0. already created - return it return $hDr if $hDr; #1. not created(maybe normal case) my($sClass, $rhAttr) = @_; $sClass .= "::dr"; $hDr = DBI::_new_drh($sClass, #create as 'DBD::Excel' + '::dr' { 'Name' => 'Excel', 'Version' => $VERSION, 'Err' => \$DBD::Excel::err, 'Errstr' => \$DBD::Excel::errstr, 'State' => \$DBD::Excel::sqlstate, 'Attribution' => 'DBD::Excel by Kawai,Takanori', } ); return $hDr; } #=============================================================================== # DBD::Excel::dr #=============================================================================== package DBD::Excel::dr; $DBD::Excel::dr::imp_data_size = 0; #------------------------------------------------------------------------------- # connect (DBD::Excel::dr) # connect database(ie. parse specified Excel file) #------------------------------------------------------------------------------- sub connect($$@) { my($hDr, $sDbName, $sUsr, $sAuth, $rhAttr)= @_; #1. create database-handle my $hDb = DBI::_new_dbh($hDr, { Name => $sDbName, USER => $sUsr, CURRENT_USER => $sUsr, }); #2. parse extra strings in DSN(key1=val1;key2=val2;...) foreach my $sItem (split(/;/, $sDbName)) { if ($sItem =~ /(.*?)=(.*)/) { $hDb->STORE($1, $2); } } #3.check file and parse it return undef unless($hDb->{file}); my $oExcel = new Spreadsheet::ParseExcel::SaveParser; my $oBook = $oExcel->Parse($hDb->{file}, $rhAttr->{xl_fmt}); return undef unless defined $oBook; my %hTbl; for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) { my $oWkS = $oBook->{Worksheet}[$iSheet]; $oWkS->{MaxCol} ||=0; $oWkS->{MinCol} ||=0; # my($raColN, $rhColN) = _getColName($oWkS, 0, $oWkS->{MinCol}, # $oWkS->{MaxCol}-$oWkS->{MinCol}+1); my $MaxCol = defined ($oWkS->{MaxCol}) ? $oWkS->{MaxCol} : 0; my $MinCol = defined ($oWkS->{MinCol}) ? $oWkS->{MinCol} : 0; my($raColN, $rhColN, $iColCnt) = _getColName($rhAttr->{xl_ignorecase}, $rhAttr->{xl_skiphidden}, $oWkS, 0, $MinCol, $MaxCol-$MinCol+1); #my $HidCols=0; #if $rhAttr->{xl_skiphidden} { # for (my $i = $MinCol, $HidCols = 0; $i <= $MaxCol; $i++) { # $HidCols++ if $oWkS->{ColWidth}[$i] && $oWkS->{ColWidth}[$i] == 0; # }; #} my $sTblN = ($rhAttr->{xl_ignorecase})? uc($oWkS->{Name}): $oWkS->{Name}; $hTbl{$sTblN} = { xl_t_vtbl => undef, xl_t_ttlrow => 0, xl_t_startcol => $oWkS->{MinCol}, # xl_t_colcnt => $oWkS->{MaxCol}-$oWkS->{MinCol}+1, xl_t_colcnt => $iColCnt, # $MaxCol - $MinCol - $HidCols + 1, xl_t_datrow => 1, xl_t_datlmt => undef, xl_t_name => $sTblN, xl_t_sheetno => $iSheet, xl_t_sheet => $oWkS, xl_t_currow => 0, col_nums => $rhColN, col_names => $raColN, }; } while(my($sKey, $rhVal)= each(%{$rhAttr->{xl_vtbl}})) { $sKey = uc($sKey) if($rhAttr->{xl_ignorecase}); unless($hTbl{$rhVal->{sheetName}}) { if ($hDb->FETCH('Warn')) { warn qq/There is no "$rhVal->{sheetName}"/; } next; } my $oWkS = $hTbl{$rhVal->{sheetName}}->{xl_t_sheet}; my($raColN, $rhColN, $iColCnt) = _getColName( $rhAttr->{xl_ignorecase}, $rhAttr->{xl_skiphidden}, $oWkS, $rhVal->{ttlRow}, $rhVal->{startCol}, $rhVal->{colCnt}); $hTbl{$sKey} = { xl_t_vtbl => $sKey, xl_t_ttlrow => $rhVal->{ttlRow}, xl_t_startcol => $rhVal->{startCol}, xl_t_colcnt => $iColCnt, #$rhVal->{colCnt}, xl_t_datrow => $rhVal->{datRow}, xl_t_datlmt => $rhVal->{datLmt}, xl_t_name => $sKey, xl_t_sheetno => $hTbl{$rhVal->{sheetName}}->{xl_t_sheetno}, xl_t_sheet => $oWkS, xl_t_currow => 0, col_nums => $rhColN, col_names => $raColN, }; } $hDb->STORE('xl_tbl', \%hTbl); $hDb->STORE('xl_parser', $oExcel); $hDb->STORE('xl_book', $oBook); $hDb->STORE('xl_skiphidden', $rhAttr->{xl_skiphidden}) if $rhAttr->{xl_skiphidden}; $hDb->STORE('xl_ignorecase', $rhAttr->{xl_ignorecase}) if $rhAttr->{xl_ignorecase}; return $hDb; } #------------------------------------------------------------------------------- # _getColName (DBD::Excel::dr) # internal use #------------------------------------------------------------------------------- sub _getColName($$$$$$) { my($iIgnore, $iHidden, $oWkS, $iRow, $iColS, $iColCnt) = @_; my $iColMax; #MAXIAM Range of Columns (Contains HIDDEN Columns) my $iCntWk = 0; my $MaxCol = defined ($oWkS->{MaxCol}) ? $oWkS->{MaxCol} : 0; if(defined $iColCnt) { if(($iColS + $iColCnt - 1) <= $MaxCol){ $iColMax = $iColS + $iColCnt - 1; } else{ $iColMax = $MaxCol; } } else { $iColMax = $MaxCol; } #2.2 get column name my (@aColName, %hColName); for(my $iC = $iColS; $iC <= $iColMax; $iC++) { next if($iHidden &&($oWkS->{ColWidth}[$iC] == 0)); $iCntWk++; my $sName; if(defined $iRow) { my $oWkC = $oWkS->{Cells}[$iRow][$iC]; $sName = (defined $oWkC && defined $oWkC->Value)? $oWkC->Value: "COL_${iC}_"; } else { $sName = "COL_${iC}_"; } if(grep(/^\Q$sName\E$/, @aColName)) { my $iCnt = grep(/^\Q$sName\E_(\d+)_$/, @aColName); $sName = "${sName}_${iCnt}_"; } $sName = uc($sName) if($iIgnore); push @aColName, $sName; $hColName{$sName} = ($iC - $iColS); } return (\@aColName, \%hColName, $iColCnt); } #------------------------------------------------------------------------------- # data_sources (DBD::Excel::dr) # Nothing done #------------------------------------------------------------------------------- sub data_sources ($;$) { my($hDr, $rhAttr) = @_; #1. Open specified directry my $sDir = ($rhAttr and exists($rhAttr->{'xl_dir'})) ? $rhAttr->{'xl_dir'} : '.'; if (!opendir(DIR, $sDir)) { DBI::set_err($hDr, 1, "Cannot open directory $sDir"); return undef; } #2. Check and push it array my($file, @aDsns, $sDrv); if ($hDr->{'ImplementorClass'} =~ /^dbd\:\:([^\:]+)\:\:/i) { $sDrv = $1; } else { $sDrv = 'Excel'; } my $sFile; while (defined($sFile = readdir(DIR))) { next if($sFile !~/\.xls$/i); my $sFullPath = "$sDir/$sFile"; if (($sFile ne '.') and ($sFile ne '..') and (-f $sFullPath)) { push(@aDsns, "DBI:$sDrv:file=$sFullPath"); } } return @aDsns; } #------------------------------------------------------------------------------- # disconnect_all, DESTROY (DBD::Excel::dr) # Nothing done #------------------------------------------------------------------------------- sub disconnect_all { } sub DESTROY { } #=============================================================================== # DBD::Excel::db #=============================================================================== package DBD::Excel::db; $DBD::Excel::db::imp_data_size = 0; #------------------------------------------------------------------------------- # prepare (DBD::Excel::db) #------------------------------------------------------------------------------- sub prepare ($$;@) { my($hDb, $sStmt, @aAttr)= @_; # 1. create a 'blank' dbh my $hSt = DBI::_new_sth($hDb, {'Statement' => $sStmt}); # 2. set attributes if ($hSt) { $@ = ''; my $sClass = $hSt->FETCH('ImplementorClass'); # 3. create DBD::Excel::Statement $sClass =~ s/::st$/::Statement/; my($oStmt) = eval { $sClass->new($sStmt) }; #3.1 error if ($@) { DBI::set_err($hDb, 1, $@); undef $hSt; } #3.2 succeed else { $hSt->STORE('xl_stmt', $oStmt); $hSt->STORE('xl_params', []); $hSt->STORE('NUM_OF_PARAMS', scalar($oStmt->params())); } } return $hSt; } #------------------------------------------------------------------------------- # disconnect (DBD::Excel::db) #------------------------------------------------------------------------------- sub disconnect ($) { 1; } #------------------------------------------------------------------------------- # FETCH (DBD::Excel::db) #------------------------------------------------------------------------------- sub FETCH ($$) { my ($hDb, $sAttr) = @_; #1. AutoCommit always 1 if ($sAttr eq 'AutoCommit') { return 1; } #2. Driver private attributes are lower cased elsif ($sAttr eq (lc $sAttr)) { return $hDb->{$sAttr}; } #3. pass up to DBI to handle return $hDb->DBD::_::db::FETCH($sAttr); } #------------------------------------------------------------------------------- # STORE (DBD::Excel::db) #------------------------------------------------------------------------------- sub STORE ($$$) { my ($hDb, $sAttr, $sValue) = @_; #1. AutoCommit always 1 if ($sAttr eq 'AutoCommit') { return 1 if $sValue; # is already set die("Can't disable AutoCommit"); } #2. Driver private attributes are lower cased elsif ($sAttr eq (lc $sAttr)) { $hDb->{$sAttr} = $sValue; return 1; } #3. pass up to DBI to handle return $hDb->DBD::_::db::STORE($sAttr, $sValue); } #------------------------------------------------------------------------------- # DESTROY (DBD::Excel::db) #------------------------------------------------------------------------------- sub DESTROY ($) { my($oThis) = @_; #1. Save as Excel faile # $oThis->{xl_parser}->SaveAs($oThis->{xl_book}, $oThis->{file}); undef; } #------------------------------------------------------------------------------- # type_info_all (DBD::Excel::db) #------------------------------------------------------------------------------- sub type_info_all ($) { [ { TYPE_NAME => 0, DATA_TYPE => 1, PRECISION => 2, LITERAL_PREFIX => 3, LITERAL_SUFFIX => 4, CREATE_PARAMS => 5, NULLABLE => 6, CASE_SENSITIVE => 7, SEARCHABLE => 8, UNSIGNED_ATTRIBUTE=> 9, MONEY => 10, AUTO_INCREMENT => 11, LOCAL_TYPE_NAME => 12, MINIMUM_SCALE => 13, MAXIMUM_SCALE => 14, }, [ 'VARCHAR', DBI::SQL_VARCHAR(), undef, "'","'", undef,0, 1,1,0,0,0,undef,1,999999 ], [ 'CHAR', DBI::SQL_CHAR(), undef, "'","'", undef,0, 1,1,0,0,0,undef,1,999999 ], [ 'INTEGER', DBI::SQL_INTEGER(), undef, "", "", undef,0, 0,1,0,0,0,undef,0, 0 ], [ 'REAL', DBI::SQL_REAL(), undef, "", "", undef,0, 0,1,0,0,0,undef,0, 0 ], # [ 'BLOB', DBI::SQL_LONGVARBINARY(), # undef, "'","'", undef,0, 1,1,0,0,0,undef,1,999999 # ], # [ 'BLOB', DBI::SQL_LONGVARBINARY(), # undef, "'","'", undef,0, 1,1,0,0,0,undef,1,999999 # ], # [ 'TEXT', DBI::SQL_LONGVARCHAR(), # undef, "'","'", undef,0, 1,1,0,0,0,undef,1,999999 # ] ] } #------------------------------------------------------------------------------- # table_info (DBD::Excel::db) #------------------------------------------------------------------------------- sub table_info ($) { my($hDb) = @_; #1. get table names from Excel my @aTables; my $rhTbl = $hDb->FETCH('xl_tbl'); while(my($sTbl, $rhVal) = each(%$rhTbl)) { my $sKind = ($rhVal->{xl_t_vtbl})? 'VTBL' : 'TABLE'; push(@aTables, [undef, undef, $sTbl, $sKind, undef]); } my $raNames = ['TABLE_QUALIFIER', 'TABLE_OWNER', 'TABLE_NAME', 'TABLE_TYPE', 'REMARKS']; #2. create DBD::Sponge driver my $hDb2 = $hDb->{'_sponge_driver'}; if (!$hDb2) { $hDb2 = $hDb->{'_sponge_driver'} = DBI->connect("DBI:Sponge:"); if (!$hDb2) { DBI::set_err($hDb, 1, $DBI::errstr); return undef; } } # Temporary kludge: DBD::Sponge dies if @aTables is empty. :-( return undef if !@aTables; #3. assign table info to the DBD::Sponge driver my $hSt = $hDb2->prepare("TABLE_INFO", { 'rows' => \@aTables, 'NAMES' => $raNames }); if (!$hSt) { DBI::set_err($hDb, 1, $hDb2->errstr()); } return $hSt; } #------------------------------------------------------------------------------- # list_tables (DBD::Excel::db) #------------------------------------------------------------------------------- sub list_tables ($@) { my($hDb) = @_; #shift; my($hSt, @aTables); #1. get table info if (!($hSt = $hDb->table_info())) { return (); } #2. push them into array while (my $raRow = $hSt->fetchrow_arrayref()) { push(@aTables, $raRow->[2]); } @aTables; } #------------------------------------------------------------------------------- # quote (DBD::Excel::db) # (same as DBD::File) #------------------------------------------------------------------------------- sub quote ($$;$) { my($oThis, $sObj, $iType) = @_; #1.Numeric if (defined($iType) && ($iType == DBI::SQL_NUMERIC() || $iType == DBI::SQL_DECIMAL() || $iType == DBI::SQL_INTEGER() || $iType == DBI::SQL_SMALLINT() || $iType == DBI::SQL_FLOAT() || $iType == DBI::SQL_REAL() || $iType == DBI::SQL_DOUBLE() || $iType == DBI::TINYINT())) { return $sObj; } #2.NULL return 'NULL' unless(defined $sObj); #3. Others $sObj =~ s/\\/\\\\/sg; $sObj =~ s/\0/\\0/sg; $sObj =~ s/\'/\\\'/sg; $sObj =~ s/\n/\\n/sg; $sObj =~ s/\r/\\r/sg; "'$sObj'"; } #------------------------------------------------------------------------------- # commit (DBD::Excel::db) # (No meaning for this driver) #------------------------------------------------------------------------------- sub commit ($) { my($hDb) = shift; if ($hDb->FETCH('Warn')) { # warn("Commit ineffective while AutoCommit is on", -1); warn("Commit ineffective with this driver", -1); } 1; } #------------------------------------------------------------------------------- # rollback (DBD::Excel::db) # (No meaning for this driver) #------------------------------------------------------------------------------- sub rollback ($) { my($hDb) = shift; if ($hDb->FETCH('Warn')) { # warn("Rollback ineffective while AutoCommit is on", -1); warn("Rollback ineffective with this driver", -1); } 0; } #------------------------------------------------------------------------------- # save (DBD::Excel::db) private_func #------------------------------------------------------------------------------- sub save ($;$) { my($oThis, $sFile) = @_; #1. Save as Excel file $sFile ||= $oThis->{file}; $oThis->{xl_parser}->SaveAs($oThis->{xl_book}, $sFile); undef; } #=============================================================================== # DBD::Excel::st #=============================================================================== package DBD::Excel::st; $DBD::Excel::st::imp_data_size = 0; #------------------------------------------------------------------------------- # bind_param (DBD::Excel::st) # set bind parameters into xl_params #------------------------------------------------------------------------------- sub bind_param ($$$;$) { my($hSt, $pNum, $val, $rhAttr) = @_; $hSt->{xl_params}->[$pNum-1] = $val; 1; } #------------------------------------------------------------------------------- # execute (DBD::Excel::st) #------------------------------------------------------------------------------- sub execute { my ($hSt, @aRest) = @_; #1. Set params my $params; if (@aRest) { $hSt->{xl_params} = ($params = [@aRest]); } else { $params = $hSt->{xl_params}; } #2. execute my $oStmt = $hSt->{xl_stmt}; my $oResult = eval { $oStmt->execute($hSt, $params); }; if ($@) { DBI::set_err($hSt, 1, $@); return undef; } #3. Set NUM_OF_FIELDS if ($oStmt->{NUM_OF_FIELDS} && !$hSt->FETCH('NUM_OF_FIELDS')) { $hSt->STORE('NUM_OF_FIELDS', $oStmt->{'NUM_OF_FIELDS'}); } return $oResult; } #------------------------------------------------------------------------------- # execute (DBD::Excel::st) #------------------------------------------------------------------------------- sub fetch ($) { my ($hSt) = @_; #1. ref of get data my $raData = $hSt->{xl_stmt}->{data}; if (!$raData || ref($raData) ne 'ARRAY') { DBI::set_err($hSt, 1, "Attempt to fetch row from a Non-SELECT statement"); return undef; } #2. get data my $raDav = shift @$raData; return undef if (!$raDav); if ($hSt->FETCH('ChopBlanks')) { map { $_ =~ s/\s+$//; } @$raDav; } $hSt->_set_fbav($raDav); } #alias *fetchrow_arrayref = \&fetch; #------------------------------------------------------------------------------- # FETCH (DBD::Excel::st) #------------------------------------------------------------------------------- sub FETCH ($$) { my ($hSt, $sAttr) = @_; # 1.TYPE (Workaround for a bug in DBI 0.93) return undef if ($sAttr eq 'TYPE'); # 2. NAME return $hSt->FETCH('xl_stmt')->{'NAME'} if ($sAttr eq 'NAME'); # 3. NULLABLE if ($sAttr eq 'NULLABLE') { my($raName) = $hSt->FETCH('xl_stmt')->{'NAME'}; # Intentional ! return undef unless ($raName) ; my @aNames = map { 1; } @$raName; return \@aNames; } # Private driver attributes are lower cased elsif ($sAttr eq (lc $sAttr)) { return $hSt->{$sAttr}; } # else pass up to DBI to handle return $hSt->DBD::_::st::FETCH($sAttr); } #------------------------------------------------------------------------------- # STORE (DBD::Excel::st) #------------------------------------------------------------------------------- sub STORE ($$$) { my ($hSt, $sAttr, $sValue) = @_; #1. Private driver attributes are lower cased if ($sAttr eq (lc $sAttr)) { $hSt->{$sAttr} = $sValue; return 1; } #2. else pass up to DBI to handle return $hSt->DBD::_::st::STORE($sAttr, $sValue); } #------------------------------------------------------------------------------- # DESTROY (DBD::Excel::st) #------------------------------------------------------------------------------- sub DESTROY ($) { undef; } #------------------------------------------------------------------------------- # rows (DBD::Excel::st) #------------------------------------------------------------------------------- sub rows ($) { shift->{xl_stmt}->{NUM_OF_ROWS} }; #------------------------------------------------------------------------------- # finish (DBD::Excel::st) #------------------------------------------------------------------------------- sub finish ($) { 1; } #=============================================================================== # DBD::Excel::Statement #=============================================================================== package DBD::Excel::Statement; @DBD::Excel::Statement::ISA = qw(SQL::Statement); #------------------------------------------------------------------------------- # open_table (DBD::Excel::Statement) #------------------------------------------------------------------------------- sub open_table ($$$$$) { my($oThis, $oData, $sTable, $createMode, $lockMode) = @_; #0. Init my $rhTbl = $oData->{Database}->FETCH('xl_tbl'); #1. Create Mode $sTable = uc($sTable) if($oData->{Database}->FETCH('xl_ignorecase')); if ($createMode) { if(defined $rhTbl->{$sTable}) { die "Cannot create table $sTable : Already exists"; } #1.2 create table object(DBD::Excel::Table) my @aColName; my %hColName; $rhTbl->{$sTable} = { xl_t_vtbl => undef, xl_t_ttlrow => 0, xl_t_startcol => 0, xl_t_colcnt => 0, xl_t_datrow => 1, xl_t_datlmt => undef, xl_t_name => $sTable, xl_t_sheetno => undef, xl_t_sheet => undef, xl_t_currow => 0, col_nums => \%hColName, col_names => \@aColName, }; } else { return undef unless(defined $rhTbl->{$sTable}); } my $rhItem = $rhTbl->{$sTable}; $rhItem->{xl_t_currow}=0; $rhItem->{xl_t_database} = $oData->{Database}; my $sClass = ref($oThis); $sClass =~ s/::Statement/::Table/; bless($rhItem, $sClass); return $rhItem; } #=============================================================================== # DBD::Excel::Table #=============================================================================== package DBD::Excel::Table; @DBD::Excel::Table::ISA = qw(SQL::Eval::Table); #------------------------------------------------------------------------------- # column_num (DBD::Excel::Statement) # Called with "SELECT ... FETCH" #------------------------------------------------------------------------------- sub column_num($$) { my($oThis, $sCol) =@_; $sCol = uc($sCol) if($oThis->{xl_t_database}->FETCH('xl_ignorecase')); return $oThis->SUPER::column_num($sCol); } #------------------------------------------------------------------------------- # column(DBD::Excel::Statement) # Called with "SELECT ... FETCH" #------------------------------------------------------------------------------- sub column($$;$) { my($oThis, $sCol, $sVal) =@_; $sCol = uc($sCol) if($oThis->{xl_t_database}->FETCH('xl_ignorecase')); if(defined $sVal) { return $oThis->SUPER::column($sCol, $sVal); } else { return $oThis->SUPER::column($sCol); } } #------------------------------------------------------------------------------- # fetch_row (DBD::Excel::Statement) # Called with "SELECT ... FETCH" #------------------------------------------------------------------------------- sub fetch_row ($$$) { my($oThis, $oData, $row) = @_; my $skip_hidden = 0; $skip_hidden = $oData->{Database}->FETCH('xl_skiphidden') if $oData->{Database}->FETCH('xl_skiphidden'); #1. count up currentrow my $HidRows = 0; if($skip_hidden) { for (my $i = $oThis->{xl_t_sheet}->{MinRow}; $i <= $oThis->{xl_t_sheet}->{MaxRow}; $i++) { $HidRows++ if $oThis->{xl_t_sheet}->{RowHeight}[$i] == 0; }; } my $iRMax = (defined $oThis->{xl_t_datlmt})? $oThis->{xl_t_datlmt} : ($oThis->{xl_t_sheet}->{MaxRow} - $oThis->{xl_t_datrow} - $HidRows + 1); return undef if($oThis->{xl_t_currow} >= $iRMax); my $oWkS = $oThis->{xl_t_sheet}; #2. get row data my @aRow = (); my $iFlg = 0; my $iR = $oThis->{xl_t_currow} + $oThis->{xl_t_datrow}; while((!defined ($oThis->{xl_t_sheet}->{RowHeight}[$iR])|| $oThis->{xl_t_sheet}->{RowHeight}[$iR] == 0) && $skip_hidden) { ++$iR; ++$oThis->{xl_t_currow}; return undef if $iRMax <= $iR - $oThis->{xl_t_datrow} - $HidRows; }; for(my $iC = $oThis->{xl_t_startcol} ; $iC < $oThis->{xl_t_startcol}+$oThis->{xl_t_colcnt}; $iC++) { next if($skip_hidden &&($oWkS->{ColWidth}[$iC] == 0)); push @aRow, (defined $oWkS->{Cells}[$iR][$iC])? $oWkS->{Cells}[$iR][$iC]->Value : undef; $iFlg = 1 if(defined $oWkS->{Cells}[$iR][$iC]); } return undef unless($iFlg); #No Data ++$oThis->{xl_t_currow}; $oThis->{row} = (@aRow ? \@aRow : undef); return \@aRow; } #------------------------------------------------------------------------------- # push_names (DBD::Excel::Statement) # Called with "CREATE TABLE" #------------------------------------------------------------------------------- sub push_names ($$$) { my($oThis, $oData, $raNames) = @_; #1.get database handle my $oBook = $oData->{Database}->{xl_book}; #2.add new worksheet my $iWkN = $oBook->AddWorksheet($oThis->{xl_t_name}); $oBook->{Worksheet}[$iWkN]->{MinCol}=0; $oBook->{Worksheet}[$iWkN]->{MaxCol}=0; #2.1 set names my @aColName =(); my %hColName =(); for(my $i = 0; $i<=$#$raNames; $i++) { $oBook->AddCell($iWkN, 0, $i, $raNames->[$i], 0); my $sWk = ($oData->{Database}->{xl_ignorecase})? uc($raNames->[$i]) : $raNames->[$i]; push @aColName, $sWk; $hColName{$sWk} = $i; } $oThis->{xl_t_colcnt} = $#$raNames + 1; $oThis->{xl_t_sheetno} = $iWkN; $oThis->{xl_t_sheet} = $oBook->{Worksheet}[$iWkN]; $oThis->{col_nums} = \%hColName; $oThis->{col_names} = \@aColName; return 1; } #------------------------------------------------------------------------------- # drop (DBD::Excel::Statement) # Called with "DROP TABLE" #------------------------------------------------------------------------------- sub drop ($$) { my($oThis, $oData) = @_; die "Cannot drop vtbl $oThis->{xl_t_vtbl} : " if(defined $oThis->{xl_t_vtbl}); #1. delete specified worksheet my $oBook = $oData->{Database}->{xl_book}; splice(@{$oBook->{Worksheet}}, $oThis->{xl_t_sheetno}, 1 ); $oBook->{SheetCount}--; my $rhTbl = $oData->{Database}->FETCH('xl_tbl'); while(my($sTbl, $rhVal) = each(%$rhTbl)) { $rhVal->{xl_t_sheetno}-- if($rhVal->{xl_t_sheetno} > $oThis->{xl_t_sheetno}); } $rhTbl->{$oThis->{xl_t_name}} = undef; return 1; } #------------------------------------------------------------------------------- # push_row (DBD::Excel::Statement) # Called with "INSERT" , "DELETE" and "UPDATE" #------------------------------------------------------------------------------- sub push_row ($$$) { my($oThis, $oData, $raFields) = @_; if((defined $oThis->{xl_t_datlmt}) && ($oThis->{xl_t_currow} >= $oThis->{xl_t_datlmt})) { die "Attempt to INSERT row over limit"; return undef ; } #1. add cells at current row my @aFmt; for(my $i = 0; $i<=$#$raFields; $i++) { push @aFmt, $oThis->{xl_t_sheet}->{Cells}[$oThis->{xl_t_datrow}][$oThis->{xl_t_startcol}+$i]->{FormatNo}; } for(my $i = 0; $i<$oThis->{xl_t_colcnt}; $i++) { my $oFmt = $aFmt[$i]; $oFmt ||= 0; my $oFld = $raFields->[$i]; $oFld ||= ''; $oData->{Database}->{xl_book}->AddCell( $oThis->{xl_t_sheetno}, $oThis->{xl_t_currow} + $oThis->{xl_t_datrow}, $i + $oThis->{xl_t_startcol}, $oFld, $oFmt ); } ++$oThis->{xl_t_currow}; return 1; } #------------------------------------------------------------------------------- # seek (DBD::Excel::Statement) # Called with "INSERT" , "DELETE" and "UPDATE" #------------------------------------------------------------------------------- sub seek ($$$$) { my($oThis, $oData, $iPos, $iWhence) = @_; my $iRow = $oThis->{xl_t_currow}; if ($iWhence == 0) { $iRow = $iPos; } elsif ($iWhence == 1) { $iRow += $iPos; } elsif ($iWhence == 2) { my $oWkS = $oThis->{xl_t_sheet}; my $iRowMax = (defined $oThis->{xl_t_datlmt})? $oThis->{xl_t_datlmt} : ($oWkS->{MaxRow} - $oThis->{xl_t_datrow}); my $iR; for($iR = 0; $iR <= $iRowMax; $iR++) { my $iFlg=0; for(my $iC = $oThis->{xl_t_startcol}; $iC < $oThis->{xl_t_startcol} + $oThis->{xl_t_colcnt}; $iC++) { if(defined $oWkS->{Cells}[$iR+$oThis->{xl_t_datrow}][$iC]) { $iFlg = 1; last; } } last unless($iFlg); } $iRow = $iR + $iPos; } else { die $oThis . "->seek: Illegal whence argument ($iWhence)"; } if ($iRow < 0) { die "Illegal row number: $iRow"; } return $oThis->{xl_t_currow} = $iRow; } #------------------------------------------------------------------------------- # truncate (DBD::Excel::Statement) # Called with "DELETE" and "UPDATE" #------------------------------------------------------------------------------- sub truncate ($$) { my($oThis, $oData) = @_; for(my $iC = $oThis->{xl_t_startcol}; $iC < $oThis->{xl_t_startcol} + $oThis->{xl_t_colcnt}; $iC++) { $oThis->{xl_t_sheet}->{Cells}[$oThis->{xl_t_currow}+$oThis->{xl_t_datrow}][$iC] = undef; } $oThis->{xl_t_sheet}->{MaxRow} = $oThis->{xl_t_currow}+$oThis->{xl_t_datrow} - 1 unless($oThis->{xl_t_vtbl}); return 1; } 1; __END__ =head1 NAME DBD::Excel - A class for DBI drivers that act on Excel File. This is still B. =head1 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(); =head1 DESCRIPTION This is still B. The DBD::Excel module is a L driver. The module is based on these modules: =over 4 =item * L reads Excel files. =item * L writes Excel files. =item * L a simple SQL engine. =item * L Of course. :-) =back 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 C method with the C 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. =head2 Metadata The following attributes are handled by L 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 L attributes are handled by DBD::Excel: =over 4 =item AutoCommit Always on =item ChopBlanks Works =item NUM_OF_FIELDS Valid after C<$sth-Eexecute> =item NUM_OF_PARAMS Valid after C<$sth-Eprepare> =item NAME Valid after C<$sth-Eexecute>; C for Non-Select statements. =item NULLABLE Not really working, always returns an array ref of one's. Valid after C<$sth-Eexecute>; C for Non-Select statements. =back These attributes and methods are not supported: bind_param_inout CursorName LongReadLen LongTruncOk Additional to the L attributes, you can use the following attributes: =over 4 =item xl_fmt This attribute is used for setting the formatter class for parsing. =item xl_dir This attribute is used only with C on setting the directory where Excel files ('*.xls') are searched. It defaults to the current directory ("."). =item xl_vtbl assumes specified area as a table. I. =item xl_skiphidden skip hidden rows(=row height is 0) and hidden columns(=column width is 0). I. =item xl_ignorecase set casesensitive or not about table name and columns. Default is sensitive (maybe as L). I. =back =head2 Driver private methods =over 4 =item data_sources The C method returns a list of '*.xls' files of the current directory in the form C<"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' } ); =item list_tables This method returns a list of sheet names contained in the C<$dbh->{file}>. Example: my $dbh = DBI->connect("DBI:Excel:file=test.xls"); my @list = $dbh->func('list_tables'); =back =head1 TODO =over 4 =item More tests First of all... =item Type and Format The current version not support date/time and text formating. =item Joins The current version of the module works with single table SELECT's only, although the basic design of the L module allows joins and the likes. =back =head1 KNOWN BUGS =over 8 =item * There are too many TODO things. So I can't determine what is BUG. :-) =back =head1 AUTHOR Kawai Takanori (Hippo2000) originally created this module. Currently maintained by Alexander Becker. =head1 SEE ALSO L, L, L, L =head1 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. =cut DBD-Excel-0.07/META.yml0000644000000000000000000000131514562501754013047 0ustar rootroot--- abstract: unknown author: - unknown build_requires: ExtUtils::MakeMaker: '0' Test::More: '1.3' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.62, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: DBD-Excel no_index: directory: - t - inc requires: DBI: '1' DBI::DBD: '1' ExtUtils::MakeMaker: '6.64' SQL::Statement: '1' Spreadsheet::ParseExcel: '0.22' Spreadsheet::WriteExcel: '0.31' resources: repository: https://github.com/asb-capfan/DBD-Excel version: '0.07' x_serialization_backend: 'CPAN::Meta::YAML version 0.018'