[WebDNA] Snippets: EXPORT RECORDS using WRITEFILE

This WebDNA talk-list message is from

2009


It keeps the original formatting.
numero = 103675
interpreted = N
texte = Have another useful snippet to contribute to the community. Everything in this email is also in the file here: http://terryfic.com/ExportRecords.txt Enjoy, Terry EXPORT RECORDS using WRITEFILE Here's a handy way to export your database in its entirety into an excel sheet. It's really just a tab delimited text file, but by naming it with the .xls extension, it will open up into an excel worksheet. Feel free to change the extension to .txt instead, but I find that clients understand an Excel file more often a text file. Sad but true. The first snippet exports everything, using [listfields] to spit out the fieldnames. Set a variable for the database location, and the rest happens automatically. The second one is a custom writefile, since more often than not, you'll want to provide an export for the client, and your database may contain fields that are not relevant, or have fieldnames that are not user-friendly, or contain passwords. You will also probably want to sort in a specific manner. I give an example using a membership database. Instead of exporting the MemberID field, I leave a blank header for the first column, and simply let [index] provide a running count in that column. Make sure you protect these snippets behind an admin password! I have wrapped them in a showif for a cookie that only the admin has. Courtesy of Terry Wilson September 23, 2009 [!] *** Export everything *** [/!] [showif [getcookie admin]=t] [text]db=YourDatabaseName.db[/text] [showif [exportfulldata]=t][writefile secure=f&file=FullData_[date %m%d%y].xls][listfields db=[db]][fieldname][showif [index]=1][text]firstfield=[fieldname][/text][/showif][/listfields] [search db=[db]&ne[firstfield]datarq=[blank]&Rank=off][founditems] [listfields db=[db]][interpret][[fieldname]][/interpret] [/listfields][/founditems][/search] [/writefile]Here is your export: FullData_[date %m%d%y].xls | [/showif]Export Full Data [/showif] [!] *** Export a custom set of fields *** [/!] [showif [getcookie admin]=t] [showif [exportdata]=t][writefile secure=f&file=YourData_[date %m%d%y].xls][search db=YourDatabase.db&neMemberIDdatarq=[blank]&lnamesort=1&fnamesort=2] First NameLast NameEmailPhoneCellFax Address1Address2CityStateZip [founditems] [index][fname][lname][email][Phone][Cell][Fax][addr1] [addr2][City][State][Zip][/founditems][/search] [/writefile]Here is your export: YourData_[date %m%d%y].xls | [/showif] Export Custom Data [/showif] -- Terry Wilson | terry@terryfic.com | http://terryfic.com http://WhosComing.com - a simplified, affordable online reservation system http://TightJacket.com -- stylish protection for your laptop -------------------------------------------------------------------------- Attitude is the only difference between ordeal and adventure. Associated Messages, from the most recent to the oldest:

    
  1. Re: [WebDNA] Snippets: EXPORT RECORDS using WRITEFILE (Govinda 2009)
  2. [WebDNA] Snippets: EXPORT RECORDS using WRITEFILE (Terry Wilson 2009)
Have another useful snippet to contribute to the community. Everything in this email is also in the file here: http://terryfic.com/ExportRecords.txt Enjoy, Terry EXPORT RECORDS using WRITEFILE Here's a handy way to export your database in its entirety into an excel sheet. It's really just a tab delimited text file, but by naming it with the .xls extension, it will open up into an excel worksheet. Feel free to change the extension to .txt instead, but I find that clients understand an Excel file more often a text file. Sad but true. The first snippet exports everything, using [listfields] to spit out the fieldnames. Set a variable for the database location, and the rest happens automatically. The second one is a custom writefile, since more often than not, you'll want to provide an export for the client, and your database may contain fields that are not relevant, or have fieldnames that are not user-friendly, or contain passwords. You will also probably want to sort in a specific manner. I give an example using a membership database. Instead of exporting the MemberID field, I leave a blank header for the first column, and simply let [index] provide a running count in that column. Make sure you protect these snippets behind an admin password! I have wrapped them in a showif for a cookie that only the admin has. Courtesy of Terry Wilson September 23, 2009 [!] *** Export everything *** [/!] [showif [getcookie admin]=t] [text]db=YourDatabaseName.db[/text] [showif [exportfulldata]=t][writefile secure=f&file=FullData_[date %m%d%y].xls][listfields db=[db]][fieldname][showif [index]=1][text]firstfield=[fieldname][/text][/showif][/listfields] [search db=[db]&ne[firstfield]datarq=[blank]&Rank=off][founditems] [listfields db=[db]][interpret][[fieldname]][/interpret] [/listfields][/founditems][/search] [/writefile]Here is your export: FullData_[date %m%d%y].xls | [/showif][thisurl]?exportfulldata=t">Export Full Data [/showif] [!] *** Export a custom set of fields *** [/!] [showif [getcookie admin]=t] [showif [exportdata]=t][writefile secure=f&file=YourData_[date %m%d%y].xls][search db=YourDatabase.db&neMemberIDdatarq=[blank]&lnamesort=1&fnamesort=2] First NameLast NameEmailPhoneCellFax Address1Address2CityStateZip [founditems] [index][fname][lname][email][Phone][Cell][Fax][addr1] [addr2][City][State][Zip][/founditems][/search] [/writefile]Here is your export: YourData_[date %m%d%y].xls | [/showif] [thisurl]?exportdata=t">Export Custom Data [/showif] -- Terry Wilson | terry@terryfic.com | http://terryfic.com http://WhosComing.com - a simplified, affordable online reservation system http://TightJacket.com -- stylish protection for your laptop -------------------------------------------------------------------------- Attitude is the only difference between ordeal and adventure. Terry Wilson

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

[sendmail] and [formvariables] (1997) Document Contains No Data! (1997) CASTEGORIES IN DIFFERENT FRAMES (1997) Customer - again (1998) Logging purchases (1997) [WriteFile] problems (1997) WebCat2b12 - nesting [tags] (1997) GuestBook example (1997) Shopping cart not being assigned (1999) embedded search vs. URL (2004) Version 4? (2000) Question about replacing words (1998) Setting Cart value (2000) Associative lookup style? (1997) RE: Cart Template (1997) Tax Troubles (2003) Sort Order on a page search (1997) Fufillment e-mail? (1998) Support suggestions - long (was politeness, et al) (2000) Emailer Set Up (1997)