Gossamer Forum
Home : Products : DBMan : Customization :

Still Export to Excel file Problem

Quote Reply
Still Export to Excel file Problem
Hi,

I tried it twice, but still got no solution and I really don't like to change to another database :-((( DBMan is really perfect for me, but I need that export function.

So let me try it again. I installed the Excel mod exactly as Don described it. After solving the CGI error (which most of you had), I managed, that the Mod creates the CSV file with the headers. But unfortunately that's it. NO RECORS inside the file, although the HTML output is perfect. So the MOD found the datas, but doesn't write them into the CSV file.

I really can't believe, that I'm the only one having this problem ....

So I'm happy with any hint, which might help and I'm sure it's something totaly simple, but since I'm no programmer nor even familiar with Perl, I have to ask you guys out there in the DBMan community :-))


Thanks,
Felix

Quote Reply
Re: Still Export to Excel file Problem In reply to
Can you post a copy of the html.pl and db.cgi on your site in TXT format? I'll take a run through it and see what we can't figure out.

Conor

Conor Treacy
-----
www.HandsonWebDesign.com
Quote Reply
Re: Still Export to Excel file Problem In reply to
Hi Conor,

sure. Please find them here:

http://www.die-muellers.org/test/html.txt
http://www.die-muellers.org/test/db.txt

Thanks for helping,
Felix
Quote Reply
Re: Still Export to Excel file Problem In reply to
Uh...he meant COPYING the html.pl as a TXT file, uploading it to your server, and then posting the URL to the TEXT file, NOT simply copying the file and pasting in the forums, which is counter-productive. Wink

Regards,

Eliot Lee
Quote Reply
Re: Still Export to Excel file Problem In reply to
Ups :-))

I changed the message.

Thanks for the hint.

Felix

Quote Reply
Re: Still Export to Excel file Problem In reply to
How ya doin... well lets see what I've got for you so far...

In your html.pl file:

sub csv_header {
# --------------------------------------------------------
# print field name headers for each column of data

my $num = 0;
for (my $i =0; $i <= $#db_cols; $i++) {
# Export all non-admin fields (admin form length = -2)
if ($db_form_len{$db_cols[$i]} >= -1) {
if ($num > 0) {print CSVFILE ";";}
print CSVFILE qq|$db_cols[$i]|;
$num += 1;
}
}
print CSVFILE "\n";
}

Should BE

sub csv_header {
# --------------------------------------------------------
# print field name headers for each column of data

my $num = 0;
for (my $i =0; $i <= $#db_cols; $i++) {
# Export all non-admin fields (admin form length = -2)
if ($db_form_len{$db_cols[$i]} >= -1) {
if ($num > 0) {print CSVFILE ",";}
print CSVFILE qq|$db_cols[$i]|;
$num += 1;
}
}
print CSVFILE "\n";
}

There is a comma supposed to be at the "if($num > 0) {print CSVFILE ",";} not a semi-colon (;)

That seems to be the only thing I have found that is different. Go ahead and change that and see if that makes the difference for you. Also, be sure your "csv" directory has write access to it, the program needs to write the information to that directory. It should be, as you get the header info, but double check it just for the heck of it k?

lep

Conor Treacy
-----
www.HandsonWebDesign.com
Quote Reply
Re: Still Export to Excel file Problem In reply to
Hi Conor,

thanks for that, since the header is now correct, but unfortunately I still hav no records :-((

Felix

Quote Reply
Re: Still Export to Excel file Problem In reply to
Ok... well onto step 2. can you copy all your files into TXT format and put them into your test directory? I'll load up the database on my end and see what happens. Also, i remember having a problem similar to this when I was using IE as my browser, but it worked fine under Netscape... which browser are you using, and do you have access to the other to test?

If you'd make that copy, or even ZIP them, i'd appreciate it.

lep

Conor Treacy
-----
www.HandsonWebDesign.com
Quote Reply
Re: Still Export to Excel file Problem In reply to
Copy the following information and post it into your .PL file. Replace your old "sub export_to_Excel" and see if this changes anything for you. Remember to make a backup of your file before putting this in so we can switch back if this doesn't help.

Also, in your CSV directory, check and see if there is a file that was created when you tried to export. See if any data has been written to it. Remember to check again and make sure that your CSV directory has write permission.

sub export_to_Excel {
my ($browser) = "";
print qq| Content-type: application/msexcel\n\n|;
print qq|
<html>
<head>
<title>$html_title: Search Results.</title>
</head>
<body>
|;
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

if ($browser ne "IE4") {
&xl_header();
for (0 .. $numhits - 1) {
&xl_record (&array_to_hash($_, @hits));
}
print "</TABLE>";
}
else {

# Open temporary csv file
my ($csvfilename) = "$db_uid" . ".csv";
my ($csvfileloc) = ">$db_csv_path$csvfilename";
open(CSVFILE, $csvfileloc) || die "Unable to open CSV file location ($csvfileloc).";


&csv_header();

# Go through each hit and convert the array to hash and send to
# csv_record for printing.

for (0 .. $numhits - 1) {
&csv_record (&array_to_hash($_, @hits));
}
close CSVFILE || die "Unable to close CSV file ($csvfilename).";

# Create link to CSV file for user to open
# delete file after use.

print "<html><head><title>$html_title: Search Results.</title></head><body>";
print qq|
<h3>Your Export File has been created!</h3><p>
<a href="$db_csv_url/$csvfilename" target="_export" name="Export" title="Export Results">Click here to retrieve it.</a>
|;
&html_footer;
}
print "</body></html>";
}

Conor Treacy
-----
www.HandsonWebDesign.com
Quote Reply
Re: Still Export to Excel file Problem In reply to
Hi Conor,

I don't think it has to with the browser, since the preview is correct and when I took a view on what the Export produces via FTP, it's always 123 bytes and only shows the header. So if the Mod makes the entries in the CSV file depending on the browser ..... Anyway. I give up.

Thanks very much for your help,
Felix

Thanks,
Felix

Quote Reply
Re: Still Export to Excel file Problem In reply to
Hi,

I just saw, that there was an additional answer :-)) I tried it, but I get following error:

CGI ERROR
==========================================
Error Message : fatal error: Undefined subroutine &main::xl_header called at ./html.pl line 1294.

Script Location : db.cgi
Perl Version : 5.006
Setup File : default.cfg
User ID : Felix
Session ID : Felix.9825203678406

This resulted in direct download of above error message.

Thanks,
Felix


Quote Reply
Re: Still Export to Excel file Problem In reply to
Are you sure you included that sub within your html.pl file?

It's looking for and can not locate the sub:

sub xl_header


Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: Still Export to Excel file Problem In reply to
Yep. I did, but as it looks like. I compared the part from Conor with the original and there it's just missing :-))

So actually this doesn't help :-((

Quote Reply
Re: Still Export to Excel file Problem In reply to
Hmmm ... if I ever get this solved ... Ok. Let's try to explain it again. The MOD is running so far. There's only one thing, which doesn't work: It writes NO data into the CSV file. So the file (*.csv) itself is created, the display on the screen is created (my search selection), the header (field names) is written to the CSV file, but at this point I have nothing more.

So the error should be somewhere in the export of data routine, where the MOD should take the data just written to the screen (and should be therefore written to some temporary array or whatever is used) and should save them into the CSV file.

Hope this helps to center the main problem.

Quote Reply
Re: Still Export to Excel file Problem In reply to
Well femu, while I'm happy to see that you're still attacking the problem, I'm surprised that it hasn't already been fixed. Let's start over and we'll go through this from the beginning again k?

Put a copy of all your files (in Text format) onto your website and send me a link (either here or e-mail conor@handsonwebdesign.com). There must be something different and it's playing havoc on your system. I'll take your entire database/program and load it up on my server, see what I can come up with through the night.

Conor Treacy
-----
www.HandsonWebDesign.com
Quote Reply
Re: Still Export to Excel file Problem In reply to
Hi Conor,
that's me :-)) It really takes very long until I really give up. I'll send you the stuff via mail, since there are some sensible datas.
Thanks very much for taking a close look on it.
Felix

Quote Reply
Re: Still Export to Excel file Problem In reply to
Just moving this back up to the top of the list so we can keep track of where we are. I've sent you the files with everything changed in them. There is still one problem and that is if you export from MSIE then it does not put (.XLS or .CSV) at the end of the file it creates, meaning it won't automatically call the EXCEL program. We'll get this part sorted out and you'll be well on your way to saying "Damnit!! Now what's wrong??!!" Wink

Conor Treacy
-----
www.HandsonWebDesign.com
Quote Reply
Re: Still Export to Excel file Problem In reply to
Brilliant! It finally works and gives me a readable file. Not perfect, but you surely get it to be in a while!

Thanks,
Felix