version 1.5, 2003/05/23 19:36:04
|
version 1.6, 2003/05/23 21:03:29
|
Line 1342 sub outsheet_excel {
|
Line 1342 sub outsheet_excel {
|
return; |
return; |
} |
} |
|
|
|
################################# |
|
## CSV output routines ## |
|
################################# |
|
sub outsheet_csv { |
|
my $self = shift; |
|
my ($r) = @_; |
|
my $csvdata = ''; |
|
my @Values; |
|
# |
|
# Open the csv file |
|
my $filename = '/prtspool/'. |
|
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
|
time.'_'.rand(1000000000).'.csv'; |
|
my $file; |
|
unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) { |
|
$r->log_error("Couldn't open $filename for output $!"); |
|
$r->print("Problems occured in writing the csv file. ". |
|
"This error has been logged. ". |
|
"Please alert your LON-CAPA administrator."); |
|
$r->print("<pre>\n".$csvdata."</pre>\n"); |
|
return 0; |
|
} |
|
# |
|
# Output the title information |
|
foreach my $value ($self->get_title()) { |
|
print $file "'".&Apache::loncommon::csv_translate($value)."'\n"; |
|
} |
|
# |
|
# Output the body of the spreadsheet |
|
$self->csv_rows($file); |
|
# |
|
# Close the csv file |
|
close($file); |
|
$r->print('<br /><br />'. |
|
'<a href="'.$filename.'">Your CSV spreadsheet.</a>'."\n"); |
|
# |
|
return 1; |
|
} |
|
|
|
sub csv_output_row { |
|
my $self = shift; |
|
my ($filehandle,$rownum,@prepend) = @_; |
|
# |
|
my @rowdata = (); |
|
if (defined($rownum)) { |
|
@rowdata = $self->get_row($rownum); |
|
} |
|
my @output = (); |
|
foreach my $cell (@prepend,@rowdata) { |
|
my $value = $cell; |
|
$value = $cell->{'value'} if (ref($value)); |
|
$value =~ s/\ / /gi; |
|
$value = "'".$value."'"; |
|
push (@output,$value); |
|
} |
|
print $filehandle join(',',@output )."\n"; |
|
return; |
|
} |
|
|
############################################ |
############################################ |
## XML output routines ## |
## XML output routines ## |
############################################ |
############################################ |