• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Valence download of excel file get damaged

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Valence download of excel file get damaged


    Hello,

    We have an app based on DD#4. The download of uploaded excel files seems to corrupt the downloaded file. The download is initiated by a grid row button.
    This functionality worked before. Currently we are using version 6.0.20211111.0

    Opening the downloaded excel file locally gives this error:
    PHP Code:
    We found a problem with some content in ’Ludoma_Warehouse_Status_Valence_Download.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbookclick Yes
    After pressing Yes:
    PHP Code:
    Repair Result to Ludoma_Warehouse_Status_Valence_Download0.xml
    Errors were detected in file ’
    /Users/theo/Downloads/Ludoma_Warehouse_Status_Valence_Download.xlsx’

    Excel completed file level validation 
    and repairSome parts of this workbook may have been repaired or discarded
    When the same file is downloaded with ftp it can be opened fine. See attachments for both files.

    The RPG code used:
    PHP Code:
    lDocOid = %int(%char(GetAppVar('DocOid')));

    Exec sql
    select trim
    (fullname), trim(nameinto lFullName, : lName from libbes where oid = : lDocOid;

    If 
    SqlCod 0;

    SetResponse('success':'false');
    SetResponse('msg':'Error: Document not found');

    Else;

    vvOut.download '1';
    vvOut.file = %trim(lName);
    vvOut_file(%trim(lFullName):vvOut);

    SetResponse('success':'true');
    SetResponse('info':'File ' + %trim(lName) + ' downloaded successfully,');

    EndIf; 
    Kind regards,
    Theo
    Attached Files

  • #2
    Hi Theo -

    Is the downloaded file the same number of bytes when you download via Valence versus FTP?

    Comment


    • #3
      Hi Sean,

      The FTP version: 13.619 bytes
      The Valence download version: 13.784 bytes

      Regards,
      Theo

      Comment


      • #4
        This is what I get from a diff on the unzipped xlsx files:

        Code:
        theo@~/Downloads$ diff -rq Valence Ftp
        Files Valence/.DS_Store and Ftp/.DS_Store differ
        Files Valence/xl/.DS_Store and Ftp/xl/.DS_Store differ
        Files Valence/xl/externalLinks/.DS_Store and Ftp/xl/externalLinks/.DS_Store differ
        theo@~/Downloads$

        Comment


        • #5
          Theo, would it be possible for you to export your app -- or a "dumbed down" version of it that exhibits the same problem -- and email the save file to us so we can run the app on our system and try to replicate what you're seeing?

          Please also send the source for the RPG program, and if there are any physical files needed for the data source(s) please send us a separate save file of those as well. Hopefully that'll make it easier for us to isolate the problem.

          Comment


          • #6
            I just sent you the email with all the information requested.
            Kind regards,
            Theo

            Comment


            • #7
              Hi Theo,

              Sorry we didn't notice this before, but the root cause of the problem you're having became clear once we took a closer look at your program handling the download process...

              Code:
              // --------------------------------------------------------------
              // Get Document
              // --------------------------------------------------------------
              dcl-proc GetDoc;
                dcl-pi GetDoc;
                end-pi;
              
                dcl-s lDocOid int(10);
                dcl-s lName char(64);
                dcl-s lFullName varchar(500);
              
                lDocOid = %int(%char(GetAppVar('DocOid')));
              
                Exec sql
                   select trim(fullname), trim(name)
                     into :lFullName, :lName
                     from libbes
                    where oid = :lDocOid;
              
                If SqlCod > 0;
                  SetResponse('success':'false');
                Else;
                  vvOut.download = '1';
                  vvOut.file = lName;
                  vvOut_file(lFullName:vvOut);
              
                  SetResponse('success':'true');
                  SetResponse('info':'File ' + %trim(lName) + ' downloaded successfully,');
                EndIf;
              
                Return;
              end-proc;
              Your button program first sends the requested spreadsheet file to the browser via a call to vvOut_file(), which is fine.

              But after that you're appending some JSON text via two SetResponse() calls. From the browser's perspective, this is essentially adding extra bytes to the .xlsx file it's receiving and, from Excel's standpoint, is corrupting the file with data it doesn't understand.

              Removing those two SetResponse() calls will resolve your problem. You can't mix your payload with both a downloaded file and JSON text; it must be one or the other.

              Comment

              Working...
              X