This topic is locked
[SOLVED]

 SCRIPT TO RENAME EXPORT CSV FILE

5/12/2011 3:14:58 AM
PHPRunner General questions
C
ckapote author

PLS ADVISE IF POSSIBLY TO RENAME THE NAME OF THE EXPORT CSV FILE EACH FILE ( IF POSSIBLE TO

GET THE VALUE FROM A TABLE FIELD (VIA A QUERY ?) INSTEAD THE NAME OF THE TABLE).
YOUR HELP WILL BE APPRECIATED.
RGDS

CHRIS

G
Grissom 5/12/2011

Hi Chris,
first of all I think you should fix your caps lock key as it's pretty hard to read caps only - and we ain't deaf either. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58284&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />
Regarding your issue:
I had the same problem and edited the export.php in the PHPRunner program directory (subdir sources) accordingly. Simply look for the line starting with



header("Content-Disposition: attachment;

This line is included in every exportable filetype function (XLS, DOC, etc.) and can also be placed at the very end of that specific subfunction and could look like
header("Content-Disposition: attachment;Filename=".$values["filename"]);
Above example above takes the filename from the db but that can be exchanged with about anything you want.
Chris

C
ckapote author 5/12/2011



Hi Chris,
first of all I think you should fix your caps lock key as it's pretty hard to read caps only - and we ain't deaf either. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58289&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' />
Regarding your issue:
I had the same problem and edited the export.php in the PHPRunner program directory (subdir sources) accordingly. Simply look for the line starting with



header("Content-Disposition: attachment;

This line is included in every exportable filetype function (XLS, DOC, etc.) and can also be placed at the very end of that specific subfunction and could look like
header("Content-Disposition: attachment;Filename=".$values["filename"]);
Above example above takes the filename from the db but that can be exchanged with about anything you want.
Chris


Thank you very much I will check .
I really sorry for my CAPS !
Rgds

C
ckapote author 5/12/2011

Change to
header("Content-Disposition: attachment;Filename=".$values["VesselRefNo"]);
but now when I press the export button it downloads the export.php file instead of csv .
pls help

G
Grissom 5/12/2011

Ah, ok. I just checked it on my side with the ExportToCSV function...
The start portion of that function looks like this:
function ExportToCSV()

{

global $rs,$nPageSize,$strTableName,$conn,$eventObj;

header("Content-Type: application/csv");

// header("Content-Disposition: attachment;Filename=##@TABLE.strShortTableName##.csv");
if($eventObj->exists("ListFetchArray"))

$row = $eventObj->ListFetchArray($rs);

else

$row = db_fetch_array($rs);

if(!$row)

return;
$totals=array();

Just add
$totals["VesselRefNo"] = GetData($row,"VesselRefNo","");

header("Content-Disposition: attachment;Filename=".$totals["VesselRefNo"].".csv");



below and you are done. Do not forget to either remove or comment out the "header" line at the top of the funcion (as I did in my example above)!
Chris

C
ckapote author 5/12/2011



Ah, ok. I just checked it on my side with the ExportToCSV function...
The start portion of that function looks like this:
function ExportToCSV()

{

global $rs,$nPageSize,$strTableName,$conn,$eventObj;

header("Content-Type: application/csv");

// header("Content-Disposition: attachment;Filename=##@TABLE.strShortTableName##.csv");
if($eventObj->exists("ListFetchArray"))

$row = $eventObj->ListFetchArray($rs);

else

$row = db_fetch_array($rs);

if(!$row)

return;
$totals=array();

Just add
$totals["VesselRefNo"] = GetData($row,"VesselRefNo","");

header("Content-Disposition: attachment;Filename=".$totals["VesselRefNo"].".csv");



below and you are done. Do not forget to either remove or comment out the "header" line at the top of the funcion (as I did in my example above)!
Chris


Thanks Working Fine .
Any idea to check if export file is emtpy no fields to cancel export operation with msg ?
rgds

G
Grissom 5/12/2011

That should be possible in the events section of the Export page (Export page:Before process). Simply add the already implemented action "Check if specific record exists" and adjust that code to your needs.
Chris

C
ckapote author 5/12/2011



That should be possible in the events section of the Export page (Export page:Before process). Simply add the already implemented action "Check if specific record exists" and adjust that code to your needs.
Chris


Thank you VERY MUCH !!<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58294&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Rgds