phpexcel 字串轉碼

2021-09-09 01:59:58 字數 2064 閱讀 8178

問題狀況:在匯入excel的時候會出現

phpexcel_richtext object ( [_richtextelements:phpexcel_richtext:private] => array ( [0] => phpexcel_richtext_run object ( [_font:phpexcel_richtext_run:private] => phpexcel_style_font object ( [_name:protected] => 細明體 [_size:protected] => 12 [_bold:protected] => [_italic:protected] => [_superscript:protected] => [_subscript:protected] => [_underline:protected] => none [_strikethrough:protected] => [_color:protected] => phpexcel_style_color object ( [_argb:protected] => ff000000 [_parentpropertyname:protected] => [_issupervisor:protected] => [_parent:protected] => ) [_issupervisor:protected] => [_parent:protected] => [colorindex] => 8 ) [_text:phpexcel_richtext_textelement:private] => 蜜糖皇后暖色胭脂 ) [1] => phpexcel_richtext_run object ( [_font:phpexcel_richtext_run:private] => phpexcel_style_font object ( [_name:protected] => calibri [_size:protected] => 12 [_bold:protected] => [_italic:protected] => [_superscript:protected] => [_subscript:protected] => [_underline:protected] => none [_strikethrough:protected] => [_color:protected] => phpexcel_style_color object ( [_argb:protected] => ff000000 [_parentpropertyname:protected] => [_issupervisor:protected] => [_parent:protected] => ) [_issupervisor:protected] => [_parent:protected] => [colorindex] => 8 ) [_text:phpexcel_richtext_textelement:private] => the honey queen honeycomb blusher ) ) )

解決辦法

import("

org.util.phpexcel

"); //

這裡不能漏掉

import("

org.util.phpexcel.iofactory");

$objreader = \phpexcel_iofactory::createreader('

excel5');

$objphpexcel = $objreader->load($file_name,$encode='

utf-8');

/****** 上面的**可以不用看,下面的才是處理的重點 *****

*///

獲取excel c2的文字

$cell = $objphpexcel->getactivesheet()->getcell('

c2')->getvalue(); //

開始格式化

if(is_object($cell)) $cell= $cell->__tostring();

事例參考 $file_name=「***.xls」

public

function excel($file_name)

return

$data;

}

java web開發中如何將字串轉碼

我們在web應用開發過程中經常遇到輸出某種編碼的字元,如iso8859 1等,如何輸出乙個某種編碼的字串?我們主要是通過string物件的getbyte iso 8859 1 utf 8 方法,其中第乙個引數是原始型別,第二個引數是我們要轉成的編碼型別 public string translate...

過濾危險字元,字元轉碼,處理字串中的空值

public class chstr else catch exception e return strvalue 返回轉換後的輸 入變數strvalue 處理字串中的空值 public static final string nulltostring string v,string tov ret...

ORACLE in 字串,字串,字串

因為傳進來的引數是 字串,字串,字串,要實現in 字串,字串,字串 select from htl price p where p.hotel id 30073328 and p.able sale date between to date 2009 03 27 yyyy mm dd and to ...