Hi, Eliot!
I know your probably just leaving for your venture to find a new abode. Hope all goes/went well. Moving is always fun!
I resolved a big chunk of issues with this mod. I will break it all down here.
1) First of all, I kind of misunderstood exactly how this mod was supposed to work. Originally, I thought it was supposed to allow you to export a record once you had it displayed. However, what it is supposed to do is when you are on a search form (sub html_view_search), it provides you with the option to print the search results to a file (in this case, as csv file) via the export button instead of to the browser (sub html_view_success) using the view records button. I guess this okay. However, as a user, I would rather see my search results first prior to exporting them. I think Carol mentioned this to Mitch (DonM) in another thread.
2) This leads to problem resolve #2. In Don's instructions for the Excel mod he says to do the following:
Code:
print qq|
<form action="$db_script_url" method="POST" name="form1">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
|;
my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=2 Color=#003399';
print qq|
<TABLE WIDTH="475" CELLPADDING=0 CELLSPACING=0 BORDER=1 BGCOLOR="#FFFFCC">
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>ID:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'ID'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Name:</FONT></TD>
<TD> <$font>$rec{'Name'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Email: </FONT></TD>
<TD> <$font>$rec{'Email'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date:</FONT></TD>
<TD> <$font>$rec{'Date'}</Font></TD></TR>
<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color>Date Last Modified:</FONT></TD>
<TD> <$font>$rec{'DateLastModified'}</Font></TD></TR>
</TABLE>
|;
print qq|
<p><center>
<INPUT TYPE="SUBMIT" NAME="export_found_records" VALUE="Export Results">
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="New Search">
<INPUT TYPE="RESET" VALUE="Reset Form">
</center></p>
</form>
|;
Part 2 - Then create a new subroutine in db.cgi under sub export_results:
Code:
sub export_found_records {
# --------------------------------------------------------
# This is called when a user wants to export found records to Excel
# All the work is done in query()
&export_to_Excel;
}
I got the above to work. I then putzed with the code a little bit and now when I hit the export results button, I get an action unknown error meassage. However, while it was working, when you download the file and open it, it only has the Field names but no records. I think this is because the new sub routine I created is looking in sub query for hits but it probably does not need to be doing this at this time. I know there should be more code in the new sub routine, but I don't know what else to put! You might not even need a new subroutine. You might be able to edit Don's exist export routine to include a new else statement.
When I had this mod working before implementing the short/long mod, I used to get the following error when trying to open the csv file:
Quote:
SYLK: FILE FORMAT IS INVALID
I don't know why. The same thing still happens when I invoke the export routine from the search page (field names and database entries show though in a text editor). This is what my csv file looks like if I open it in a text editor. I have tried opening it in Excel 97 and Excel 2000.
Quote:
ID,Name,Email,Date,DateLastModified
"1","Brian Michael","brian.michael@york.com","29-Oct-1999","29-Oct-1999"
"2","Brian York","brian.michael@york.com","29-Oct-1999","29-Oct-1999"
I then went to Don's site and tried his hockey demo. The csv file I got from his site opened right up in Excel. So I opened it in a text editor to compare it to my file and here is what it looked like:
Quote:
NHL,FirstName,LastName,Pos,Height,Weight,BirthDate,DraftedBy,Drafted,Active
"ANA","Mike","LeClerc","F","6'1","205","10-Nov-1976","Not Drafted","No","No"
"PHI","John","LeClair","F","6'3","228","05-Jul-1969","Chebib_Jim","Yes","Yes"
Looks similar in format to mine. What's wrong?
Third problem.. Using Internet Explorer 5.0, when I click on the link to retrieve the csv file, I get a window that opens up along with the download prompt box and after I hit the save file to disk button, this new window loads a blank page saying action cancelled - no page to be displayed (the file itself downloads successfully). Anyway to stop this? It just looks sloppy.
I think we got this thread close to complete. Please provide some code, Eliot or Don, if you can to finish this up. I am stumped at this point. Sorry if this so long - I just did not want to miss anything!
Thanks!
[This message has been edited by BrianYork (edited October 30, 1999).]