Forums: PHPExcel - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHPExcel PHPRunner 9.8 Rate Topic: -----

#1 User is offline   Jorge 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 31-January 19
  • Gender:Male
  • Location:FORTALEZA/BRAZIL

Posted 12 February 2019 - 12:18 AM

I added bellow script on "server" button action and the file is saved in server without problem. Now, I need to downoload the file,
but it does not work. So, I need a help.



require('PHPExcel.php');

$phpExcel = new PHPExcel;

// Setting font to Arial Black

$phpExcel->getDefaultStyle()->getFont()->setName('Arial Black');

// Setting font size to 14

$phpExcel->getDefaultStyle()->getFont()->setSize(14);

//Setting description, creator and title

$phpExcel ->getProperties()->setTitle("Vendor list");

$phpExcel ->getProperties()->setCreator("Robert");

$phpExcel ->getProperties()->setDescription("Excel SpreadSheet in PHP");

// Creating PHPExcel spreadsheet writer object

// We will create xlsx file (Excel 2007 and above)

$writer = PHPExcel_IOFactory::createWriter($phpExcel, "Excel2007");

// When creating the writer object, the first sheet is also created

// We will get the already created sheet

$sheet = $phpExcel ->getActiveSheet();

// Setting title of the sheet

$sheet->setTitle('My product list');

// Creating spreadsheet header

$sheet ->getCell('A1')->setValue('Vendor');

$sheet ->getCell('B1')->setValue('Amount');

$sheet ->getCell('C1')->setValue('Cost');

// Making headers text bold and larger

$sheet->getStyle('A1:D1')->getFont()->setBold(true)->setSize(14);

// Insert product data

// Autosize the columns

$sheet->getColumnDimension('A')->setAutoSize(true);

$sheet->getColumnDimension('B')->setAutoSize(true);

$sheet->getColumnDimension('C')->setAutoSize(true);

// Save the spreadsheet

$writer->save('products.xlsx');
0

#2 User is offline   John 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 02-December 05
  • Gender:Male

Posted 12 February 2019 - 04:07 PM

View PostJorge, on 11 February 2019 - 07:18 PM, said:

I added bellow script on "server" button action and the file is saved in server without problem. Now, I need to downoload the file,
but it does not work. So, I need a help.



require('PHPExcel.php');

$phpExcel = new PHPExcel;

// Setting font to Arial Black

$phpExcel->getDefaultStyle()->getFont()->setName('Arial Black');

// Setting font size to 14

$phpExcel->getDefaultStyle()->getFont()->setSize(14);

//Setting description, creator and title

$phpExcel ->getProperties()->setTitle("Vendor list");

$phpExcel ->getProperties()->setCreator("Robert");

$phpExcel ->getProperties()->setDescription("Excel SpreadSheet in PHP");

// Creating PHPExcel spreadsheet writer object

// We will create xlsx file (Excel 2007 and above)

$writer = PHPExcel_IOFactory::createWriter($phpExcel, "Excel2007");

// When creating the writer object, the first sheet is also created

// We will get the already created sheet

$sheet = $phpExcel ->getActiveSheet();

// Setting title of the sheet

$sheet->setTitle('My product list');

// Creating spreadsheet header

$sheet ->getCell('A1')->setValue('Vendor');

$sheet ->getCell('B1')->setValue('Amount');

$sheet ->getCell('C1')->setValue('Cost');

// Making headers text bold and larger

$sheet->getStyle('A1:D1')->getFont()->setBold(true)->setSize(14);

// Insert product data

// Autosize the columns

$sheet->getColumnDimension('A')->setAutoSize(true);

$sheet->getColumnDimension('B')->setAutoSize(true);

$sheet->getColumnDimension('C')->setAutoSize(true);

// Save the spreadsheet

$writer->save('products.xlsx');


From Here : Click Here

// We'll be outputting an excel file
header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
// It will be called product.xlsx
header('Content-Disposition: attachment; filename="products.xlsx"');
// Write file to the browser
$writer->save('php://output');
exit();
0

#3 User is offline   Jorge 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 2
  • Joined: 31-January 19
  • Gender:Male
  • Location:FORTALEZA/BRAZIL

Posted 12 February 2019 - 07:19 PM

Dear John,

If a call normal PHP page in the server it download, but if I call the the page through PHPRunner (button on server atction), it save but
call back a error..

PK��LNG�D�X�[Content_Types].xml��MN�0���"�%nY ��vAa �(0����ؖg�w{&i �@�nbE�{��y��d۸l m�����X�(���)���F��;@1_�����c)j�x/%��E��y� �QĿi!��K�y3�J<���Z1�0?Y�L%zV c��Ib7�����a/l٥P1:�q�r��j��j0A����u�""���(� ���W�M��)Tj�({ܲ�>�O��,X٭���>B��~׭� ��Ӥ6�J=�oBZ����t��X4���Cg�,���QgmrL�ٯc�e��t�� Z�?����hPv����u�j���R������}�Cv��PK��LN�78�K _rels/.rels���j�0 ��{ �{���1F�^ʠ�2��l�$���-}�y������O��v�y�;�؋Ӱ.JP��޵^�����Yű�3G�Ww�g)���>� qQC��D���b!�]�i$L��3��� �2n���oT �:Z �h����[��4�ი��]��yN�,ە�>�>�j -' V�)�#��EF^6��n���8q"K��H��>_ׄ����eƏ�<⇄�Ud�v�� T�PK��LN�$�V��xl/_rels/workbook.xml.rels���j�0D�� ��ZvZJ)�s)�\[����LlIh7m��UH��Ĭؙ�H���8�OL���*J�M���|4��g��[=� &$��w�74�r}$�M<)p��EJ2GME���MҨ9��ɨ�^w(We�$��� O�� ��V �)��C��_�9���J�$���/�:DG]d���WK�s��s��<�[ �V�tB��)?�����0_!��!��4�E�ǩy���PK��LNm�(�AdocProps/app.xml�S�n�0 ��+ �9�0 ���H7��`��gU�c��$����';��4;M�G��鉤����Y �w[.r��Ӿ4�X���ϻ�,CR�T�;(X�����>@$�%���šs�54 ��R��Q��x侪��G�O 8�<���L�J(��$�.���W�����/�.$=)B�F+J��[��G_Q��� >/�$�}��:� >�^+ �$,+e�H�'P}�v�D���u �|���I][��M!�v ֪h�#v�]�ۀ嫏�X >%8�α�*�!�k"��$|m�`���v*�?/�l�q�ei^�ISf ҍ���O�l|��f#��|z/�X[��z� �2����?*����I��U�2�l�ϔO�!���M��ʑs[����#�r����d� ����/PK��LN(H��docProps/core.xml��IO�0��� ���I[��M@�hY��Z�Ķ�4�'iӲܸD�7_f��8_W%��5��RJ�H��YL���&9�$�0J����6�9?(�˥�0�ցG �D� �t�Dt9cA.�a&�o�Wc�� � `�4=f�Pk���t�Tr@�_v%�P����Q�v^_�?:e�Yil�i݊�{�`��zTv�8�^��fݪ�6mT(/�̥����*��S_)�Ǡ�4���?����!���`�-�f��ĩ�~���|xy5��|�fgI:N��<;ɳ�������x|�z-�$3�R�%m��vڵ������y'E�lMm� � pW���]X��ҏ��-�/PK��LN���Jxl/theme/theme1.xml�Y[s�8~�_��{k 6%��L ��i3 �N��Ud�#����=���X��Mgw��,�;������/)'wT*&���=�9�f��X������C��,.2:v�T9�g��S�Д$��)��D���uU�۠���fxo%d �2v# ��6�n���)��!����j�BJK�l�|��+Ӫ��� K�m����GmՔKr|제H�/��J㍱�+?�{���q}��E7/?5]M��%���{Bo����W����l6�y{~%�-�:X>�&;�-Pu��=�=�ķ�:���d��A��;�Qo�_� ���������th��?���/N���/A gٺ�.⹏����>B�h� �meWE��C���g!�(� �eDos��qSH��A!N)��T[��l�� %����+��r~N΋�����㔉��� ��.$,۰K�"��=�)jnaL��q��A "-��N �-pnBMG}�X�6��gC��Dn4��$���O�����6g��v�r�����dO�s��1O���4����� 1ͨ&�=���B��1W,�B��&����d���N����-�Cm���#�ncI�L$&?pK� 7����Ԫ1���| :�)y����p�1�1��"�������3ְ_�mj"�fk�-�F^��4�4��̲���S�1E�\ mUB�R�1� �GF�����{�w6���FwMY��V���_��^�c��`���m�6�5�L��Uw�_����c{i�>��L[�K�+����r�V��W���7�EI����/kq.�P^)��L'� �(�+%Īf+� �S�s�wydh|���o�}%�j{�>��ٔ�X� � ��1a^vV8'�e�#?U4 �q6vB]���b~h�=-��A� �T�TRQ��v�=�F�~�~x���b0��E-܇��� ���fY�M�mݓ%��@��*�"����-$V�_'�Y�u<|�RW�<��'�Z�����^�r�R�=��w�2xBS�_ה"sqlD�q � ��ѱ#�Nv����\�Σ�q��;F5!�~���r����{���������v�%�2��X~FٗxP�p��wE_�9ݽ�G>nCz�PK��LN���ן�xl/sharedStrings.xml]�A �0н���� "��H���Ўm����T��������0�z�A=1sHdaS������,\/��������*�2̢�)��^d/�� ٮ �� J>\�vJ��_/^���J�'�\wJϐ8�� ē���v�:�$Nڗ����V�E��HO�d�� �m���)ס�����T�8�Q{d� g���8f�^�NI�4E��*�k�_��OW �/�kU�9-)q0���1v��4��!�Ӗ ���� W��.�������_��֟L3����]P�7GN}i�ƥi�������!g3����X��8Fi�e�p� ��Y� �'z��Ə�M^A�]J�M_�PK��LNp�o��xl/workbook.xml�QMO1��WX��MP��(���"��*)�{��-�lB��;����7�珃W[Ȅ1�zz2� ���}���/�Њ�g| ��=�>_�[�b~����d~A�X�� y �$��gN��!��`�$&R�b �� Ɍq������� �g�E~ G�:�p�8@�IoX$Q���j١�ۃJeR�a���k� �� ��3�q�yL�F��'sݬ^���J|�պG�{.��ov���@e,��f�jqڌ/�3� ��5�1UߧZu��o�/�s��>��Qw�bƧ�����u��l���g���l~�Z}6�-n�#�[]����?���Q���z�R�n��<�mR�ruE^�<�U�㼃�bI^β�I u�t6�~�_���.����%�3|���Σ���PK��LN�W9�Yxl/worksheets/sheet1.xml�UKs�0��Wxt/6�<�`2M(Mg�I&��,�5V#K�$��_�����C9�����.�׊G-(ͤH�x��D&s&6)yz\�?'�6T�K)ف&�w�T/�0�tM3��hP- ��Ҙz�:+��z$kxSHUQ����mh�*O��4�(�a���C�`)��a<�N �KVk��;wj1���L���tSUT�.��-�N:��mJc�x1�{��!��R��Hɧ�l�4��w[}p� ]?��@�m��R��˯a�u)�_�o0,�Q x�^n�$�Ʋ�Xk$v\�9ş��s���1���V�j�{m�AW�ҝ��NH�s-�{[�d�adCO���}G.Ɋ��dYnʔ�������I���5h�b��6k��ճW0;{�{�'��{��=���|z2�g����yI ]̕�F�wVM�8�g�13 ��sw�o�]$�4A��Xc<Ը:֘ 5�C %�u��2t�4����r����u/� UL�?��#�0ɛJ�E����0�=���] {�e��hx��������@>�VK�O�6F�7�z�f�4�t��-ۓ��|X�Z1ank����~ȃq�<@�]ֈn�UL5�P�M2:#�����F������J�-�4�u��/:jꨦX�� \KH�p]�-����S����`�Q� "�aܶ�nW�_������y�����bŔ6�����)qswE9���B�v�����{pƣ���J�ꇂ=��BaC�M�z��tX���oPK��LN�KR"x�#xl/worksheets/_rels/sheet1.xml.relsM�1!{_A��@ c�q����p+a!,1�{)-'��y����$�p� (bW�����~ݟAIG�0& _X��|��}4b5&,B�����@e*�x�gi���uE�BO�h�I����PK��LNG�D�X���[Content_Types].xmlPK��LN�78�K ���_rels/.relsPK��LN�$�V�����xl/_rels/workbook.xml.relsPK��LNm�(�A���docProps/app.xmlPK��LN(H����zdocProps/core.xmlPK��LN���J��-xl/theme/theme1.xmlPK��LN���ן���� xl/sharedStrings.xmlPK��LN���. ��y xl/styles.xmlPK��LNp�o�����xl/workbook.xmlPK��LN�W9�Y���xl/worksheets/sheet1.xmlPK��LN�KR"x�#���xl/worksheets/_rels/sheet1.xml.relsPK �{[]
0

#4 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16224
  • Joined: 03-February 03
  • Gender:Male

Posted 12 February 2019 - 08:27 PM

Button's server code is executed behind the scene via AJAX. You cannot do redirects there and you cannot offer a file to download from the Server code.
Best regards,
Sergey Kornilov
0

#5 User is offline   John 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 562
  • Joined: 02-December 05
  • Gender:Male

Posted 12 February 2019 - 08:29 PM

View PostJorge, on 12 February 2019 - 02:19 PM, said:

Dear John,

If a call normal PHP page in the server it download, but if I call the the page through PHPRunner (button on server atction), it save but
call back a error..

PK��LNG�D�X�[Content_Types].xml��MN�0���"�%nY ��vAa �(0����ؖg�w{&i �@�nbE�{��y��d۸l m�����X�(���)���F��;@1_�����c)j�x/%��E��y� �QĿi!��K�y3�J<���Z1�0?Y�L%zV c��Ib7�����a/l٥P1:�q�r��j��j0A����u�""���(� ���W�M��)Tj�({ܲ�>�O��,X٭���>B��~׭� ��Ӥ6�J=�oBZ����t��X4���Cg�,���QgmrL�ٯc�e��t�� Z�?����hPv��±��u�j���R������}�Cv��PK��LN�78�K _rels/.rels���j�0 ��{ �{���1F�^ʠ�2��l�$���-}�y����Î��O��v�y�;�؋Ӱ.JP��޵^�����Yű�3G�Ww�g)���>� qQC��D���b!�]�i$L��3��� �2n���oT �:Z �h����[��4�ი��]��yN�,ە�>�>�j -' V�)�#��EF^6��n���8q"K��H��>_ׄ����eƏ�<⇄�Ud�v�� T�PK��LN�$�V��xl/_rels/workbook.xml.rels���j�0D�� ��ZvZJ)�s)�\[����LlIh7m��UH��Ĭؙ�H���8�OL���*J�M���|4��g��[=� &$��w�74�r}$�M<)p��EJ2GME���MҨ9��ɨ�^w(We�$��� O�� ��V �)��C��_�9���J�$���/�:DG]d���WK�s��s��<�[ �V�tB��)?�����0_!��!��4�E�ǩy���PK��LNm�(�AdocProps/app.xml�S�n�0 ��+ �9�0 ���H7��`��gU�c��$����';��4;M�G��鉤����Y �w[.r��Ӿ4�X���ϻ�,CR�T�;(X�����>@$�%���šs�54 ��R��Q��x侪��G�O 8�<���L�J(��$�.���W�����/�.$=)B�F+J��[��G_Q��� >/�$�}��:� >�^+ �$,+e�H�'P}�v�D���u �|���I][��M!�v ֪h�#v�]�ۀ嫏�X >%8�α�*�!�k"��$|m�`���v*�?/�l�q�ei^�ISf ҍ���O�l|��f#��|z/�X[��z� �2����?*����I��U�2�l�ϔO�!���M��ʑs[����#�r����d� ����/PK��LN(H��docProps/core.xml��IO�0��� ���I[��M@�hY��Z�Ķ�4�'iӲܸD�7_f��8_W%��5��RJ�H��YL���&9�$�0J����6�9?(�˥�0�ցG �D� �t�Dt9cA.�a&�o�Wc�� � `�4=f�Pk���t�Tr@�_v%�P����Q�v^_�?:e�Yil�i݊�{�`��zTv�8�^��fݪ�6mT(/�̥����*��S_)�Ǡ�4���?����!���`�-�f��ĩ�~���|xy5��|�fgI:N��<;ɳ�������x|�z-�$3�R�%m��vڵ������y'E�lMm� � pW���]X��ҏ��-�/PK��LN���Jxl/theme/theme1.xml�Y[s�8~�_��{k 6%��L ��i3 �N��Ud�#����=���X��Mgw��,�;������/)'wT*&���=�9�f��X������C��,.2:v�T9�g��S�Д$��)��D���uU�۠���fxo%d �2v# ��6�n���)��!����j�BJK�l�|��+Ӫ��� K�m����GmՔKr|제H�/��J㍱�+?�{���q}��E7/?5]M��%���{Bo����W����l6�y{~%�-�:X>�&;�-Pu��=�=�ķ�:���d��A��;�Qo�_� ���������th��?���/N���/A gٺ�.⹏����>B�h� �meWE��C���g!�(� �eDos��qSH��A!N)��T[��l�� %����+��r~N΋�����㔉��� ��.$,۰K�"��=�)jnaL��q��A "-��N �-pnBMG}�X�6��gC��Dn4��$���O�����6g��v�r�����dO�s��1O���4����� 1ͨ&�=���B��1ïW,�B��&����d���N����-�Cm���#�ncI�L{:content:}amp;?pK� 7����Ԫ1���| :�)y����p�1�1��"�������3ְ_�mj"�fk�-�F^��4�4��̲���S�1E�\ mUB�R�1� �GF�����{�w6���FwMY��V���_��^�c��`���m�6�5�L��Uw�_����c{i�>��L[�K�+����r�V��W���7�EI����/kq.�P^)��L'� �(�+%Īf+� �S�s�wydh|���o�}%�j{�>��ٔ�X� � ��1a^vV8'�e�#?U4 �q6vB]���b~h�=-��A� �T�TRQ��v�=�F�~�~x���b0��E-܇��� ���fY�M�mݓ%��@��*�"����-$V�_'�Y�u<|�RW�<��'�Z�����^�r�R�=��w�2xBS�_ה"sqlD�q � ��ѱ#�Nv����\�Σ�q��;F5!�~���r����{���������v�%�2��X~FٗxP�p��wE_�9ݽ�G>nCz�PK��LN���ן�xl/sharedStrings.xml]�A �0н���� "��H���Ўm����T��������0�z�A=1sHdaS������,\/��������*�2̢�)��^d/�� ٮ �� J>\�vJ��_/^���J�'�\wJϐ8�� ē���v�:�$Nڗ����V�E��HO�d�� �m���)ס�����T�8�Q{d� g���8f�^�NI�4E��*�k�_��OW �/�kU�9-)q0���1v��4��!�Ӗ ���� W��.�������_��֟L3����]P�7GN}i�ƥi�������!g3����X��8Fi�e�p� ��Y� �'z��Ə�M^A�]ÒJ�M_�PK��LNp�o��xl/workbook.xml�QMO1��WX��MP��(���"��*)�{��-�lB��;����7�珃W[Ȅ1�zz2� ���}���/�Њ�g| ��=�>_�[�b~����d~A�X�� y �$��gN��!��`�{:content:}amp;R�b �� Ɍq������� �g�E~ G�:�p�8@�IoX$Q���j١�ۃJeR�a���k� �� ��3�q�yL�F��'sݬ^���J|�պG�{.��ov���@e,��f�jqڌ/�3� ��5�1UߧZu��o�/�s��>��Qw�bƧ�����u��l���g���l~�Z}6�-n�#�[]����?���Q���z�R�n��<�mR�ruE^�<�U�㼃�bI^β�I u�t6�~�_���.����%�3|���Σ���PK��LN�W9�Yxl/worksheets/sheet1.xml�UKs�0��Wxt/6�<�`2M(Mg�I&��,�5V#K�$��_�����C9�����.�׊G-(ͤH�x��D&s&6)yz\�?'�6T�K)ف&�w�T/�0�tM3��hP- ��Ҙz�:+��z$kxSHUQ����mh�*O��4�(�a���C�`)��a<�N �KVk��;wj1���L���tSUT�.��-�N:��mJc�x1�{��!��R��Hɧ�l�4��w[}p� ]?��@�m��R��˯a�u)�_�o0,�Q x�^n�$�Ʋ�Xk$v\�9ş��s���1���V�j�{m�AW�ҝ��NH�s-�{[�d�adCO���}G.Ɋ��dYnʔ�������I���5h�b��6k��ճW0;{�{�'��{��=���|z2�g����yI ]̕�F�wVM�8�g�13 ��sw�o�]$�4A��Xc<Ը:֘ 5�C %�u��2t�4�Ü���r����u/� UL�?��#�0ɛJ�E����0�=���] {�e��hx��������@>�VK�O�6F�7�z�f�4�t��-ۓ��|X�Z1ank����~ȃq�<@�]ֈn�UL5�P�M2:#�����F������J�-�4�u��/:jꨦX�� \KH�p]�-����S����`�Q� "�aܶ�nW�_������y�����bŔ6�����)qswE9���B�v�����{pƣ���J�ꇂ=��BaC�M�z��tX���oPK��LN�KR"x�#xl/worksheets/_rels/sheet1.xml.relsM�1!{_A��@ c�q����p+a!,1�{)-'��y����$�p� (bW�����~ݟAIG�0& _X��|��}4b5&,B�����@e*�x�gi���uE�BO�h�I����PK��LNG�D�X���[Content_Types].xmlPK��LN�78�K ���_rels/.relsPK��LN�$�V�����xl/_rels/workbook.xml.relsPK��LNm�(�A���docProps/app.xmlPK��LN(H����zdocProps/core.xmlPK��LN���J��-xl/theme/theme1.xmlPK��LN���ן���� xl/sharedStrings.xmlPK��LN���. ��y xl/styles.xmlPK��LNp�o�����xl/workbook.xmlPK��LN�W9�Y���xl/worksheets/sheet1.xmlPK��LN�KR"x�#���xl/worksheets/_rels/sheet1.xml.relsPK �{[]


Okay maybe try this:

ob_end_clean();
ob_start();
$Writer->save('php://output');
// I used phpexcel to email the excel file to the user with a button . I had no issue. If you need the code I will post. I am running on php 7.0 with no issues. Note PHPexcel is deprecated and there is a new version called phpexcelspreadsheet.
// . See Admin answer above though!!!! If you are just outputting then do in event instead of button I would think.

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users