--- loncom/interface/loncommon.pm 2005/02/25 05:54:01 1.252
+++ loncom/interface/loncommon.pm 2005/03/10 00:21:48 1.255
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.252 2005/02/25 05:54:01 albertel Exp $
+# $Id: loncommon.pm,v 1.255 2005/03/10 00:21:48 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -547,7 +547,7 @@ END
$result .= "\n";
@@ -557,7 +557,7 @@ END
my $seconddefault = $hashref->{$firstdefault}->{'default'};
foreach my $value (sort(keys(%select2))) {
$result.=" \n";
}
$result .= "\n";
@@ -691,7 +691,8 @@ sub help_open_menu {
my $helpicon=&lonhttpdurl("/adm/lonIcons/helpgateway.gif");
$template .= <<"ENDTEMPLATE";
@@ -895,6 +897,7 @@ sub define_excel_formats {
$format->{'h1'} = $workbook->add_format(bold=>1, size=>18);
$format->{'h2'} = $workbook->add_format(bold=>1, size=>16);
$format->{'h3'} = $workbook->add_format(bold=>1, size=>14);
+ $format->{'h4'} = $workbook->add_format(bold=>1, size=>12);
$format->{'i'} = $workbook->add_format(italic=>1);
$format->{'date'} = $workbook->add_format(num_format=>
'mm/dd/yyyy hh:mm:ss');
@@ -906,6 +909,49 @@ sub define_excel_formats {
=pod
+=item &create_workbook
+
+Create an Excel worksheet. If it fails, output message on the
+request object and return undefs.
+
+Inputs: Apache request object
+
+Returns (undef) on failure,
+ Excel worksheet object, scalar with filename, and formats
+ from &Apache::loncommon::define_excel_formats on success
+
+=cut
+
+###############################################################
+###############################################################
+sub create_workbook {
+ my ($r) = @_;
+ #
+ # Create the excel spreadsheet
+ 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("Unable to create new Excel file. ". + "This error has been logged. ". + "Please alert your LON-CAPA administrator"). + '
'); + return (undef); + } + # + $workbook->set_tempdir('/home/httpd/perl/tmp'); + # + my $format = &Apache::loncommon::define_excel_formats($workbook); + return ($workbook,$filename,$format); +} + +############################################################### +############################################################### + +=pod + =item * change_content_javascript(): This and the next function allow you to create small sections of an @@ -1045,7 +1091,7 @@ sub multiple_select_form { $output.="\n\n"; @@ -1076,7 +1122,7 @@ sub select_form { } foreach (@keys) { $selectform.="\n"; } $selectform.=""; @@ -1113,7 +1159,7 @@ sub select_level_form { my $selectform = ""; @@ -1143,7 +1189,7 @@ sub select_dom_form { my $selectdomain = ""; @@ -2353,7 +2399,7 @@ sub submlink { &Apache::lonxml::whichuser($symb); if (!$symb) { $symb=$cursymb; } } - if (!$symb) { $symb=&symbread(); } + if (!$symb) { $symb=&Apache::lonnet::symbread(); } $symb=&Apache::lonnet::escape($symb); if ($target) { $target="target=\"$target\""; } return ''); foreach (sort({$a <=> $b} keys(%sone))) { $r->print(''); } $r->print(''."\n"); @@ -3354,7 +3401,7 @@ sub csv_samples_select_table { foreach (@$d) { my ($value,$display,$defaultcol)=@{ $_ }; $r->print(''); } $r->print('