Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:19:49+00:00 2026-05-29T06:19:49+00:00

I’m having this problem when I tried to extract information from excel files. Here’s

  • 0

I’m having this problem when I tried to extract information from excel files. Here’s my situation, I have 34 Excel files which I received from my various users.

I’m using PHP version 5 to extract from the Excel files. My script will loop for every files, and looping again according to sheet name, and lastly looping again according to cell addresses.

The problem arised when the users had entered into a cell for e.g. =+A1 which means the users referencing the cell value to another cell due to it has the same value with cell A1.

When I checked in mysql (as I saved those for future use) I found from the record for a particular cell is identical with another record obtained from the same cell but in different excel file. What I meant is that, as my php script will loop from one file to another file, the first time PHPExcel read for e.g cell C3 which has some value USD3,000.00 the next files the PHPExcel may go to the same cell C3 but this time the C3 cell contain a formula that referencing to cell A1 (“=+A1” formula)which has value USD5,000.00.

PHP script suppose to record in mysql for USD5,000.00 but it didn’t. I suspect that the PHPExcel script did not clear the variable at first round. I’ve tried unset($objPHPExcel) and destroy the variable but it still happening.

My coding is simple as follows:

if(file_exists($inputFileName))
                                    {
                                        $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
                                        $objReader = PHPExcel_IOFactory::createReader($inputFileType);
                                        $objReader->setReadDataOnly(true);
                                        $objPHPExcel = $objReader->load($inputFileName);

                                        //to obtain date from FILE and store in DB for future comparison
                                        $validating_date_reporting = $objPHPExcel->getSheet(0)->getCell('C10')->getValue();
                                        $validating_date_reporting = PHPExcel_Style_NumberFormat::toFormattedString($validating_date_reporting,"YYYY-MMM-DD");
                                        $validating_date_reporting = date('Y-m-d',strtotime($validating_date_reporting));

                                        //first entry
                                        $entry = mysql_query('INSERT INTO `'.$table.'`(`broker_code`, `date`, `date_from_submission`) VALUES("'.$broker_code.'","'.$reporting_date.'","'.$reporting_date.'")') or die(mysql_error());

                                        foreach($cells_array as $caRef=>$sName)
                                        {
                                            foreach($sName as $sNameRef=>$cells)
                                                {

                                                    $wksht_page = array_search($caRef, $sheetNameArray);
                                                    $cell_column = $wksht_page.'_'.$cells;
                                                    echo $inputFileName.' '.$caRef.' '.$cell_column.'<br>';
                                                    $value = $objPHPExcel->setActiveSheetIndexByName($caRef)->getCell($cells)->getCalculatedValue();

                                                    echo $value.'<br>';

                                                        if($value)
                                                        {
                                                            $isdPortal->LoginDB($db_periodic_submission);
                                                            $record = mysql_query('UPDATE `'.$table.'` SET `'.$cell_column.'` = "'.$value.'" WHERE broker_code = "'.$broker_code.'" AND date_from_submission = "'.$validating_date_reporting.'"') or die(mysql_error());

                                                        }

                                                }

                                        }


                                    }

I really hope that you can help me out here..

thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:19:50+00:00Added an answer on May 29, 2026 at 6:19 am

    PHPExcel holds a calculation cache as well, and this is not cleared when you unset a workbook: it has to be cleared manually using:

    PHPExcel_Calculation::flushInstance();
    

    or

    PHPExcel_Calculation::getInstance()->clearCalculationCache();
    

    You can also disable calculation caching completely (although this may slow things down if you have a lot of formulae that reference cells containing other formulae) using:

    PHPExcel_Calculation::getInstance()->setCalculationCacheEnabled(FALSE);
    

    before you start processing your files

    This is because currently PHPExcel uses a singleton for the calculation engine. It is in the roadmap to switch to using a multiton pattern later this year, which will effectively maintain a separate cache for each workbook, alleviating this problem.

    EDIT

    Note that simply unsetting $objPHPExcel does not work. You need to detach the worksheets before unsetting $objPHPExcel.

    $objPHPExcel->disconnectWorksheets();
    unset($objPHPExcel);
    

    as described in section 4.3 of the Developer Documentation. And this is the point where you should also add the PHPExcel_Calculation::flushInstance();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.