pass xlsx file to angular js2019 Community Moderator ElectionHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?Php: Keep same filename when downloading from serverWhat is the difference between angular-route and angular-ui-router?download docx file from PHP REST API with angularjsChrome Excel file download errorHow to download an excel file in Safari-Mac-Desktop (JavaScript)Ignore/ remove error message while opening .xlsx file through codeERROR_MESSAGE_MAIN ERROR_MESSAGE_REASON on iPad and iPhone SafariDownload Excel not working in IPadDownload .xlsx file using an api returns XML formatted file? VB.NET

Rewrite the power sum in terms of convolution

Solar Charging Car Battery through Cigarette Lighter Outlet?

How to save the initial startup configuration in IOS XR?

'The literal of type int is out of range' con número enteros pequeños (2 dígitos)

Do items de-spawn in Diablo?

cat shows nothing

They call me Inspector Morse

Why does liquid water form when we exhale on a mirror?

How to draw cubes in a 3 dimensional plane

What does "promotional consideration" at the end credits mean?

Signed and unsigned numbers

Why doesn't this Google Translate ad use the word "Translation" instead of "Translate"?

Should I take out a loan for a friend to invest on my behalf?

Error during using callback start_page_number in lualatex

How strictly should I take "Candidates must be local"?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

List elements digit difference sort

Could you please stop shuffling the deck and play already?

What problems would a superhuman have whose skin is constantly hot?

I reported the illegal activity of my boss to his boss. My boss found out. Now I am being punished. What should I do?

Why the color red for the Republican Party

Why would one plane in this picture not have gear down yet?

What are the practical Opportunty Attack values for a bugbear, holding a reach weapon, with Polearm Mastery?

Find longest word in a string: are any of these algorithms good?



pass xlsx file to angular js



2019 Community Moderator ElectionHow to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?Php: Keep same filename when downloading from serverWhat is the difference between angular-route and angular-ui-router?download docx file from PHP REST API with angularjsChrome Excel file download errorHow to download an excel file in Safari-Mac-Desktop (JavaScript)Ignore/ remove error message while opening .xlsx file through codeERROR_MESSAGE_MAIN ERROR_MESSAGE_REASON on iPad and iPhone SafariDownload Excel not working in IPadDownload .xlsx file using an api returns XML formatted file? VB.NET










0















I'm trying to pass an xlsx file that I generated in php with the excelphp library, to my frontend that is in angular js. To download the file I am using the angular file saver library. All this works correctly, the problem is that I can not open the file, it indicates that it is corrupt.



this is my php code for send response type:



$response = new Response();
$response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
$response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
$response->headers->set('Cache-Control', 'max-age=0');
$response->headers->set('Cache-Control', 'max-age=1');

$response->headers->set('Cache-Control', 'cache, must-revalidate');
$response->headers->set('Pragma', 'public');
$response->headers->set('Access-Control-Allow-Origin', '*');

$response->prepare($request);
$response->sendHeaders();
ob_end_clean();
$objWriter->save('php://output');
exit();


this works perfectly.



this is my angular js code:



const file = await service.exportExcel(itemId);

const blob = new Blob([file], type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

FileSaver.saveAs(blob, "Export.xlsx");


this download the file perfectly, but this is the content generated:



enter image description here



what is the problem here?










share|improve this question


























    0















    I'm trying to pass an xlsx file that I generated in php with the excelphp library, to my frontend that is in angular js. To download the file I am using the angular file saver library. All this works correctly, the problem is that I can not open the file, it indicates that it is corrupt.



    this is my php code for send response type:



    $response = new Response();
    $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
    $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
    $response->headers->set('Cache-Control', 'max-age=0');
    $response->headers->set('Cache-Control', 'max-age=1');

    $response->headers->set('Cache-Control', 'cache, must-revalidate');
    $response->headers->set('Pragma', 'public');
    $response->headers->set('Access-Control-Allow-Origin', '*');

    $response->prepare($request);
    $response->sendHeaders();
    ob_end_clean();
    $objWriter->save('php://output');
    exit();


    this works perfectly.



    this is my angular js code:



    const file = await service.exportExcel(itemId);

    const blob = new Blob([file], type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

    FileSaver.saveAs(blob, "Export.xlsx");


    this download the file perfectly, but this is the content generated:



    enter image description here



    what is the problem here?










    share|improve this question
























      0












      0








      0








      I'm trying to pass an xlsx file that I generated in php with the excelphp library, to my frontend that is in angular js. To download the file I am using the angular file saver library. All this works correctly, the problem is that I can not open the file, it indicates that it is corrupt.



      this is my php code for send response type:



      $response = new Response();
      $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
      $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
      $response->headers->set('Cache-Control', 'max-age=0');
      $response->headers->set('Cache-Control', 'max-age=1');

      $response->headers->set('Cache-Control', 'cache, must-revalidate');
      $response->headers->set('Pragma', 'public');
      $response->headers->set('Access-Control-Allow-Origin', '*');

      $response->prepare($request);
      $response->sendHeaders();
      ob_end_clean();
      $objWriter->save('php://output');
      exit();


      this works perfectly.



      this is my angular js code:



      const file = await service.exportExcel(itemId);

      const blob = new Blob([file], type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

      FileSaver.saveAs(blob, "Export.xlsx");


      this download the file perfectly, but this is the content generated:



      enter image description here



      what is the problem here?










      share|improve this question














      I'm trying to pass an xlsx file that I generated in php with the excelphp library, to my frontend that is in angular js. To download the file I am using the angular file saver library. All this works correctly, the problem is that I can not open the file, it indicates that it is corrupt.



      this is my php code for send response type:



      $response = new Response();
      $response->headers->set('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
      $response->headers->set('Content-Disposition', 'attachment;filename="' . $fileName . '"');
      $response->headers->set('Cache-Control', 'max-age=0');
      $response->headers->set('Cache-Control', 'max-age=1');

      $response->headers->set('Cache-Control', 'cache, must-revalidate');
      $response->headers->set('Pragma', 'public');
      $response->headers->set('Access-Control-Allow-Origin', '*');

      $response->prepare($request);
      $response->sendHeaders();
      ob_end_clean();
      $objWriter->save('php://output');
      exit();


      this works perfectly.



      this is my angular js code:



      const file = await service.exportExcel(itemId);

      const blob = new Blob([file], type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');

      FileSaver.saveAs(blob, "Export.xlsx");


      this download the file perfectly, but this is the content generated:



      enter image description here



      what is the problem here?







      php angularjs excel filesaver.js






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 15:15









      kmilo93sdkmilo93sd

      95110




      95110






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026402%2fpass-xlsx-file-to-angular-js%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55026402%2fpass-xlsx-file-to-angular-js%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown