This topic is locked

PHPExcel

2/11/2019 7:18:51 PM
PHPRunner General questions
J
jorge.santos author

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');

lefty 2/12/2019



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
[color="#303336"]

// It will be called product.xlsx

[color="#303336"][font="inherit"]header

[color="#858C93"]
[color="#D73A49"][font="SFMono-Regular, Consolas,"]exit

J
jorge.santos author 2/12/2019

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�[ContentTypes].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�$���/�<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=87043&image=1&table=forumreplies' class='bbcemoticon' alt=':D' />G]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$&?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 �{[]

admin 2/12/2019

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.

lefty 2/12/2019



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�[ContentTypes].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�$���/�<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=87048&image=1&table=forumreplies' class='bbcemoticon' alt=':D' />G]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:
[color="#303336"]

[color="#303336"][font="inherit"]$Writer

[color="#303336"]// 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.