當前位置:首頁 » 辦公資訊 » 怎樣使用excel

怎樣使用excel

發布時間: 2022-01-20 00:18:32

excel裡面@怎麼使用

  1. @用於定義的表,你直接寫@,並沒有引用具體的表,所以是錯的。

  2. 定義的表如下圖所示:

❷ 怎樣用excel

excel表格導入mysql資料庫 第一步:建立資料庫和數據表(按照自己的Excel數據設立欄位)。
[sql] view plain print?
CREATE DATABASE php_excel;
USE php_excel;
CREATE TABLE IF NOT EXISTS php_excel(
id int(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
gid varchar(20) NOT NULL,
stu_no varchar(20) NOT NULL,
name varchar(45) NOT NULL,
age int(4) NOT NULL
)ENGINE=MyISAM DEFAULT CHARSET=utf8;

第二步:前台index.php文件。
[html] view plain print?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phpexcel導入excel數據到MYSQL資料庫</title>
</head>

<body>
<form name="frm1" action="insertdb.php" method="post" enctype="multipart/form-data">
<input name="filename" type="file" />
<input name="submit" type="submit" value="import" />
</form>
</body>
</html>

第三步:向資料庫插入數據的insertdb.php文件。
[php] view plain print?
session_start();
header("Content-type:text/html;charset:utf-8");
//全局變數

$succ_result=0;
$error_result=0;
$file=$_FILES['filename'];
$max_size="2000000"; //最大文件限制(單位:byte)
$fname=$file['name'];
$ftype=strtolower(substr(strrchr($fname,'.'),1));
//文件格式
$uploadfile=$file['tmp_name'];
if($_SERVER['REQUEST_METHOD']=='POST'){
if(is_uploaded_file($uploadfile)){
if($file['size']>$max_size){
echo "Import file is too large";
exit;
}
if($ftype!='xls'){
echo "Import file type is error";
exit;
}
}else{
echo "The file is not empty!";
exit;
}
}
require("./conn.php"); //連接mysql資料庫

//調用phpexcel類庫
require_once 'PHPExcel.php';
require_once 'PHPExcel\IOFactory.php';
require_once 'PHPExcel\Reader\Excel5.php';

$objReader = PHPExcel_IOFactory::createReader('Excel5');//use excel2007 for 2007 format
$objPHPExcel = $objReader->load($uploadfile);
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow(); // 取得總行數
$highestColumn = $sheet->getHighestColumn(); // 取得總列數
$arr_result=array();
$strs=array();

for($j=2;$j<=$highestRow;$j++)
{
unset($arr_result);
unset($strs);
for($k='A';$k<= $highestColumn;$k++)
{
//讀取單元格
$arr_result .= $objPHPExcel->getActiveSheet()->getCell("$k$j")->getValue().',';
}
$strs=explode(",",$arr_result);
$sql="insert into php_excel(gid,stu_no,name,age) values ($strs[0],'$strs[1]','$strs[2]',$strs[3])";
echo $sql."<br/>";
mysql_query("set names utf8");
$result=mysql_query($sql) or die("執行錯誤");

$insert_num=mysql_affected_rows();
if($insert_num>0){
$succ_result+=1;
}else{
$error_result+=1;
}

}
echo "插入成功".$succ_result."條數據!!!<br>";
echo "插入失敗".$error_result."條數據!!!";

其中conn.php代碼如下:
[php] view plain print?
$mysql=mysql_connect("localhost","root","") or die("資料庫連接失敗!");
mysql_select_db("php_excel",$mysql);
mysql_query("set names utf8");

我的導入效果如下:
至此,從Excel文件讀取數據批量導入到Mysql資料庫完成。

❸ 怎樣使用Excel電子表格。。。。。。。。。。。。。。


1,按保存後,就不能撤銷

2,點「文件」菜單-「頁面設置」-「工作表」選項卡
定位到「頂端標題行」,點後面的小按鈕
然後選擇標題行
即可

熱點內容
馬路上汽車的噪音在多少分貝 發布:2023-08-31 22:08:23 瀏覽:1765
應孕棒多少錢一盒 發布:2023-08-31 22:08:21 瀏覽:1255
標准養老金一年能領多少錢 發布:2023-08-31 22:05:05 瀏覽:1541
湖北通城接網線多少錢一個月 發布:2023-08-31 21:59:51 瀏覽:1620
開隨車吊車多少錢一個月 發布:2023-08-31 21:55:06 瀏覽:1381
京東付尾款怎麼知道前多少名 發布:2023-08-31 21:52:58 瀏覽:1702
在學校租鋪面一個月要多少錢 發布:2023-08-31 21:52:09 瀏覽:1837
2寸有多少厘米 發布:2023-08-31 21:50:34 瀏覽:1475
知道電壓如何算一小時多少電 發布:2023-08-31 21:46:20 瀏覽:1461
金手鐲54號圈周長是多少厘米 發布:2023-08-31 21:44:28 瀏覽:1634