version 1.39, 2005/03/03 17:52:36
|
version 1.40, 2005/03/10 17:33:57
|
Line 1433 sub excel_output_row {
|
Line 1433 sub excel_output_row {
|
return; |
return; |
} |
} |
|
|
sub create_excel_spreadsheet { |
|
my $self = shift; |
|
my ($r) = @_; |
|
my $filename = '/prtspool/'. |
|
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
|
time.'_'.rand(1000000000).'.xls'; |
|
my $workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename); |
|
if (! defined($workbook)) { |
|
$r->log_error("Error creating excel spreadsheet $filename: $!"); |
|
$r->print(&mt("Problems creating new Excel file. ". |
|
"This error has been logged. ". |
|
"Please alert your LON-CAPA administrator")); |
|
return undef; |
|
} |
|
# |
|
# The excel spreadsheet stores temporary data in files, then put them |
|
# together. If needed we should be able to disable this (memory only). |
|
# The temporary directory must be specified before calling 'addworksheet'. |
|
# File::Temp is used to determine the temporary directory. |
|
$workbook->set_tempdir('/home/httpd/perl/tmp'); |
|
# |
|
# Determine the name to give the worksheet |
|
return ($workbook,$filename); |
|
} |
|
|
|
# |
# |
# This routine is just a stub |
# This routine is just a stub |
sub outsheet_htmlclasslist { |
sub outsheet_htmlclasslist { |
Line 1478 sub outsheet_excel {
|
Line 1453 sub outsheet_excel {
|
# |
# |
$r->print("<h2>".&mt('Preparing Excel Spreadsheet')."</h2>"); |
$r->print("<h2>".&mt('Preparing Excel Spreadsheet')."</h2>"); |
# |
# |
# Create excel worksheet |
# Create excel workbook |
my ($workbook,$filename) = $self->create_excel_spreadsheet($r); |
my ($workbook,$filename,$format)=&Apache::loncommon::create_workbook($r); |
return if (! defined($workbook)); |
return if (! defined($workbook)); |
# |
# |
# Create main worksheet |
# Create main worksheet |
Line 1490 sub outsheet_excel {
|
Line 1465 sub outsheet_excel {
|
# Write excel header |
# Write excel header |
foreach my $value ($self->get_title()) { |
foreach my $value ($self->get_title()) { |
$cols_output = 0; |
$cols_output = 0; |
$worksheet->write($rows_output++,$cols_output,$value); |
$worksheet->write($rows_output++,$cols_output,$value,$format->{'h1'}); |
} |
} |
$rows_output++; # skip a line |
$rows_output++; # skip a line |
# |
# |
# Write summary/export row |
# Write summary/export row |
$cols_output = 0; |
$cols_output = 0; |
$self->excel_output_row($worksheet,0,$rows_output++,'Summary'); |
$self->excel_output_row($worksheet,0,$rows_output++,'Summary', |
|
$format->{'b'}); |
$rows_output++; # skip a line |
$rows_output++; # skip a line |
# |
# |
$self->excel_rows($connection,$worksheet,$cols_output,$rows_output); |
$self->excel_rows($connection,$worksheet,$cols_output,$rows_output, |
|
$format); |
# |
# |
# |
# |
# Close the excel file |
# Close the excel file |