There is no close method in spreadsheet.If you opened the spreadsheet and after reading you need to delete it then FIleUtils.rm(file_name) will work smoothly in linux but in windows it will give permission error
Errno::EACCESS(Permission denied)
Initially I have this code
@book = Spreadsheet.open file_name
@salary_sheet = @book.worksheet 0
Above works fine in linux but in Windows it is giving me Permission error so I tried below code.
Spreadsheet.open file_name do |sheet|
@salary_sheet = sheet.worksheet 0
end
The above code fixed my problem.
0 Comment(s)