php - how to get cell data with special characters from xlsx reader -


i using simplexlsx php class reading data xlsx file , importing database.

i facing 1 issue have not found after google also, issue having values in xlsx column 100%, $300 library parsing data , give output this: 1, 300 - evaluating values , removing symbols.

excel file: enter image description here

after parsing library output is:

[10] => simplexmlelement object         (           [v] => 5         ) [11] => simplexmlelement object         (           [v] => 1.2         ) [12] => simplexmlelement object         (           [v] => 1.1000000000000001         ) [13] => simplexmlelement object         (           [v] => 1         ) 

and expected out should this:

[10] => simplexmlelement object             (               [v] => 2.5%             )     [11] => simplexmlelement object             (               [v] => 2%             )     [12] => simplexmlelement object             (               [v] => 1.50%             )     [13] => simplexmlelement object             (               [v] => 1%             ) 

here class link using: http://www.phpclasses.org/package/6279-php-parse-and-retrieve-data-from-excel-xls-files.html

also available on git older version: https://github.com/raulferras/simplexlsx

here file parsing function, above output getting echo statement see in below function under $sheet parse condition:

function _parse() {         // document data holders         $this->sharedstrings = array();         $this->sheets = array(); //      $this->styles = array();          // read relations , search officedocument         if ( $relations = $this->getentryxml("_rels/.rels" ) ) {              foreach ($relations->relationship $rel) {                  if ($rel["type"] == simplexlsx::schema_rel_officedocument) {  //                      echo 'workbook found<br />';                     // found office document! read workbook & relations...                      // workbook                     if ( $this->workbook = $this->getentryxml( $rel['target'] )) {  //                      echo 'workbook read<br />';                          if ( $workbookrelations = $this->getentryxml( dirname($rel['target']) . '/_rels/workbook.xml.rels' )) {  //                          echo 'workbook relations<br />';                              // loop relations workbook , extract sheets...                             foreach ($workbookrelations->relationship $workbookrelation) {                                  $path = dirname($rel['target']) . '/' . $workbookrelation['target'];                                  if ($workbookrelation['type'] == simplexlsx::schema_rel_worksheet) { // sheets  //                                  echo 'sheet<br />';                                      if ( $sheet = $this->getentryxml( $path ) ) {                                         $this->sheets[ str_replace( 'rid', '', (string) $workbookrelation['id']) ] = $sheet;                                         echo '<pre>'.htmlspecialchars( print_r( $sheet, true ) ).'</pre>';                                     }                                  } else if ($workbookrelation['type'] == simplexlsx::schema_rel_sharedstrings && $this->entryexists( $path )) { // 0.6.6  //                                  echo 'sharedstrings<br />';                                      if ( $sharedstrings = $this->getentryxml( $path ) ) {                                         foreach ($sharedstrings->si $val) {                                             if (isset($val->t)) {                                                 $this->sharedstrings[] = (string)$val->t;                                             } elseif (isset($val->r)) {                                                 $this->sharedstrings[] = $this->_parserichtext($val);                                             }                                         }                                     }                                 } else if ($workbookrelation['type'] == simplexlsx::schema_rel_styles) {                                     $this->styles = $this->getentryxml( $path );                                      $nf = array();                                     if ( $this->styles->numfmts->numfmt != null )                                         foreach( $this->styles->numfmts->numfmt $v )                                             $nf[ (int) $v['numfmtid'] ] = (string) $v['formatcode'];                                      if ( $this->styles->cellxfs->xf != null )                                            foreach( $this->styles->cellxfs->xf $v ) {                                             $v = (array) $v->attributes();                                             $v = $v['@attributes'];                                             if (isset($this->built_in_cell_formats[ $v['numfmtid'] ]) )                                                 $v['format'] = $this->built_in_cell_formats[ $v['numfmtid'] ];                                              else if (isset($nf[ $v['numfmtid'] ]))                                                 $v['format'] = $nf[ $v['numfmtid'] ];                                             else                                                 $v['format'] = '';                                             $this->workbook_cell_formats[] = $v;                                         }                                         //print_r( $this->workbook_cell_formats ); exit;                                  }                             }                              break;                         }                     }                 }             }         }          // sort sheets         ksort($this->sheets);     } 

any appreciated. in advance.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -