zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

Can't export notes with spreadsheet #199

Closed ghost closed 7 years ago

ghost commented 7 years ago

I'm using spreadsheet to export excel with .xls extension. So i can't add note into worksheet. Below my code:

  Spreadsheet.client_encoding = 'UTF-8'
        spreadsheet = StringIO.new
        comment = Spreadsheet::Note.new
        comment.author = "TestAuthor"
        comment.text = "TestAuthor"
        wb = Spreadsheet::Excel::Workbook.new
        wb.add_worksheet(Spreadsheet::Excel::Worksheet.new)
        sheet = wb.worksheet(0)
        sheet.ensure_rows_read
        sheet.row(0).concat ['会社コード', '部署コード', '部署名', '社員コード', '社員名', '出勤予定日', '開始時刻(予定)', '終了時刻(予定)', '所定時間数', 'コメント']
        sheet.add_note(0, 1, comment)
        wb.write spreadsheet
        send_data spreadsheet.string, :filename => "yourfile.xls", type:  "application/vnd.ms-excel"

we are using rails 4.2.5 and ruby 2.3. Thanks

zdavatz commented 7 years ago

Are you editing an existing file? Or are you creating a new file from scratch?

ghost commented 7 years ago

@zdavatz i creating new file!

zdavatz commented 7 years ago

Let me test this!

zdavatz commented 7 years ago

Your script gives me: test.rb:15:in <main>': undefined method send_data' for main:Object (NoMethodError) you need to provide a Ruby script that works for testing!