具有条件的IMPORTRANGE

时间:2017-01-16 15:35:10

标签: google-sheets

使用Google工作表,我希望在同一文档中使用具有条件的IMPORTRANGE将数据从一个工作表导入另一个工作表。

我尝试过失败:

  

= IF(IMPORTRANGE(" https:URL"," Inc数据库!B2:B300")="永久",IMPORTRANGE(" htps :// URL"," Inc数据库!A2:A300"),"")

  

= QUERY(IMPORTRANGE(" https:/ URL"," Inc数据库!A2:A300")," SELECT Col1 WHERE Col1<>&#39 ;永久'&#34)

  

= FILTER(IMPORTRANGE(" URL"," Inc数据库!A1:A250"),IMPORTRANGE(" URL"," Inc数据库! B1:B250" ="冒险永久"))

我希望函数说:导入符合条件的任何值范围A" permanent"在范围B

public function add_candidate_personal_info(){

  $candidate = $this->input->post();
  $this->load->model('common_model');
  // $this->load->library('form_validation');
  $this->load->helper('common_helper');
  $this->load->model('User_model');

  $this->form_validation->set_rules('firstname', 'First Name', 'required');
  $this->form_validation->set_rules('lastname', 'Last Name', 'required');
  $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[candidate.email]');
  $this->form_validation->set_rules('password', 'Password', 'required|min_length[6]');
  if (empty($_FILES['userfile']['name']))
  {
      $this->form_validation->set_rules('userfile', 'File Upload', 'required');
  }

  if($this->form_validation->run()==FALSE){
    $formError = validation_errors();
    $this->data['errorMessage'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
    $this->load->view('front/user/candidate/add', $this->data);
   // redirect('register_candidate');
  }
  else {
    $personal_data = array(
        'firstname' => $this->input->post('firstname'),
        'lastname' => $this->input->post('lastname'),
        'father_name' => $this->input->post('father_name'),
        'cnic' => $this->input->post('cnic'),
        'gender' => $this->input->post('gender'),
        'marital_status' => $this->input->post('marital_status'),
        'day_of_birth' => $this->input->post('day_of_birth'),
        'month_of_birth' => $this->input->post('month_of_birth'),
        'year_of_birth' => $this->input->post('year_of_birth'),
        'email' => $this->input->post('email'),
        'phone' => $this->input->post('phone'),
        'postal_code' => $this->input->post('postal_code'),
        'country_id' => $this->input->post('country_id'),
        'state_id' => $this->input->post('state_id'),
        'industry_id' => $this->input->post('industry_id'),
        'experienc_level' => $this->input->post('experienc_level'),
        'current_salary' => $this->input->post('current_salary'),
        'expected_salary' => $this->input->post('expected_salary'),
        'salary_currency' => $this->input->post('salary_currency'),
        'address' => $this->input->post('address'),
        'skype' => $this->input->post('skype'),
        'professional_summary' => $this->input->post('professional_summary'),
        'face_book' => $this->input->post('face_book'),
        'twitter' => $this->input->post('twitter'),
        'linkedin' => $this->input->post('linkedin'),
        'blog' => $this->input->post('blog'),
        'website' => $this->input->post('website'),
        'created_at' => date('Y-m-d H:i'),
    );

     if ($this->common_model->insert('candidate_resume_profile', $personal_data)) {
            $this->ajaxResponse['status'] = 200;
            $this->ajaxResponse['message'] = $this->message->success('Candidate Personal Information is Successfully Added');
            $this->ajaxResponse['data'] = '';
            exit(json_encode($this->ajaxResponse));
        } else {
            $this->ajaxResponse['status'] = 500;
            $this->ajaxResponse['message'] = $this->message->error('Internal Error');
            $this->ajaxResponse['data'] = '';
            exit(json_encode($this->ajaxResponse));
        }

  }
}

THKS,

2 个答案:

答案 0 :(得分:1)

我在following spreadsheet中列举了几个例子:

e.g。 = QUERY(IMPORTRANGE(" https://docs.google.com/spreadsheets/d/1LX7JfbGvgBTfmXsYZz0u5J7K0O6oHJSnBowKQJGa9lY/edit#gid=0"," Inc数据库!A2:B300")," SELECT Col1 WHERE not(Col2 =' Permanent& #39;)")

答案 1 :(得分:0)

由于名称中有空格,因此您需要在工作表/选项卡的引用周围使用单引号。使用您的示例:

IMPORTRANGE("https:/URL", "'Inc Database'!A2:A300")

但这只会导入A列,因此您无法检查B列

然后使用Query。如果你想要B是'永久'的所有东西,那么你想要(未经测试):

=QUERY(IMPORTRANGE("https:/URL", "'Inc Database'!A2:B"),"SELECT Col1 WHERE Col1 = 'Permanent'")

这将:

  • 导入所有行,从主数据表的A2开始,在Query()中使用。
  • 通过查询,仅返回Col2(B)包含'Permanent'
  • 的那些