000100 *==================================================================== 000000 000200 * RPG ILE XLSCGI/SAMPLECGI3 000000 000300 * Just generates a spreadsheet and sends it to the browser 000000 000400 * 000000 000500 * CRTBNDRPG PGM(XLSCGI/SAMPLECGI3) DFTACTGRP(*NO) ACTGRP(SAMPLECGI3) DBGVIEW(*LIST) 000000 000600 * 000000 000700 *==================================================================== 000000 000800 /copy xlscgi/qrpglesrc,hspecs 000000 000900 /copy xlscgi/qrpglesrc,hspecsbnd 000000 001000 FSAMPLEFILEif e k disk usropn 000000 001100 F extfile('XLSCGI/SAMPLEFILE') 000000 001200 /copy XLSCGI/qrpglesrc,prototypeb 000000 001300 /copy XLSCGI/qrpglesrc,usec 000000 001400 /copy XLSCGI/qrpglesrc,variables3 000000 001500 /copy XLSCGI/qrpglesrc,xlscgiprot 000000 001600 * Other variables 000000 001700 D extHtml s 2000 varying 000000 001800 * Indicators for GetHtmlIfsMult subprocedure 000000 001900 D IfsMultIndicators... 000000 002000 d ds 000000 002100 D NoErrors n 000000 002200 D NameTooLong n 000000 002300 D NotAccessible n 000000 002400 D NoFilesUsable n 000000 002500 D DupSections n 000000 002600 D FileIsEmpty n 000000 002700 * 000000 002800 D inpNumber s 30p 9 000000 002900 *======================================================================== 000000 003000 * Main line 000000 003100 *======================================================================== 000000 003200 /free 000000 003300 000000 003400 fixJobCCSID(); //change job CCSID if 65535 160512 003500 SetNoDebug(*on); //do not write records to file CGIDEBUG 160512 003600 000000 003700 //Load external HTML 160512 003800 exthtml ='/xlscgi/html/samplecgi2.xml ' + //XML sections for Spreadsheet 160512 003900 '/xlscgi/html/goxls.htm'; //bootstrap HTML for Spreadsheet stmf 160512 004000 IfsMultIndicators = getHtmlIfsMult(exthtml:'<as400>'); 160512 004100 160512 004200 //Open file 160512 004300 if not %open(samplefile); 160512 004400 open samplefile; 160512 004500 endif; 160512 004600 160512 004700 //Start spreadsheet 160512 004800 wrtsection('XMLtop'); 160512 004900 160512 005000 //Write spreadsheet rows 160512 005100 samppartno=*loval; 160512 005200 setll samppartno samprcd; 160512 005300 read samprcd; 160512 005400 dow not %eof; 160512 005500 //remove unsupported characters from character fields 160512 005600 samppartno=fixString(samppartno); 160512 005700 sampdescrn=fixString(sampdescrn); 160512 005800 updhtmlvar('samppartno':samppartno); 160512 005900 updhtmlvar('sampdescrn':sampdescrn); 160512 006000 inpNumber=sampsales1; 160512 006100 updhtmlvar('sampsales1':edtNumber(inpNumber)); 160512 006200 inpNumber=sampsales2; 160512 006300 updhtmlvar('sampsales2':edtNumber(inpNumber)); 160512 006400 inpNumber=sampsales3; 160512 006500 updhtmlvar('sampsales3':edtNumber(inpNumber)); 160512 006600 inpNumber=sampsales4; 160512 006700 updhtmlvar('sampsales4':edtNumber(inpNumber)); 160512 006800 wrtsection('XMLrow'); 160512 006900 read samprcd; 160512 007000 enddo; 160512 007100 160512 007200 //End spreadsheet 160512 007300 wrtsection('XMLbot'); 160512 007400 160512 007500 //Send the output to the browser 160512 007600 sndToExcel(); 160512 007700 160512 007800 //Back to the caller 160512 007900 return; 160512 008000 160512 008100 /end-free 000000 008200 /copy XLSCGI/qrpglesrc,sndtoexcel 000000