Created
March 2, 2019 04:34
-
-
Save ytnk531/eee2cb278f1b36d1caff4c999e0672c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExcelsController < ApplicationController | |
def show | |
end | |
def create | |
file = params[:file] | |
# ファイルを開く | |
workbook = RubyXL::Parser.parse file.path | |
# 編集する | |
workbook[0].add_cell 0, 0, 'changed' | |
# 編集したファイルを送る | |
send_data workbook.stream.string, type: file.content_type, filename: 'modified.xlsx' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | |
root to: "excels#show" | |
resource :excel, only: [:show, :create] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag({action: :create}, multipart: true) do %> | |
<div> | |
<%= file_field_tag :file %> | |
</div> | |
<div> | |
<%= submit_tag "Send" %> | |
</div> | |
<% end %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment