How to save report data to excel file steps?

hi,

anybody know the steps to save report data to excel file.

i tried with printjobsettings() in init method but its not working for me

( this.printJobSettings().setTarget(PrintMedium::File);

this.printJobSettings().preferredFileFormat(PrintFormat::ASCII); )

please give me all steps to do it.

any help would be appreciated…

thanks

Hi,

write the below code in your report init method after super(),

//Set the print target. In this case, set the target to mail.

element.printJobSettings().setTarget(printmedium::File);

// Indicate the preferred target to verify that the printing will go to mail.

element.printJobSettings().preferredTarget(PrintMedium::File);

// Specify the format of the mail. In this case, specify PDF.

element.printJobSettings().format(PrintFormat::ASCII);

// element.printJobSettings().fileName(""); // here path inlcudes file location to store and file name with .xls extension format. for ex., path is D:\MyReport.xls

Hi Manjunadh,

thanks for quick reply,

i tried that. but when i open report nothing is happen.

when i open that xls. file it is showing me blank

hi Manjunadh,

can you please tell me why this is happenning.

thanks ,

Have u given path name correctly? check once…

path should be a string like “D:\MyReport.xls”.

hi Manjunadh,

yes i have given the path same as you said but still it showing .xls file blank

is this the only method to do that ? can you please send me the whole code for that?

thanks

Hi,

excel file is creating on specified path means then it is clear that ur report is not fetching data…pls check ur fetch method code…

hi,

now data is showing in excel file.

thanks…

@Sunny,

otherwise you run the report normally,after u got the report click print icon and then click on save icon here u can select for different file types to save.

for example u want excel give filename.xls and select in drop down list as ANSII.

for pdf give filename .pdf and select in the drop downlist as pdf .