1. PHP ZEND 설치
2. ZEND library full down - gdata가 xml도 사용하므로 full로 다운받아야 이용 가능(zend framework 1.12.13)
http://framework.zend.com/downloads/latest
3. ZendFramework-1.12.13/demos/Zend/Gdata/Spreadsheet-ClientLogin.php 파일 수정
//생성자에 시트키와 워크시트 키를 고정한다.
public function __construct($email, $password, $keyword)
{
try {
$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME);
} catch (Zend_Gdata_App_AuthException $ae) {
exit("Error: ". $ae->getMessage() ."nCredentials provided were email: [$email] and password [$password].n");
}
$this->gdClient = new Zend_Gdata_Spreadsheets($client);
$this->currKey = '시트키';
$this->currWkshtId = '워크시트키';
$this->listFeed = '';
$this->rowCount = 0;
$this->columnCount = 0;
$this->keyword = '검색어';//셀상단값=검색어
}
//스프레드시트 선택 인풋 루틴 제거
/**
* promptForSpreadsheet
*
* @return void
*/
public function promptForSpreadsheet()
{
$feed = $this->gdClient->getSpreadsheetFeed();
}
//워크시트 선택 인풋 루틴 제거
/**
* promptForWorksheet
*
* @return void
*/
public function promptForWorksheet()
{
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($this->currKey);
$feed = $this->gdClient->getWorksheetFeed($query);
}
쿼리 사용은 http://framework.zend.com/manual/1.12/en/zend.gdata.spreadsheets.html 참고
$query = new Zend_Gdata_Spreadsheets_ListQuery();
$query->setSpreadsheetKey($this->currKey);
$query->setWorksheetId($this->currWkshtId);
$keyword="셀이름=검색어";
$query->setSpreadsheetQuery($keyword);
$this->listFeed = $this->gdClient->getListFeed($query);
봐줄만한 속도로 스프레드시트의 검색된 결과 행을 출력한다.
/**
* printFeed
*
* @param Zend_Gdata_Gbase_Feed $feed
* @return void
*/
public function printFeed($feed)
{
$i = 0;
foreach($feed->entries as $entry) {
// if ($entry instanceof Zend_Gdata_Spreadsheets_CellEntry) {
// print $entry->title->text .' '. $entry->content->text . "n";
// } else if ($entry instanceof Zend_Gdata_Spreadsheets_ListEntry) {
// print $i .' '. $entry->title->text .' | '. $entry->content->text . "n";
// } else {
// print $i .' '. $entry->title->text . "n";
// }
print $entry->content->text;
$i++;
}
}
댓글 달기