Advertisement

07.10.2008 at 03:33AM PDT, ID: 23553194
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Bad Excel file generated by PEAR::Spreadsheet_Excel_Writer only on one file

Asked by MichealECooper in PHP Scripting Language, Microsoft Excel Spreadsheet Software

Tags:

I am writing a script that generates an Excel report for download, and I have one test script and one previous Excel report generator on the same server using the same database, but the new script is not working. I can download the Excel file, but when I try to open it, it says that I cannot. Then when I choose the option of Excel repairing the file, I get the data that I put into it, but there is also a message in a box that reads, "Microsoft Office Excel was able to open the file by making the repairs listed below":
"Damage to the file was so extensive that repairs were not possible. Excel attempted to recover your formulas and values, but some data may have been lost or corrupted."

The log file reads:
Microsoft Office Excel File Repair Log

Errors were detected in file 'C:\Documents and Settings\micadmin\My Documents\FacProfile_20080710_AdachiJason.xls'
The following is a list of repairs:

Damage to the file was so extensive that repairs were not possible. Excel attempted to recover your formulas and values, but some data may have been lost or corrupted.

My other scripts work just fine, and I cannot find a difference. The data is in the spreadsheets, but I cannot turn this over to my users.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
<?php
/*
    Uses classes Instructor and InstructorProfile to create Excel files containing
    one instructor profile per sheet.
*/
 
require_once("../ERW.php");
ERW::init();
ERW::checkBrowser();
ERW::localise();
if (!isset($_ERW_db)) ERW::connect();
ERW::checkValidUser();
 
require_once("Instructor.class.php");
require_once("InstructorProfile.class.php");
require_once("Spreadsheet/Excel/Writer.php");
 
$bktitle='FacProfile_'.date('Ymd');     //filename (without suffix)
$instrlist=array();
$instrid=$_REQUEST['instrid'];
 
function MakeSheet(&$workbook,$profile)
{
    global $_ERW_userId, $D;
    
    //Get personal info from the InstructorProfile instance.
    $pinfo=$profile->i->GetPersonalInfo();
    $instrid=$pinfo["id"];
    $wkstitle=$pinfo["familynameen"]."_".$pinfo["givennameen"];
    
    //Create the worksheet and establish variables for navigation.
    {
        $worksheet =& $workbook->addWorksheet($wkstitle);
        $worksheet->setHeader($wkstitle);
        $worksheet->setMargins(0.5);
        $worksheet->fitToPages(1,1);
        $worksheet->write(0,0,'test');//MECDEBUG
    }
}
 
function MakeBook($instrlist,$bktitle)
{
    global $_ERW_userId, $D;
    
    //Start the book and set things up.
    $workbook = new Spreadsheet_Excel_Writer();
 
    foreach($instrlist as $instrid)
    {
        //Make a sheet for each instructor from the ilist
        $profile=new InstructorProfile($instrid);
        MakeSheet($workbook,$profile);
    }
 
    // Send HTTP headers.
    $workbook->send($bktitle.".xls");
    // Close the file, and by doing so, send it.
    $workbook->close();
}
 
if(is_null($instrid))
{
    if(user_in_grp($_ERW_userId, array(1,2,4,6,9)))
    {
        //Loop through the set of current faculty members to make list.
        $q="select i.id from instructors i
            inner join employees e on (i.id=e.id)
            inner join people p on (i.id=p.id)
            where e.departdate is null order by p.familynameen, p.givennameen;";
        $rs=ERW::query($q);
        while($r=$rs->fetchRow(DB_FETCHMODE_ORDERED))
        {
            $instrlist[]=$r[0];
        }
        MakeBook($instrlist,$bktitle);
    }
    else
    {
        die('You are not authorized to view all faculty profiles. Yáhá×íÕ¡¤ën¢¯»¹o1ïU_fD~[“');
    }
}
else //if instrid is specified, then make sure it is user's own or a privileged user
{
    if(user_in_grp($_ERW_userId, array(1,2,4,6,9)) || $_ERW_userId==$instrid)
    {
        $instrlist[]=$instrid;
        //Get data about instructor for filename.
        $profile=new InstructorProfile($instrid);
        $pinfo=$profile->i->GetPersonalInfo();
        $bktitle.="_".$pinfo['familynameen'].$pinfo['givennameen'];
        MakeBook($instrlist,$bktitle);
    }
    else
    {
        die('You are not authorized to view this faculty profile. SnYá×íÕ¡¤ën¢¯»¹o1ïU_fD~[“');
    }
}
 
?>
[+][-]07.10.2008 at 07:02AM PDT, ID: 21973473

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 08:38AM PDT, ID: 21974472

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Microsoft Excel Spreadsheet Software
Tags: PHP4
Sign Up Now!
Solution Provided By: bportlock
Participating Experts: 2
Solution Grade: B
 
 
[+][-]07.10.2008 at 01:02PM PDT, ID: 21976861

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 02:34PM PDT, ID: 21977598

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 02:38PM PDT, ID: 21977617

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 02:59PM PDT, ID: 21977749

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 07:47PM PDT, ID: 21979586

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.12.2008 at 12:09AM PDT, ID: 21987999

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.12.2008 at 12:12AM PDT, ID: 21988003

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.13.2008 at 09:40PM PDT, ID: 21995673

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 01:55AM PDT, ID: 22005115

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 04:46AM PDT, ID: 22005913

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.15.2008 at 05:13AM PDT, ID: 22006075

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628