php 將excel匯入MySQL 資料庫後,怎麼使得它以文本形式顯示

來源:互聯網
上載者:User
php 將excel匯入MySQL 資料庫後,如何使得它以文本形式顯示
php 將excel匯入MySQL 資料庫後,如何使得它以文本形式顯示
比如excel裡面是 9787509345030
匯入資料庫之後變成了 9.78750934503E+12
php去讀資料庫的資料,發現也是9.78750934503E+12
好惱火,求助,心情很複雜。
它好像是數值型的了,我明明是
$number= implode('',explode('-',$data->sheets[0]['cells'][$i][1]));
$number = strval($number);
把它搞成字串型了,為啥米還是數值型????
------解決思路----------------------
你的 9787509345030 在 excel 不是以字串形式儲存的('9787509345030),而是以樣式表方式修飾的(不然也是科學計數法表示)
你可以嘗試使用 getFormattedValue 方法讀取,而不是 getValue 方法讀取

你的 $data->sheets[0]['cells'][$i][1] 是有問題的
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.