phpexcel生成excel無法讀取

2021-12-27 08:59:23 字數 3045 閱讀 8752

1樓:匿名使用者

方法三: phpexcel 類庫,功能強大,支援win excel2003 ,win excel2007.

//設定phpexcel類庫的include path

set_include_path('.'. path_separator .

'd:\zeal\php_libs' . path_separator .

get_include_path());

/*** 以下是使用示例,對於以 //// 開頭的行是不同的可選方式,請根據實際需要

* 開啟對應行的註釋。

* 如果使用 excel5 ,輸出的內容應該是gbk編碼。

// uncomment

用於其他低版本xls

// or

用於 excel-2007 格式

// 建立一個處理物件例項

$objexcel = new phpexcel();

// 建立檔案格式寫入物件例項, uncomment

////$objwriter = new phpexcel_writer_excel5($objexcel); // 用於其他版本格式

// or

////$objwriter = new phpexcel_writer_excel2007($objexcel); // 用於 2007 格式

//$objwriter->setoffice2003compatibility(true);

//*************************************

//設定文件基本屬性

$objprops = $objexcel->getproperties();

$objprops->setcreator("zeal li");

$objprops->setlastmodifiedby("zeal li");

$objprops->settitle("office xls test document");

$objprops->setsubject("office xls test document, demo");

$objprops->setdescription("test document, generated by phpexcel.");

$objprops->setkeywords("office excel phpexcel");

$objprops->setcategory("test");

//*************************************

//設定當前的sheet索引,用於後續的內容操作。

//一般只有在使用多個sheet的時候才需要顯示呼叫。

//預設情況下,phpexcel會自動建立第一個sheet被設定sheetindex=0

$objexcel->setactivesheetindex(0);

$objactsheet = $objexcel->getactivesheet();

//設定當前活動sheet的名稱

$objactsheet->settitle('測試sheet');

//*************************************

//設定單元格內容

////由phpexcel根據傳入內容自動判斷單元格內容型別

$objactsheet->setcellvalue('a1', '字串內容'); // 字串內容

$objactsheet->setcellvalue('a2', 26); // 數值

$objactsheet->setcellvalue('a3', true); // 布林值

$objactsheet->setcellvalue('a4', '=sum(a2:a2)'); // 公式

//顯式指定內容型別

$objactsheet->setcellvalueexplicit('a5', '847475847857487584',

phpexcel_cell_datatype::type_string);

//合併單元格

$objactsheet->mergecells('b1:c22');

//分離單元格

$objactsheet->unmergecells('b1:c22');

//*************************************

//設定單元格樣式

////設定寬度

$objactsheet->getcolumndimension('b')->setautosize(true);

$objactsheet->getcolumndimension('a')->setwidth(30);

$objstylea5 = $objactsheet->getstyle('a5');

//設定單元格內容的數字格式。

////如果使用了 phpexcel_writer_excel5 來生成內容的話,

//這裡需要注意,在 phpexcel_style_numberformat 類的 const 變數定義的

//各種自定義格式化方式中,其它型別都可以正常使用,但當setformatcode

//為 format_number 的時候,實際出來的效果被沒有把格式設定為"0"。需要

//修改 phpexcel_writer_excel5_format 類源**中的 getxf($style) 方法,

//在 if ($this->_biff_version == 0x0500) { (第363行附近)前面增加一

2樓:朦朧彩紗

是不是配置存在風險,電腦中裝了保險裝置,所以無法正常讀取excel。

我用phpexcel匯出excel,結果單元格里漢字正常標題漢字就不顯示了我設定的utf8編碼

header content type text html charset utf 8 con mysql connect 192.168.80.1 root mysql select db db mysql query set names utf8 objexcel new phpexcel ob...

excel自動生成報價,excel自動生成銷售報價單

1.加上d列 金額 在d2設公式 d2 b2 c2,然後往下複製 2.再加一欄e列 可定義為 識別欄 在e列設公公式 e2 if c 0,然後往下複製 這個公式是表示,只要你在 數量 c列 輸入客戶所需數量,即在相對應的e列位置做記號 3.在d列即金額欄的最下方設加總公式,假設你的產品有100種,則...

excel怎麼生成隨機數,excel怎麼生成6位隨機數?

1全部生成隨機數的方法 首先介紹一下如何用rand 函式來生成隨機數 同時返回多個值時是不重複的 如下圖所示,在單元格中輸入 rand 回車後單元格即返回了一個隨機數字。rand 函式返回的隨機數字的範圍是大於0小於1。因此,也可以用它做基礎來生成給定範圍內的隨機數字。生成制定範圍的隨機數方法是這樣...