久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <tfoot id='EKd3N'></tfoot>
    • <bdo id='EKd3N'></bdo><ul id='EKd3N'></ul>
        <i id='EKd3N'><tr id='EKd3N'><dt id='EKd3N'><q id='EKd3N'><span id='EKd3N'><b id='EKd3N'><form id='EKd3N'><ins id='EKd3N'></ins><ul id='EKd3N'></ul><sub id='EKd3N'></sub></form><legend id='EKd3N'></legend><bdo id='EKd3N'><pre id='EKd3N'><center id='EKd3N'></center></pre></bdo></b><th id='EKd3N'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='EKd3N'><tfoot id='EKd3N'></tfoot><dl id='EKd3N'><fieldset id='EKd3N'></fieldset></dl></div>
      1. <legend id='EKd3N'><style id='EKd3N'><dir id='EKd3N'><q id='EKd3N'></q></dir></style></legend>
      2. <small id='EKd3N'></small><noframes id='EKd3N'>

        PHPExcel 閱讀器——需要幫助

        PHPExcel reader -- help required(PHPExcel 閱讀器——需要幫助)

      3. <tfoot id='apJ6t'></tfoot>

            <small id='apJ6t'></small><noframes id='apJ6t'>

            <legend id='apJ6t'><style id='apJ6t'><dir id='apJ6t'><q id='apJ6t'></q></dir></style></legend>

              <bdo id='apJ6t'></bdo><ul id='apJ6t'></ul>

                <tbody id='apJ6t'></tbody>
              1. <i id='apJ6t'><tr id='apJ6t'><dt id='apJ6t'><q id='apJ6t'><span id='apJ6t'><b id='apJ6t'><form id='apJ6t'><ins id='apJ6t'></ins><ul id='apJ6t'></ul><sub id='apJ6t'></sub></form><legend id='apJ6t'></legend><bdo id='apJ6t'><pre id='apJ6t'><center id='apJ6t'></center></pre></bdo></b><th id='apJ6t'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='apJ6t'><tfoot id='apJ6t'></tfoot><dl id='apJ6t'><fieldset id='apJ6t'></fieldset></dl></div>
                  本文介紹了PHPExcel 閱讀器——需要幫助的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在使用 PHPExcel 從 Excel 表中讀取數(shù)據(jù)并存儲在 mysql 表中,直到現(xiàn)在我能上傳 .xls 和 .xlsx 文件,上傳 xls 后,我得到了下面的數(shù)據(jù)表結(jié)構(gòu)

                  I m using PHPExcel to read data from Excel sheet and store in mysql table, till now i m able to upload .xls as well as .xlsx file and after uploading the xls i got below table structure of data

                  name    start_date              end_date               city
                  one 11/25/2011 3:30:00 PM   11/29/2011 4:40:00 AM   Jaipur
                  two 10/22/2011 5:30:00 PM   10/25/2011 6:30:00 AM   Kota
                  three  3/10/2011 2:30:00 PM 3/11/2011 12:30:00 AM   Bikaner
                                                                      chandigarh
                  

                  現(xiàn)在我遇到了一些問題,請建議我優(yōu)化的方法

                  now i have some problems, please suggest me the optimized method

                  1. 我們?nèi)绾潍@得工作表名稱(bcoz 在一個 excel 中有 7 個工作表)
                  2. 現(xiàn)在我如何存儲這些數(shù)據(jù)到db,下面是代碼片段

                  1. how do we get the sheet name ( bcoz in one excel there are 7 sheets )
                  2. for now what i do to store these data into db, below is the code snippet

                  $inputFileName = "test.xls";  
                  $inputFileType = PHPExcel_IOFactory::identify($inputFileName);  
                  $objReader = PHPExcel_IOFactory::createReader($inputFileType);  
                  $objReader->setReadDataOnly(true);  
                  /**  Load $inputFileName to a PHPExcel Object  **/  
                  $objPHPExcel = $objReader->load($inputFileName);  
                  $total_sheets=$objPHPExcel->getSheetCount(); // here 4  
                  $allSheetName=$objPHPExcel->getSheetNames(); // array ([0]=>'student',[1]=>'teacher',[2]=>'school',[3]=>'college')  
                  $objWorksheet = $objPHPExcel->setActiveSheetIndex(0); // first sheet  
                  $highestRow = $objWorksheet->getHighestRow(); // here 5  
                  $highestColumn = $objWorksheet->getHighestColumn(); // here 'E'  
                  $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);  // here 5  
                  for ($row = 1; $row <= $highestRow; ++$row) {  
                      for ($col = 0; $col <= $highestColumnIndex; ++$col) {  
                      $value=$objWorksheet->getCellByColumnAndRow($col, $row)->getValue();  
                          if(is_array($arr_data) ) { $arr_data[$row-1][$col]=$value; }  
                      }  
                  }
                  print_r($arr_data);
                  

                  然后返回

                  Array
                  (
                  [0] => Array
                      (
                          [0] => name
                          [1] => start_date
                          [2] => end_date
                          [3] => city
                          [4] =>         
                      )
                  
                  [1] => Array
                      (
                          [0] => one  
                          [1] => 40568.645833333
                          [2] => 40570.5
                          [3] => Jaipur
                          [4] => 
                      )
                  [2] => Array
                      (
                          [0] => two 
                          [1] => 40568.645833333
                          [2] => 40570.5
                          [3] => Kota
                          [4] => 
                      )
                  [3] => Array
                      (
                          [0] => three
                          [1] => 40568.645833333
                          [2] => 40570.5
                          [3] => Bikaner
                          [4] => 
                       )
                    [4] => Array
                      (
                          [0] => 
                          [1] => 
                          [2] => 
                          [3] => Chandigarh
                          [4] => 
                      )
                  
                  )
                  

                  我需要那個

                  • 每個excel表的標題(即第一行)成為數(shù)組的鍵($arr_data)和
                  • rest 成為數(shù)組的值.
                  • 時間變成了一些整數(shù)值,應(yīng)該和excel表中的一樣
                  • 應(yīng)截斷所有行中數(shù)組的空白字段(即空白標題列)(此處 [4] )
                  • 如果 Excel 表的第一個字段(或某些情況下的組合條件)字段)未滿足,則不應(yīng)將該行添加到數(shù)組中

                  即所需的數(shù)組應(yīng)該看起來像

                  i.e. desired array should look like

                  Array  
                      (  
                      [0] => Array  
                      (  
                        [name] => one  
                        [start_date] => 11/25/2011 3:30:00 PM  
                        [end_date] => 11/29/2011 4:40:00 AM  
                        [city] => Jaipur  
                      )  
                      [1] => Array  
                      (  
                        [name] => two  
                        [start_date] => 10/22/2011 5:30:00 PM  
                        [end_date] => 10/25/2011 6:30:00 AM  
                        [city] => Kota  
                      )  
                      [2] => Array  
                      (  
                        [name] => three  
                        [start_date] => 3/10/2011 2:30:00 PM  
                        [end_date] => 3/11/2011 12:30:00 AM  
                        [city] => Bikaner  
                      )  
                  )
                  

                  然后我在所需數(shù)組上使用 mysql 操作將數(shù)據(jù)存儲到我的數(shù)據(jù)庫中.

                  and after that i store data into my db using mysql action on desired array.

                  • 是否還有其他簡短的方法可以將上述數(shù)據(jù)存儲在 db 中

                  @Mark 感謝您的解決方案,它對我?guī)椭艽螅匀淮嬖谝恍﹩栴}

                  @Mark Thanks for your solution, it helps me a lot, but still some problems are there

                  • 如何處理excel表中的空/空白單元格..bcoz,當任何單元格為空時,它會顯示一個通知

                  注意:未定義索引:C in C:xampphtdocsxls_readerTestsexcel2007.php在線 60
                  注意:未定義索引:D in C:xampphtdocsxls_readerTestsexcel2007.php在線60

                  Notice: Undefined index: C in C:xampphtdocsxls_readerTestsexcel2007.php on line 60
                  Notice: Undefined index: D in C:xampphtdocsxls_readerTestsexcel2007.php on line 60

                  而第 60 行是

                  foreach($headingsArray as $columnKey => $columnHeading) { 
                      $namedDataArray[$r][$columnHeading] = $dataRow[$row]$columnKey];
                  }
                  

                  • 如何在檢索完整數(shù)據(jù)數(shù)組之前設(shè)置條件,即如果我希望第一列和第二列在任何行中為空/空白,則不應(yīng)將該行添加到我們想要的數(shù)組中
                  • 謝謝

                    推薦答案

                    我們?nèi)绾潍@得工作表名稱( bcoz in一個excel有7張)?

                    how do we get the sheet name ( bcoz in one excel there are 7 sheets )?

                    獲取當前活動的工作表:

                    To get the current active sheet:

                    $sheetName = $objPHPExcel->getActiveSheet()->getTitle();
                    

                    <塊引用>

                    時間變成了一些整數(shù)值,應(yīng)該和excel表一樣

                    查看 PHPExcel_Shared_Date::ExcelToPHP($excelDate) 或 PHPExcel_Shared_Date::ExcelToPHPObject($excelDate) 將日期/時間值轉(zhuǎn)換為 PHP 時間戳或 DateTime 對象

                    time changed into some integer value, that shoud be same as in excel sheet

                    查看 $objPHPExcel->getActiveSheet()->toArray() 方法,而不是自己遍歷所有 rwos 和列.但是,如果您想將 toArray 與格式化參數(shù)一起使用,請不要使用 $objReader->setReadDataOnly(true);否則 PHPExcel 無法區(qū)分數(shù)字和日期/時間.最新的 SVN 代碼在工作表對象中添加了 rangeToArray() 方法,該方法允許您一次讀取一行(或單元格塊),例如$objPHPExcel->getActiveSheet()->rangeToArray('A1:A4')

                    Look at PHPExcel_Shared_Date::ExcelToPHP($excelDate) or PHPExcel_Shared_Date::ExcelToPHPObject($excelDate) to convert the date/time values to a PHP timestamp or DateTime object

                    你的其余問題基本上都是 PHP 數(shù)組操作

                    Have a look at the $objPHPExcel->getActiveSheet()->toArray() method rather than looping through all the rwos and columns yourself. If you want to use toArray with the formatted argument though, don't use $objReader->setReadDataOnly(true); otherwise PHPExcel can't distinguish between a number and a date/time. The latest SVN code has added a rangeToArray() method to the worksheet object, which allows you to read a row (or block of cells) at a time, e.g. $objPHPExcel->getActiveSheet()->rangeToArray('A1:A4')

                    編輯

                    附注.不要只是告訴我們手冊真的非常糟糕...告訴我們?nèi)绾胃倪M它.

                    EDIT

                    編輯 2

                    使用最新的SVN代碼利用rangeToArray()方法:

                    EDIT 2

                    Using the latest SVN code to take advantage of the rangeToArray() method:
                    $objWorksheet = $objPHPExcel->setActiveSheetIndex(0);
                    $highestRow = $objWorksheet->getHighestRow();
                    $highestColumn = $objWorksheet->getHighestColumn();
                    
                    $headingsArray = $objWorksheet->rangeToArray('A1:'.$highestColumn.'1',null, true, true, true);
                    $headingsArray = $headingsArray[1];
                    
                    $r = -1;
                    $namedDataArray = array();
                    for ($row = 2; $row <= $highestRow; ++$row) {
                        $dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$highestColumn.$row,null, true, true, true);
                        if ((isset($dataRow[$row]['A'])) && ($dataRow[$row]['A'] > '')) {
                            ++$r;
                            foreach($headingsArray as $columnKey => $columnHeading) {
                                $namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
                            }
                        }
                    }
                    
                    echo '<pre>';
                    var_dump($namedDataArray);
                    echo '</pre><hr />';
                    

                    這篇關(guān)于PHPExcel 閱讀器——需要幫助的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                    【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  enable SOAP on PHP(在 PHP 上啟用 SOAP)
                  Get received XML from PHP SOAP Server(從 PHP SOAP 服務(wù)器獲取接收到的 XML)
                  not a valid AllXsd value(不是有效的 AllXsd 值)
                  PHP SoapClient: SoapFault exception Could not connect to host(PHP SoapClient:SoapFault 異常無法連接到主機)
                  Implementation of P_SHA1 algorithm in PHP(PHP中P_SHA1算法的實現(xiàn))
                  Sending a byte array from PHP to WCF(將字節(jié)數(shù)組從 PHP 發(fā)送到 WCF)
                    <bdo id='eYa3X'></bdo><ul id='eYa3X'></ul>
                      <tbody id='eYa3X'></tbody>
                        <tfoot id='eYa3X'></tfoot>
                        <i id='eYa3X'><tr id='eYa3X'><dt id='eYa3X'><q id='eYa3X'><span id='eYa3X'><b id='eYa3X'><form id='eYa3X'><ins id='eYa3X'></ins><ul id='eYa3X'></ul><sub id='eYa3X'></sub></form><legend id='eYa3X'></legend><bdo id='eYa3X'><pre id='eYa3X'><center id='eYa3X'></center></pre></bdo></b><th id='eYa3X'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='eYa3X'><tfoot id='eYa3X'></tfoot><dl id='eYa3X'><fieldset id='eYa3X'></fieldset></dl></div>
                        • <legend id='eYa3X'><style id='eYa3X'><dir id='eYa3X'><q id='eYa3X'></q></dir></style></legend>
                          1. <small id='eYa3X'></small><noframes id='eYa3X'>

                            主站蜘蛛池模板: 超碰精品在线观看 | 蜜臀av日日欢夜夜爽一区 | 精品一区久久 | 欧美日韩国产一区二区三区 | 欧美视频免费在线观看 | 欧美成人一区二区三区 | 一级毛片,一级毛片 | 亚洲综合一区二区三区 | 黄色毛片在线播放 | 国产精品久久久久久一区二区三区 | 国产在线一区二区三区 | 日韩精品久久 | 毛片韩国| a中文在线视频 | 国产一区二区三区久久久久久久久 | 色天堂视频 | 亚洲美女一区 | 国产一级视频 | 国产一区二区在线观看视频 | 久久久www成人免费无遮挡大片 | av免费网站在线观看 | 欧美国产一区二区三区 | 黄色精品 | 成人精品在线视频 | 日韩在线观看中文字幕 | 国产色婷婷精品综合在线播放 | 国产黑丝av | 欧一区| 成人精品国产 | 国产精品视频免费观看 | 天堂视频中文在线 | 夜夜夜久久久 | 日本国产欧美 | 欧美一级一区 | 男女啪啪高潮无遮挡免费动态 | 在线免费观看黄视频 | 在线欧美亚洲 | 欧美日韩在线免费观看 | 在线视频日韩 | 在线看片福利 | 中文字幕日韩欧美 |