rails excel 내보내기
ruby script/plugin install http://svn.napcsweb.com/public/excel
이 때 프로젝트의vender 디렉터리에 excel이 있습니다.rb, 이것이 우리의 핵심 방법
2. OrderedHash 이 hash는 질서정연합니다. 컨트롤러에서 require "active_support"include ActiveSupport를 가져와야 합니다.
3. 컨트롤러의 실례를 보다
  def export
    @ala_users = User.find(:all)
    @count = Record.count(:conditions => [' ala_organization_id = ? and ala_user_id = ? ',session[:organization_id],session[:user_id]]) 
    @count_pass = Record.count(:conditions => [' ala_organization_id = ? and ala_user_id = ? and status = ? ',session[:organization_id],session[:user_id],'6'])        
    array = Array.new
    for i in 0..@ala_users.length-1
      item = OrderedHash.new
      item[" "] = @ala_users[i].name
      item[" "] = @ala_users[i].ala_department.name if @ala_users[i].ala_department
      item[" "] = @ala_users[i].positions
      item[" "] = @ala_users[i].learning_times
      item[" "] = @ala_users[i].learning_credits
      item[" "] = @count[i]
      item[" "] = @count_pass[i]
      array << item
    end
    e = Excel::Workbook.new
    e.addWorksheetFromArrayOfHashes("Books info", array)
    headers['Content-Type'] = "application/vnd.ms-excel"
    headers['Content-Disposition'] = 'attachment; filename="excel-export.xls"'
    headers['Cache-Control'] = ''
    render :text=>e.build
  end 
                이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.