DBD-Excel-0.06/0040755000076400007640000000000007564267703012444 5ustar kawaitkawaitDBD-Excel-0.06/README0100644000076400007640000000200707564161052013306 0ustar kawaitkawaitNAME DBD::Excel - A class for DBI drivers that act on Excel File. 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. REQUIREMENT This module requires these modules: Spreadsheet::ParseExcel Spreadsheet::WriteExcel DBI SQL::Statement INSTALLATION The module can be installed using the standard Perl procedure: perl Makefile.PL make make test make install # You may need to be root make clean # or make realclean Windows users without a working "make" can get nmake from: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe VERSION This document refers to version 0.06 of DBD::Excel, released Nov 12, 2002. AUTHOR KAWAI,Takanori (kwitknr@cpan.org) DBD-Excel-0.06/sample/0040755000076400007640000000000007564267703013725 5ustar kawaitkawaitDBD-Excel-0.06/sample/res_testj0100644000076400007640000000014607564160257015644 0ustar kawaitkawaitDATA:РюЙчЙЇХЕ,ЅЊЁМЅзЅѓЅЗЅЙЅЦЅрЛіЖШЩє DATA:ВЯЧЯВАЦѓРщЧЏЦВ,ВЯЧЯВАЦѓРщЧЏЦВ DATA:Hippo2000,ВЯЧЯВАЦѓРщЧЏЦВ DBD-Excel-0.06/sample/res_tex0100644000076400007640000000437007564160257015316 0ustar kawaitkawait#-------------------------------------------------------------- # 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.06/sample/thidden.xls0100644000076400007640000003300007564160260016053 0ustar kawaitkawaitаЯрЁБс>ўџ ўџџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ ўЭЩ@сАСт\pн]T][xQ BАaР=œЏМ=М%r8X@"Зк1ШџArial1ШџArial1ШџArial1ШџArial1Ш Arial1 xџ€-џ3џ 0џД0З0У0Џ01Ш$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@ @ – р Р “Я0Є0б0ќ0ъ0ѓ0Џ0“€џ“ hˆ:yn0n0Я0Є0б0ќ0ъ0ѓ0Џ0’т8џџџџџџџџџџџџ€€€€€€€€€РРР€€€€€џ€ `џџР рр`€џ€€€РРРџ€џџџџџџ€€€€€џЬџiџџЬџЬџџ™ІЪ№ЬœЬЬ™џууу3fџ3ЬЬ3™3™™3™f3™ffff™–––33Ь3ff333f3™3f33™BBB\џџџ`… ЩTESTŒQQСС`iќNoNAMEDeptMailWmm& . hoge@mailSECRET 5Mr.Hide 5XEmp1 5Emp2 52nd row 51st row 5Œ Emp1@com 5real:1 5real:2 5real:3HIDDEN 5H 5џ0 žzrN ўЭЩ@ Е …  dќЉёвMbP?_*+‚€%џСƒ„&ш?'ш?(№?)№?Ё"dXXр?р?U} } л} m} Ж } I  џ џ§ § § § § ~ №?§ §  §  §  § § § § § ~ @§  §  § § з h<FFF>Ж@я5ИjаЩъyљКЮŒ‚ЊKЉ  Emp1@comрЩъyљКЮŒ‚ЊKЉ mailto:Emp1@com ўџр…ŸђљOhЋ‘+'Гй0X(0 DPЄ ь‡F“TT@ Ќm СўџеЭеœ.“—+,љЎDеЭеœ.“—+,љЎєАHP X`hp x ‰Єэ TEST  ƒ[ƒNƒV[ƒg  8@ _PID_HLINKSЄAXuXmailto:Emp1@comўџџџ ўџџџўџџџ§џџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџRoot Entry ИИъ:iЂи+00/C:\џџџџџџџџ РFProfilesўџџџWorkbookPersonalt ИИ8џџџџџџџџџџџџџџџџSummaryInformation(џџџџDocumentSummaryInformation8џџџџџџџџџџџџDBD-Excel-0.06/sample/dbdtest.xls0100644000076400007640000004000007564160257016071 0ustar kawaitkawaitаЯрЁБс>ўџ ўџџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ шЬЩсАСт\pн]T][xQ BАa=œЏМ=5Cr8X@"Зк1ШџArial1ШџArial1ШџArial1ШџArial1 xџ€-џ3џ 0џД0З0У0Џ01 Шџ€-џ3џ 0џД0З0У0Џ0"\"#,##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џџЬџЬџџ™ІЪ№ЬœЬЬ™џууу3fџ3ЬЬ3™3™™3™f3™ffff™–––33Ь3ff333f3™3f33™BBB\џџџ`…DEL_TEST… šTEST…iTEST_V…’ TEST_JAPANŒQQЎќя3"No 5NAME 5Dept 5Age 5Mail 5GCD00051@nifty.ne.jp 5 Hippo2000 5kawait@nippon-rad.co.jp 5NoNAMEDeptAgeMailн]T][xQ Њ0ќ0з0ѓ0З0Й0Ц0р0‹NmiшGCD00051@nifty.ne.jpГlЌ™K\Œ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 eЦdx‘ /C сжqцхwџХŒЦЎ`щw№ХГ-0рdbТЧ Ч~ @§ § ~  0DŸ@~ @§ § ~ €BџџџџeW0y-p0ИW0+p0ОЧЧШЦ#хџџц!!џ 0zМЧ№—V0ФЦ–nЩ0Х0€hЦ‚АџЩ0n0Щ0@л0ОЧЧМЧ–nОЧЩЂ0ЧЧџџџџ]г0ОЧЧџџџџДЧDЩj–nЬшtXЧIАwшtТw ^КwшtטШП0ЖW0”Ш П0бО0rW0#)% —F€аЧ'Щ0)pW0ќ—€ќ€% —0Ш…Ч0 меpќШ`!W0t—`Ш`АџxПphкpџџџџ\ШиyВwќ`!W0€Ш`!W0ќХ0tШ€„0 `!W0€ШЩ„p0„p0ьЬ0”ШЧЬ Ч H ЧЬ Ч­w 0Чф(Ч€Щ Щш ЧLЩт‚0DЩкXXџџџџХ" шЬЩ ;W  dќЉёвMbP?_*+‚€%џСƒ„Ё"џ`!W0ќЉёвMbр?ќЉёвMbр?U} л} Ж} m} Ж} $s(§ §  §  §  §  ~ №?§ § ~ €B@§ зДF>Ж@  я5 шЬЩ V"  dќЉёвMbP?_*+‚€%џСƒ„Ё"џќЉёвMbр?ќЉёвMbр?U} л} Ж} m} Ж} $џsџџ8щGџ§ § § § § ~ №?§ § ~ €B@§ ~ @§ § ~ DŸ@~ @§ § ~ €B@§ з d<FFB>Ж@я5 шЬЩ  %G  dќЉёвMbP?_*+‚€%џСƒ„Ё"џќЉёвMbр?ќЉёвMbр?U} л} m} m} л}   џsџџ8щGџ џŒЧ џХ§ §  §  §  § ~ №?§ § ~ €B@§ ~ @§ § ~ DŸ@§ ~ @§ § ~ €B@§ §  § § !зКdFFFF>Ж@  я5 шЬЩ N  dќЉёвMbP?_*+‚€%џСƒ„Ё"џќЉёвMbр?ќЉёвMbр?U} л} Ж} m} Ж} $s(џ8щGџ§ §  §  §  §  ~ №?§  § ~ €B@§ ~ @§ § ~ DŸ@~ @§ § ~ €B@§ з Z<FF8>Ж@  я5 ўџр…ŸђљOhЋ‘+'Гй0@ (8ЄkawaitaўџеЭеœ.“—+,љЎDеЭеœ.“—+,љЎаHP X`hp x АЄш  DEL_TESTTESTTEST_V TEST_JAPAN мАИМАФ˜ 6> _PID_GUIDЄAN{CAF0C7A0-3F66-11D5-9802-0090CC001ADF} ўџџџўџџџўџџџ§џџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџRoot Entryџџџџџџџџ РFPMыw§РўџџџWorkbookџџџџџџџџџџџџWSummaryInformation(џџџџ DocumentSummaryInformation8џџџџџџџџџџџџDBD-Excel-0.06/sample/README0100644000076400007640000000112307564160257014573 0ustar kawaitkawaittex.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.06/sample/testj.xls0100644000076400007640000003300007564160260015565 0ustar kawaitkawaitаЯрЁБс>ўџ ўџџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ ўЭсСПРт\pь‡F“T BЄœ=М%r8X@"Зк1ШџArial1ШџArial1ШџArial1ШџArial1Шџ€‚l‚r ‚oƒSƒVƒbƒN1xџ€‚l‚r ‚oƒSƒVƒbƒN"\"#,##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џџЬџЬџџ™ІЪ№ЬœЬЬ™џууу3fџ3ЬЬ3™3™™3™f3™ffff™–––33Ь3ff333f3™3f33™BBB… ї“њ–{Œъ ўЭ Џч  dќЉёвMbP?_*+‚€%џŒQQСƒ„Ё"QF ќЉёвMbр?ќЉёвMbр?ЄU} лF} ЖF} mF} ЖF} $F @@џ@џ@ ”д† –М‘O •”ƒ[ƒ‹ƒ[ƒ‹~ №?ь‡F“TƒI[ƒvƒ“ƒVƒXƒeƒ€Ž–‹Ц•”~ €B@GCD00051@nifty.ne.jp~ @‰Э”n‰Ў“ёч”N“А‰Э”n‰Ў“ёч”N“А~ DŸ@~ @ Hippo2000‰Э”n‰Ў“ёч”N“А~ €B@kawait@nippon-rad.co.jpз д<TrP=М%r8X> ЖЋ" рџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ ўџр…ŸђљOhЋ‘+'Гй0l08 L XdЄ ь‡F“Ta@qв!)ыР@€Зu;-ыРўџеЭеœ.“—+,љЎ0€0 8@ H [Є “њ–{Œъ  ƒ[ƒNƒV[ƒgўџџџ ўџџџўџџџ§џџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџRoot Entryi“јјџџџџџџџџРFўџџџBook џџџџџџџџџџџџSummaryInformation(џџџџDocumentSummaryInformation8џџџџџџџџџџџџDBD-Excel-0.06/sample/texj.pl0100644000076400007640000001123707564160260015223 0ustar kawaitkawaituse 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.06/sample/res_hidden0100644000076400007640000000537307564160257015755 0ustar kawaitkawait#------------------------------------------------------------ # 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.06/sample/newxl.xls0100644000076400007640000001300007564160257015575 0ustar kawaitkawaitаЯрЁБс>ўџ ўџџџўџџџ џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ l Щ=М%r8X"1ШџArial1ШџArial1ШџArial1ШџArial1ШџArial1Ш Arial1Шџ-3 0ДЗУЏЄ@рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р рѕџ Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р р Р рЄ Р рЄ д– I€@ рЄ Р рЄ Д– I€@ рЄ $Р @€I€@ рЄ ,Р @€I€@ рЄ фA€I€@ рЄ ьA€I€@ “€џ… 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џР @"ГЌKŒCt"ГЌKŒCt DŸ@џР @" Hippo2000"ГЌKŒCt €B@ kawait@nippon-rad.co.jp)№?(№?'ш?&ш?„ƒ> Ж l ЩTESTTEST_V TEST_JAPANЁ"dXXр?р? џР ID NO NAME)№?(№?'ш?&ш?„ƒ> Ж Root EntryџџџџџџџџўџџџBook џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўџџџўџџџ§џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџDBD-Excel-0.06/sample/testj.pl0100644000076400007640000000164207564160257015407 0ustar kawaitkawaituse 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.06/sample/thidden.pl0100644000076400007640000001611607564160260015671 0ustar kawaitkawaituse 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.06/sample/res_texj0100644000076400007640000000471707564160257015475 0ustar kawaitkawait#-------------------------------------------------------------- # 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.06/sample/tex.pl0100644000076400007640000001035107564160260015045 0ustar kawaitkawaituse 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.06/MANIFEST0100644000076400007640000000041407322310003013537 0ustar kawaitkawaitChanges Excel.pm Makefile.PL MANIFEST README test.pl 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 DBD-Excel-0.06/test.pl0100644000076400007640000000121707274747114013753 0ustar kawaitkawait# 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.06/Changes0100644000076400007640000000157707564161250013734 0ustar kawaitkawaitRevision history for Perl extension DBD::Excel. 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.06/Makefile.PL0100644000076400007640000000150607564156715014415 0ustar kawaitkawait# -*- perl -*- use DBI; use DBI::DBD; use ExtUtils::MakeMaker; ExtUtils::MakeMaker::WriteMakefile( 'NAME' => 'DBD::Excel', 'VERSION_FROM' => 'Excel.pm', 'INC' => $DBI_INC_DIR, 'dist' => { 'SUFFIX' => '.gz', 'COMPRESS' => 'gzip -9f' }, 'realclean' => {'*.xsi'}, 'PREREQ_PM' => { Spreadsheet::ParseExcel => 0.22, Spreadsheet::WriteExcel => 0.31, DBI => 1, SQL::Statement => , }, # e.g., Module::Name => 1.1 ); package MY; sub postamble { DBI::DBD::dbd_postamble(@_); } sub libscan { my($self, $path) = @_; ($path =~ /\~$/) ? undef : $path; } __DATA__ DBD-Excel-0.06/Excel.pm0100644000076400007640000010672107564157220014036 0ustar kawaitkawait#!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.06'; $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); =cmmt 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; }; } =cut 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; $hDb = DBI->connect("DBI:Excel:file=test.xls") or die "Cannot connect: " . $DBI::errstr; $hSt = $hDb->prepare("CREATE TABLE a (id INTEGER, name CHAR(10))") or die "Cannot prepare: " . $hDb->errstr(); $hSt->execute() or die "Cannot execute: " . $hSt->errstr(); $hSt->finish(); $hDb->disconnect(); =head1 DESCRIPTION This is still B. The DBD::Excel module is a DBI driver. The module is based on these modules: =over 4 =item * Spreadsheet::ParseExcel reads Excel files. =item * Spreadsheet::WriteExcel writes Excel files. =item * SQL::Statement a simple SQL engine. =item * DBI Of course. :-) =back This module assumes TABLE = Worksheet. The contents of first row of each worksheet as column name. Adding that, this module accept temporary table definition at "connect" method with "xl_vtbl". ex. 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, } } }); For more information please refer sample/tex.pl included in this distribution. =head2 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: =over 4 =item AutoCommit Always on =item ChopBlanks Works =item NUM_OF_FIELDS Valid after C<$hSt-Eexecute> =item NUM_OF_PARAMS Valid after C<$hSt-Eprepare> =item NAME Valid after C<$hSt-Eexecute>; undef for Non-Select statements. =item NULLABLE Not really working, always returns an array ref of one's. Valid after C<$hSt-Eexecute>; undef for Non-Select statements. =back These attributes and methods are not supported: bind_param_inout CursorName LongReadLen LongTruncOk Additional to the DBI attributes, you can use the following dbh attribute: =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 SQL::Statement). 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 "DBI:Excel:xl_dir=$dirname". If you want to read the subdirectories of another directory, use my($hDr) = DBI->install_driver("Excel"); my(@list) = $hDr->data_sources( { xl_dir => '/usr/local/xl_data' } ); =item list_tables This method returns a list of sheet names contained in the $hDb->{file}. Example: my $hDb = DBI->connect("DBI:Excel:file=test.xls"); my @list = $hDb->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 SQL::Statement module allows joins and the likes. =back =head1 KNOWN BUGS =over 8 =item * There are too many TODO things. So I can't determind what is BUG. :-) =back =head1 AUTHOR Kawai Takanori (Hippo2000) kwitknr@cpan.org Homepage: http://member.nifty.ne.jp/hippo2000/ (Japanese) http://member.nifty.ne.jp/hippo2000/index_e.htm (English) Wiki: http://www.hippo2000.net/cgi-bin/KbWiki/KbWiki.pl (Japanese) http://www.hippo2000.net/cgi-bin/KbWikiE/KbWiki.pl (English) =head1 SEE ALSO DBI, Spreadsheet::WriteExcel, Spreadsheet::ParseExcel, SQL::Statement =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