--- loncom/interface/statistics/lonproblemstatistics.pm 2005/03/08 17:40:39 1.100 +++ loncom/interface/statistics/lonproblemstatistics.pm 2005/03/10 17:33:57 1.101 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.100 2005/03/08 17:40:39 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.101 2005/03/10 17:33:57 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1264,30 +1264,13 @@ sub Excel_output { &compute_all_statistics($r); my $c = $r->connection; return if ($c->aborted()); + # + my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); ## ## Create the excel workbook - my $filename = '/prtspool/'. - $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. - time.'_'.rand(1000000000).'.xls'; - my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); - # - # Create sheet - my $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename); - # - # Check for errors - if (! defined($excel_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 0; - } - # - # 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. - $excel_workbook->set_tempdir($Apache::lonnet::tmpdir); + my ($excel_workbook,$filename,$format) = + &Apache::loncommon::create_workbook($r); + return if (! defined($excel_workbook)); # # Add a worksheet my $sheetname = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; @@ -1296,8 +1279,6 @@ sub Excel_output { } my $excel_sheet = $excel_workbook->addworksheet( &Apache::loncommon::clean_excel_name($sheetname)); - # - my $format = &Apache::loncommon::define_excel_formats($excel_workbook); ## ## Begin creating excel sheet ##