4 solutions

Solution 1

I assume you intend: "How to report database data on a PDF document or an Excel one".
To write a PDF document you need a library. You may write to Excel using automation or, for instance via OLEDB. You may find many tutorials about all these techniques.

Solution 3

The code which I used in asp.net for downloading the data as excel format:

first store all the values into a dataset. Then take one string builder and append all the values of dataset in a table format. Then pass that string builder to the stringwriter as below and follow the overall code below:

Here below "sb" means stringbuilder object as example

// Save the format as MsExcel file in a folder(.xls) StringWriter sw = new StringWriter(sb);