<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>¹«Á¦ ¹®¼</title>
</head>
<body>
<?php
require_once "Comn/reader.php";
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding("UTF-8//IGNORE");
$data->read("sample_excel.xls");
for ($i = 2; $i <= $data->sheets[0]["numRows"]; $i++) {
$my_name = $data->sheets[0]["cells"][$i][1];
$my_age = $data->sheets[0]["cells"][$i][2];
$my_gender = $data->sheets[0]["cells"][$i][3];
$my_phone = $data->sheets[0]["cells"][$i][4];
$query = "insert into my_user (my_name,my_age,my_gender,my_phone) values ('{$my_name}','{$my_age}','{$my_gender}','{$my_phone}') ";
}
?>
</body>
</html>
ÀüüÀûÀÎ ¼Ò½º´Â À§¿Í µ¿ÀÏÇÏ´Ù . ±×·³ ÇϳªÇϳª ¶â¾î º¸µµ·Ï ÇÏÀÚ.
1. DB ¿¬µ¿ ..
$conn = mysql_connect("", "", "");
$mysql = mysql_select_db("", $conn);
mysql_query("set names utf8");
2.PHP ¶óÀ̺귯¸® ·Îµå.
require_once "Comn/reader.php";
3.¶óÀ̺귯¸®¿¡ Á¤ÀÇ µÇ¾î ÀÖ´Â °´Ã¼ ÇÔ¼ö¸¦ ÀÌ¿ëÇÑ Ãʱ⠼ÂÆÃ.
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding("UTF-8//IGNORE");
$data->read("sample_excel.xls");
ºÎ¿¬ ¼³¸íÀ» ÇÏÀÚ¸é ¹Ýµå½Ã OUTPUTENcodingÀÌ readº¸´Ù ¾Õ¼ ³ª¿Í¾ß ÇÑ´Ù.
±×¸®°í read¿¡ Á¤ÀÇµÈ ¿¢¼¿ ÆÄÀÏÀº ¹Ýµå½Ã ¼¹ö¿¡ ¿Ã·ÁÁ® ÀÖ¾î¾ß ÇÑ´Ù.
4. DB¿¡ ÀÚ·á ÀúÀåÇϱâ
for ($i = 2; $i <= $data->sheets[0]["numRows"]; $i++) {$my_name = $data->sheets[0]["cells"][$i][1];$my_age = $data->sheets[0]["cells"][$i][2];$my_gender = $data->sheets[0]["cells"][$i][3];$my_phone = $data->sheets[0]["cells"][$i][4];$query = "insert into my_user (my_name,my_age,my_gender,my_phone) values ('{$my_name}','{$my_age}','{$my_gender}','{$my_phone}') ";$result = mysql_query($query, $conn);}
$data->sheets[0]["numRows"]; ´Â ¿¢¼¿ ½ÃÆ®ÀÇ ÇàÀÇ °¹¼ö¸¦ ¹ÝȯÇØ ÁØ´Ù.
°°ÀÌ Ã·ºÎ ÇØ ³õÀº ¿¢¼¿À» º¸¸é ¾Ë°ÚÁö¸¸, ³»°¡ »ùÇ÷Π¸¸µé¾î ³õÀº ¿¢¼¿Àº 3Çà 4¿ÀÌ´Ù.
for ($i = 2; .. ¿¡¼ ¿Ö $i°¡ 2·Î ½ÃÀÛÀ» Ç߳ĸé,
1·Î ½ÃÀÛÀ» Çϸé À̸§ ³ªÀÌ ¼ºº° Æù¹øÈ£ .. ¶ó´Â ¼ÒºÐ·ù ±ÛÀÚ±îÁö Àоî¹ö¸®±â ¶§¹®ÀÌ´Ù.
(¹«½¼ ¸»ÀÎÁö ¸ð¸£¸é ÷ºÎµÈ ¿¢¼¿ open open)
±×·¡¼ 2ºÎÅÍ ½ÃÀÛÇÏ¿©, ¸Ç ù¹ø° ÁÙÀ» Á¦¿ÜÇÏ°í DB¿¡ ÀúÀå½ÃÅ°´Â °ÍÀÌ´Ù.
±× ¹Ø¿¡
´Â °ªÀÌ Á¦´ë·Î ÇÒ´ç µÇ´ÂÁö Âï¾îº¸·Á°í echo ÇÑ°ÍÀÌ°í,
¸ðµç ÀÛ¾÷ÀÌ ³¡³ª¸é '¹Ýµå½Ã' DB¸¦ Ŭ·ÎÁî ÇØÁÖ¾î¾ß ÇÑ´Ù.
Comm/reader.php ´Â ¾Æ·¡ »çÀÌÆ®¿¡¼ ´Ù¿î ¹ÞÀÚ.
http://shonm.tistory.com/attachment/cfile26.uf@2067D03E4D4FABA426F0DB.zip
Ãâó : http://blog.naver.com/87kks/40187215290
Ãâó: https://codeghost.tistory.com/34 []