本文整理匯總了PHP中openImportExcelFile函數的典型用法代碼示例。如果您正苦於以下問題:PHP openImportExcelFile函數的具體用法?PHP openImportExcelFile怎麽用?PHP openImportExcelFile使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了openImportExcelFile函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ImportFromExcel
function ImportFromExcel($uploadfile)
{
$autoinc = false;
$ret = 1;
global $error_message, $keys, $goodlines, $total_records, $conn, $strOriginalTableName, $strTableName, $keys_present;
$data = openImportExcelFile($uploadfile);
// populate field names array
$fields = array();
$fields = getImportExcelFields($data);
$fields = getFieldNamesByHeaders($fields);
$keys_present = 1;
for ($k = 0; $k < count($keys); $k++) {
if (!in_array(RemoveFieldWrappers($keys[$k]), $fields)) {
$keys_present = 0;
break;
}
}
if (in_array("Record ID", $fields)) {
$autoinc = true;
}
if ($autoinc) {
$sql = "SET IDENTITY_INSERT " . AddTableWrappers($strOriginalTableName) . " ON";
db_exec($sql, $conn);
}
$ret = getImportExcelData($data, $fields);
if ($autoinc) {
$sql = "SET IDENTITY_INSERT " . AddTableWrappers($strOriginalTableName) . " OFF";
db_exec($sql, $conn);
}
return $ret;
}
示例2: importFromExcel
/**
* Import data form an Excel file
* @param String filePath
* @param Array fieldsData
* @param Boolean useFirstLine
* @param String dateFormat
* @return Array
*/
protected function importFromExcel($filePath, $fieldsData, $useFirstLine, $dateFormat)
{
$ext = getFileExtension($filePath);
$fileHandle = openImportExcelFile($filePath, $ext);
$keys = $this->pSet->getTableKeys();
$autoinc = $this->hasAutoincImportFields($fieldsData);
if ($this->connection->dbType == nDATABASE_MSSQLServer && $autoinc) {
$sql = "SET IDENTITY_INSERT " . $this->connection->addTableWrappers($this->strOriginalTableName) . " ON";
$this->connection->exec($sql);
}
$metaData = ImportDataFromExcel($fileHandle, $fieldsData, $keys, $this, $autoinc, $useFirstLine, $dateFormat);
if ($this->connection->dbType == nDATABASE_MSSQLServer && $autoinc) {
$sql = "SET IDENTITY_INSERT " . $this->connection->addTableWrappers($this->strOriginalTableName) . " OFF";
$this->connection->exec($sql);
}
return $metaData;
}
示例3: ImportFromExcel
function ImportFromExcel($uploadfile)
{
$autoinc = false;
$ret = 1;
global $error_message, $keys, $goodlines, $total_records, $conn, $strOriginalTableName, $strTableName, $keys_present;
$data = openImportExcelFile($uploadfile);
// populate field names array
$fields = array();
$fields = getImportExcelFields($data);
$fields = getFieldNamesByHeaders($fields);
$keys_present = 1;
for ($k = 0; $k < count($keys); $k++) {
if (!in_array(RemoveFieldWrappers($keys[$k]), $fields)) {
$keys_present = 0;
break;
}
}
$ret = getImportExcelData($data, $fields);
return $ret;
}
示例4: ImportFromExcel
function ImportFromExcel($uploadfile, $strOriginalTableName, $ext, $keys, &$keys_present, &$total_records, &$error_message, &$goodlines, $pageObject, $cipherer)
{
global $conn, $strTableName;
$autoinc = false;
$ret = 1;
$data = openImportExcelFile($uploadfile);
// populate field names array
$fields = array();
$fields = getImportExcelFields($data);
$fields = getFieldNamesByHeaders($fields, $strOriginalTableName, $ext);
if($fields == null) // if error happened
return;
$keys_present=1;
for($k=0; $k<count($keys); $k++)
{
if (!in_array(RemoveFieldWrappers($keys[$k]),$fields))
{
$keys_present=0;
break;
}
}
if(in_array("id",$fields))
$autoinc=true;
if(GetDatabaseType() == 2 && $autoinc)
{
$sql = "SET IDENTITY_INSERT ".AddTableWrappers($strOriginalTableName)." ON";
db_exec($sql,$conn);
}
$ret = getImportExcelData($data, $fields, $error_message, $goodlines, $keys, $keys_present, $strOriginalTableName, $pageObject, $cipherer, $autoinc, $total_records);
if(GetDatabaseType() == 2 && $autoinc)
{
$sql="SET IDENTITY_INSERT ".AddTableWrappers($strOriginalTableName)." OFF";
db_exec($sql,$conn);
}
return $ret;
}