I'm using the Export Search results to Excel Mod and the output in Excel doesn't display properly. One of the fields I have is a very large text area. It's taking some of the information from that cell and dividing it up amongst the cell's after it. (example: text area is cell J, text which should appear in cell J is appearing in K,L,M,etc.) Is this a matter of my settings in Microsoft Excel, or is it a setting that should be configured in the Mod? I really have no clue as to why the output is this way except for maybe a cell can only contain so many characters of data, so I don't know where to begin in fixing this.
Jul 21, 2000, 1:48 PM
Novice (34 posts)
Jul 21, 2000, 1:48 PM
Post #2 of 7
Views: 2044
Here's an amendment to my previous post. I would like to take out a field (the large text area field) entirely from the Excel output. I'm using the Spreadsheet Mod and have that configured to leave out said field in all displays, I would like the Excel Mod to also "forget" that information is there when it exports.
Jul 25, 2000, 12:35 AM
Veteran / Moderator (8669 posts)
Jul 25, 2000, 12:35 AM
Post #3 of 7
Views: 2023
As to your first problem, I think that needs to be set in Excel. There's something about word-wrapping that you can set.
For your second problem, I've looked at the Export mod and it looks like you would need to make a change in sub xl_record:
for (my $i =0; $i <= $#db_cols; $i++) {
unless ($i == the number of the field you don't want to print) {
if ($db_form_len{$db_cols[$i]} >= -1) {
# Export all non-admin fields (admin form length = -2)
print qq|<td width="$db_lengths{$db_cols[$i]}"> <$font>$rec{$db_cols[$i]}</font></td>|;
}
}
}
JPD
http://www.jpdeni.com/dbman/
For your second problem, I've looked at the Export mod and it looks like you would need to make a change in sub xl_record:
Code:
for (my $i =0; $i <= $#db_cols; $i++) {
unless ($i == the number of the field you don't want to print) {
if ($db_form_len{$db_cols[$i]} >= -1) {
# Export all non-admin fields (admin form length = -2)
print qq|<td width="$db_lengths{$db_cols[$i]}"> <$font>$rec{$db_cols[$i]}</font></td>|;
}
}
}
http://www.jpdeni.com/dbman/
Jul 25, 2000, 10:08 AM
Novice (34 posts)
Jul 25, 2000, 10:08 AM
Post #4 of 7
Views: 2011
I have been trying this method and it doesn't seem to work.
Here is the code in my html.pl file:
----------------------------------------------------------->
sub xl_record {
# --------------------------------------------------------
# writes record in table format for Excel export
my (%rec) = @_; # Load any defaults to put in the VALUE field.
my $num = 0;
print "<tr>";
for (my $i =0; $i <= $#db_cols; $i++) {
unless ($i ==9) {
if ($db_form_len{$db_cols[$i]} >= -1) {
# Export all non-admin fields (admin form length = -2)
print qq|<td width="$db_lengths{$db_cols[$i]}"> <$font>$rec{$db_cols[$i]}</font></td>|;
}
}
}
print "</tr>";
}
<----------------------------------------------------------
I've tried different variations of ($i ==9) such as ($i =9), ($i = 9), ($i == 9), etc. and none of them seem to work. Oddly enough, dbman doesn't pick this up as an error, it runs the program but the export results still contain field 9. Did I copy/past the code incorrectly? Could there be some other code that needs to be changed for this to work? I would also like the export to ignore field 15, would I code that as ($i ==9,15) or ($i ==9; 15)?? please help.
Here is the code in my html.pl file:
----------------------------------------------------------->
sub xl_record {
# --------------------------------------------------------
# writes record in table format for Excel export
my (%rec) = @_; # Load any defaults to put in the VALUE field.
my $num = 0;
print "<tr>";
for (my $i =0; $i <= $#db_cols; $i++) {
unless ($i ==9) {
if ($db_form_len{$db_cols[$i]} >= -1) {
# Export all non-admin fields (admin form length = -2)
print qq|<td width="$db_lengths{$db_cols[$i]}"> <$font>$rec{$db_cols[$i]}</font></td>|;
}
}
}
print "</tr>";
}
<----------------------------------------------------------
I've tried different variations of ($i ==9) such as ($i =9), ($i = 9), ($i == 9), etc. and none of them seem to work. Oddly enough, dbman doesn't pick this up as an error, it runs the program but the export results still contain field 9. Did I copy/past the code incorrectly? Could there be some other code that needs to be changed for this to work? I would also like the export to ignore field 15, would I code that as ($i ==9,15) or ($i ==9; 15)?? please help.
Jul 25, 2000, 5:35 PM
Veteran / Moderator (8669 posts)
Jul 25, 2000, 5:35 PM
Post #5 of 7
Views: 2028
It needs to be $i == 9 (spaces don't matter, but you have to have both = signs).
Just a little tutorial.
In Perl = means "gets set to" and == means "is equal to."
I have no idea why it wouldn't work, though. When I run the code on my home computer, it does exactly what it's supposed to do.
It looks like you have the code correct -- in fact, I just copied it from your post and pasted it into my test script.
Since you want to eliminate two fields, it's easier to do an "if" than an "unless" (for me, anyway
), so let's try changing
unless ($i ==9) {
to
if (($i != 9) && ($i != 15)) {
(The != means "is not equal to.")
This works on my home computer, too.
JPD
http://www.jpdeni.com/dbman/
Just a little tutorial.

I have no idea why it wouldn't work, though. When I run the code on my home computer, it does exactly what it's supposed to do.
It looks like you have the code correct -- in fact, I just copied it from your post and pasted it into my test script.
Since you want to eliminate two fields, it's easier to do an "if" than an "unless" (for me, anyway

unless ($i ==9) {
to
if (($i != 9) && ($i != 15)) {
(The != means "is not equal to.")
This works on my home computer, too.
JPD
http://www.jpdeni.com/dbman/
Jul 26, 2000, 6:07 AM
Novice (34 posts)
Jul 26, 2000, 6:07 AM
Post #6 of 7
Views: 1989
It worked! in a way...
That line of code certainly did the trick. however, it wasn't until I added if (($i != 9) && ($i != 15)) {
into sub csv_header , sub csv_record , and sub xl_header as well as sub xl_record. Now, Im not sure if it needed to be in all those subroutines, but the point is it now works.
With this out of the way I have one more important detail to fix. I would not like anyone but the admin to have access to the "Export Results" button. This is imperative for security reaons. I've tried the method to which you can make a field only visible to the admin but it doesn't seem to work with buttons. Is there a way to do this?
That line of code certainly did the trick. however, it wasn't until I added if (($i != 9) && ($i != 15)) {
into sub csv_header , sub csv_record , and sub xl_header as well as sub xl_record. Now, Im not sure if it needed to be in all those subroutines, but the point is it now works.
With this out of the way I have one more important detail to fix. I would not like anyone but the admin to have access to the "Export Results" button. This is imperative for security reaons. I've tried the method to which you can make a field only visible to the admin but it doesn't seem to work with buttons. Is there a way to do this?
Jul 26, 2000, 3:29 PM
Veteran / Moderator (8669 posts)
Jul 26, 2000, 3:29 PM
Post #7 of 7
Views: 1981
I'm glad you were able to work it out.
The first thing you need to do is to change the line in db.cgi, sub main so only admins can use the function:
elsif ($in{'export_records'}) { if ($per_admin) { &export_records; } else { &html_unauth; } }
That's your main security.
As for your button, right now you probably have
<p><center> <INPUT TYPE="SUBMIT" NAME="export_records" VALUE="Export Results">
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="View Records">
or something similar.
Change this to
if ($per_admin) {
print qq| <INPUT TYPE="SUBMIT" NAME="export_records" VALUE="Export Results">|;
}
print qq|
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="View Records">It won't print out the button unless you have admin permission.
JPD
http://www.jpdeni.com/dbman/

The first thing you need to do is to change the line in db.cgi, sub main so only admins can use the function:
elsif ($in{'export_records'}) { if ($per_admin) { &export_records; } else { &html_unauth; } }
That's your main security.
As for your button, right now you probably have
<p><center> <INPUT TYPE="SUBMIT" NAME="export_records" VALUE="Export Results">
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="View Records">
or something similar.
Change this to
Code:
<p><center>|; if ($per_admin) {
print qq| <INPUT TYPE="SUBMIT" NAME="export_records" VALUE="Export Results">|;
}
print qq|
<INPUT TYPE="SUBMIT" NAME="view_records" VALUE="View Records">
JPD
http://www.jpdeni.com/dbman/