Skip to content

invalid byte sequence in UTF-8 when generating spreadsheet in Mailer #29

Open
@tigershen23

Description

@tigershen23

Hey there, I'm trying to attach an xlsx spreadsheet to a Sidekiq delayed email (only difference is that it's in the background), and I'm getting a WARN: invalid byte sequence in UTF-8 that blows up the sending job. I've tried all manner of different encoding options for the output from render_to_string, but no dice. This happens even when using very basic . The spreadsheet renders fine from the console and from a controller action. The email sends fine with no attachments. The following code is exactly what I'm running, with some names switched out. Gem version 0.3.0, Rails 4.1.7, Ruby 2.2.0

report_mailer.rb

xlsx = (render_to_string handlers: [:axlsx], formats: [:xlsx],
              template: "report")
attachments["report.xlsx"] = { mime_type: Mime::XLSX, content: xlsx }

report.xlsx.axlsx

wb.add_worksheet(:name => "Custom Borders") do |sheet|
   sheet.add_row ["wrap", "me", "Up in Red"], :style => red_border
   sheet.add_row [1, 2, 3], :style => blue_border
end

Output from a pry session right after the render_to_string call

[6] pry(#)> xlsx
03:24:34 worker.1 | => "PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�c8k��\u0000\u0000\u0000A\u0002\u0000\u0000\v\u0000\u0000\u0000_rels/.rels���N�0\f��<E���nH\b�e� ��\u0010*\u000F`\u0012�����\u0013��=�\u0003bh\b\u000E;Z�������\u0012f�B�=G\u0003��\u0005E���q0�����a��>���^����j$f\u0003c)�F�lG\n�\eN\u0014��g\tX�(�Nh'\u001CHo��J�w\u0006\u001C3U�2P1����ezb��\n\u0003��%�O\u0015���t��9P,'\u001A\u007F\\�:8\u0003rpk���8���5iY��6�\n:,�\t_��CR<�/���^����h)\u0014\u001D�SF�\u001FF��\u0015v\u0017�PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!������\u0001\u0000\u0000\t\u0005\u0000\u0000\r\u0000\u0000\u0000xl/styles.xml�T�j�0\u0010}�W\b}@em�@\u0017�P\u0002�B\u0013\n�C_�kym��Hr���\u0019I�-CC��\u000F���s��Fc���R<uBx4)�\u001D�����\u0010w�����\u0019��\u007FZc\u0015���\u0017�\u0006+x��HIr(�;�x�qU�Q��;t6��\f\u001FV\b��g�0-\n����i\u0004�3<D)�4\u0018�\u007F\n�{\u0002�uG���E%Y�Wek�V\u0005�\t\u0000k�\u0004z���\u001F��\u0012���&���k���� \u0001 I\u0018���K�;]\u0000�r��\v�k��%~�\a�T\e-�E2B0��\a���3=����\vTt2�\u0011vWS�\u0010pR�!R�\u001E�+g�w���F\u001A����p]\u0017�I�\f������Z\u0012�U��p�\u0002��<���V�����\u0000�q\u0016R>\u0005�?����\u0016%N\u0018'��f+��^C��\u0012����On�\u0012d�7����}��\u0005�\u007F�]\u0015���\u001E|\u0018��8���u|�b\u0015y\a���V�z��(�]\f?\u0006\a�����`�L[\u0003�0�\u0001���'�\u0010%�F�|��y�\u0018��\a�������~�/�/�-�\u0015F���-S8P�\u0004v�����\u0006PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���\u0001\t\r\u0001\u0000\u0000�\u0001\u0000\u0000\u0011\u0000\u0000\u0000docProps/core.xmlm��N� \u0010��>E��\u0005Z5\eB�\a��41�F����K,�\u0000n��K����l�e���\u00182|;�.9���7%�\u0019A\t\u0018�7��%z�w�\u0006m+.-���\u0017�[pA�Ob��L�\u0012�C�\fc/����\"ab��;-B,]�����\u0005�\u0013r�5\u0004�� �$L�bD'e#\u0017��q�,h$�\u000E4��1�(�g�\n�\u0016�v��\u0015\u001D�i\u007F\u0015���\u001C�Z�a\u0018����8?�\u001F�O��WSe|\u0010F\u0002�x#�t B�*1v~�xu�O\u000F\u001F/�I��\u001D�>'���c�CUN�]J��5)\u0018����sr]���ppP��*������]U7\u007FPK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���O��\u0000\u0000\u0000�\u0000\u0000\u0000\u0010\u0000\u0000\u0000docProps/app.xml���\n�0\u0014Ew��do\u0013\u001DDJ�.�������\r��B�,���\b�;^��p�n��b��\u001Ca+��\u0012\u0005�!�pn�u8�'���\u0012)@d\a��\u007FL�X�C-e2\v�1U\u0019c&\u0013E?r�q�4M�@O��\u0001Y\u001E�:J�\u0018��-�W(>�z�\u007F����/��g�>��_���\u0000PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�u�\u0000��\u0000\u0000\u0000\n\u0001\u0000\u0000\u001A\u0000\u0000\u0000xl/_rels/workbook.xml.rels���\n�0\u0010��>E���*\"\"M{\u0011�W�\u000F\u0010�mZl~�F�oo���\a���|�T����A�'�$l�\u0012\u00049���\u0019\t���>@SW\u0017�U�\t\u001E��\"W\u001CK\u0018S\nGD�#Y��\u000F��3�hU�2\u001A\fJ��!���\u001E�'\u0003���S�P��i����\u0001�-��Y��0i:y}����1|SA�����;����O��\u0005PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�=�9�\u0015\u0001\u0000\u0000�\u0002\u0000\u0000\u0013\u0000\u0000\u0000[Content_Types].xml��=O�0\u0010�w~E�\u0015�\u000E\f\b�$\u001D�\u0018�C�\u0001��$V�%�[�\u007F���K��������9[�W���\u000E\u0012��\ev�+V�WA\e�7�s�V>�U[o�\u0011��V�\r\er�OB�\u001A�I�!��J\u0017�����\u0017Q�Q� ���A��3�\\�����\u0005:���x^�gt�d��(�i\n���\u0004Z�\u0002y\u0002{���D��\u0006V�NDY��*2q��48�)�A����b-S~��RB\a�N!��<?���;t�Q@���\b�Y�A�������\u0012��*$�^~|�9}�q�\u0002��\u0002���\u0018\u0013H�\u0003@v�/�3�����\u0010��v�+w���_\u001C�s{�\u0003PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�@*\u0014��\u0000\u0000\u0000)\u0001\u0000\u0000\u000F\u0000\u0000\u0000xl/workbook.xml�����0\fE��\u0015���\u00161#�j�\u0006!�C��\u0003B���&��\u0000��\u0013^b������z�\u0017\u0006uF\u0016O�@9-@al��x0��]O\u0016�l�\v�qOtTy:��>���Z�\u001E��)�\u0018s�#\u000E6��\u000FZFF��GLa�������\bwB��0��|�+jO\u0001c�C\u0018\a��W��(�r�e�l����\e�� \b��o��\u0011U�\u0001\r�\\u\t�V���4(�|\u0016�q��-�\\�Oz��\u000FPK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��(�js\u0000\u0000\u0000�\u0000\u0000\u0000#\u0000\u0000\u0000xl/worksheets/_rels/sheet1.xml.relsU�K\u000E\u0002!\u0010\u0005�����i��1\u0006��\u001C��\a �\u0002q��&���R��W���I�xS�X���$APv�\u0011��p���\u0005\u0016�n��>\f\u000E��\u0018��\u001AB����.P�<�Jy,����\u0003��j��z�Y�3��\u0006\u0018�\u007FQs�\u0002PK\u0003\u0004\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��v\u0015��\u0001\u0000\u0000\b\u0004\u0000\u0000\u0018\u0000\u0000\u0000xl/worksheets/sheet1.xml�SMo�0\f��W\u0018�/v\at\v�8=��: [��\u001F�n�M�Be���z��\u001F%;�\u0003l�n�����V��\e\u001D��u\nM*�\u0016����X(S���a�q)n��\u001E���\u0001(�t�RQ\u0013�7q��\u001A\u001A�\u0016���H������b�Z�E(jt�)I>��TF\f\u001Dn�����T9�a�5`hhbAK�e]�Z\u0017���V��\n\u001E����X�������VV�\u0001=����\u001E��@*J�\u001D�(^��1w,zR���\u001D��\u0014�\u001F,\u0012�\u0014H\u001AkI\u001E3�\fB1a����V\u0004���\f�w�����9�v\u0017�-?���\fZU���\u000EJ�H�\u0005\u00169�l7\u0002?;\r�\u0002�~����gI���V\u0015;�?�\u0005����q����;b��R��W\t_���������/Mf)�gi'��\v\\]\u0006=�����\"���\u0014�Is�$�6�\u0003�w�\u000Ex�gUP����\u0002~�=x�x�e�4��I��~�\u001D����?�Nko��\u000Eeqz;��V\u0019������ ��n����t���w4��\u0010s���,fuf�|u�,�K[)�b�����k\u0011���`\u001F�\b��W\u0012��U\"���I������{�Z�\f�m��D�}v�_���\aPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�c8k��\u0000\u0000\u0000A\u0002\u0000\u0000\v\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��\u0000\u0000\u0000\u0000_rels/.relsPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!������\u0001\u0000\u0000\t\u0005\u0000\u0000\r\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��\u0002\u0001\u0000\u0000xl/styles.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���\u0001\t\r\u0001\u0000\u0000�\u0001\u0000\u0000\u0011\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\u0002\u0000\u0000docProps/core.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!���O��\u0000\u0000\u0000�\u0000\u0000\u0000\u0010\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��1\u0004\u0000\u0000docProps/app.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�u�\u0000��\u0000\u0000\u0000\n\u0001\u0000\u0000\u001A\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\u0004\u0000\u0000xl/_rels/workbook.xml.relsPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�=�9�\u0015\u0001\u0000\u0000�\u0002\u0000\u0000\u0013\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\u0005\u0000\u0000[Content_Types].xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!�@*\u0014��\u0000\u0000\u0000)\u0001\u0000\u0000\u000F\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000��\u000E\a\u0000\u0000xl/workbook.xmlPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��(�js\u0000\u0000\u0000�\u0000\u0000\u0000#\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\a\u0000\u0000xl/worksheets/_rels/sheet1.xml.relsPK\u0001\u00024\u0003\u0014\u0000\u0000\u0000\b\u0000\u0000\u0000!��v\u0015��\u0001\u0000\u0000\b\u0004\u0000\u0000\u0018\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000\u0000\u0000���\b\u0000\u0000xl/worksheets/sheet1.xmlPK\u0005\u0006\u0000\u0000\u0000\u0000\t\u0000\t\u0000N\u0002\u0000\u0000�\n\u0000\u0000\u0000\u0000"

Thanks in advance for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions