zenkay / simple-spreadsheet

Simple spreadsheet is a Ruby Gem reader for common spreadsheet formats: Excel (.xls, .xlsx), Open-office (.ods) and CSV (standard, excel, tab separated)
https://rubygems.org/gems/simple-spreadsheet
MIT License
98 stars 32 forks source link

Best way to read Uploaded files #18

Closed jasonperrone closed 6 years ago

jasonperrone commented 7 years ago

Hi, could you tell me what would be the preferred method for reading an already uploaded file (such as through a file_field_tag in a multipart form)? It wants a file path and name, but what if you already have the file? For example, Ruby CSV would just do CSV.new(file.read).

Sorry for the n00b question.

thanhquang1988 commented 7 years ago

Hello, are you done with that :) I suggest using this method :

book = SimpleSpreadsheet::Workbook.read params[:file].tempfile.path
jasonperrone commented 7 years ago

I could swear I tried that. lol. What I ended up doing was simply staged the file on the local server to be processed by SimpleSpreadsheet.

naveenslm commented 7 years ago

it is any possibilities to check whether the imported data is bold or italic and so on ??

naveenslm commented 7 years ago

I hav a data which is 22.9% but it is getting uploaded as 0.029... how to get out of tis issue ??

MaG21 commented 7 years ago

This lib doesn't work with files without extensions. Change the extension of the file beforehand.

Any chance of fixing this behaviour?

naveenslm commented 7 years ago

both the file extensions XLS and XLSX provides the same outcomes for tis....till i cant fix tis bug...

neerajgupta2407 commented 7 years ago

HI, How can we iterate througn multiple sheet present in Excel. Eg: s = SimpleSpreadsheet::Workbook.read("abc.xlsx") s.selected_sheet = s.sheets.first I can access sheets by s.sheets.first, s.sheets.second, s.sheets.third.... But i am not getting option for iterating over all sheets present.

I need somethig like this. s.sheets.each do |sheet| s.selected_sheet = sheet end Thanks

neerajgupta2407 commented 7 years ago

Got the solution...

jasonperrone commented 6 years ago

BTW, the answer above from thanhquang1988 was correct.