0
<a style="margin:0px 10px;" href="<?php echo base_url(); ?>admin/download_members" class="btn btn-info" ><i class="glyphicon glyphicon-cloud-download"></i> Download Excel</a>
上記のアンカータグをクリックするとExcelが完全にダウンロードされます。 私はいくつかのフィルターでExcelをダウンロードする必要があります。私はダウンロードするのにAJAXを使用していますが、ダウンロードすることはできません。エクセルシートにデータをダウンロード
私のAjax
$(document).ready(function(){
$("#download_excel").click(function(){
var state = $("#state").val();
var city = $("#city").val();
$.post("<?php echo base_url()?>admin/download_members",
{
state:state,city:city
},
function(response){
});
});
});
私のコントローラ
function download_members(){
$state = $this->input->post('state');
$city = $this->input->post('city');
$data['members'] = $this->Select->view_members_to_download($state,$city,$status);
$this->load->view('admin/spreadsheet_view',$data);
}
あなたのコントローラにダウンロードヘルパーを使用することができます
public function view_members_to_download($state,$city){
if($state){
$this->db->where('u.state',$state);
}
if($city){
$this->db->where('u.city',$city);
}
$this->db->order_by('u.plan','asc');
$this->db->from('users u');
$this->db->join('states s', 'u.state=s.id', 'left');
$this->db->join('cities c', 'u.city=c.id', 'left');
$this->db->join('packages p', 'p.package_id=u.plan', 'left');
$this->db->join('profile_type pt', 'pt.profile_type_id=u.profile_type', 'left');
$query = $this->db->get();
return $query->result();
}
はhrefを "#"に置き換えます。 –