Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to convert the database data into pdf or excel format
Posted

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.
 
Share this answer
 
v3
 
Share this answer
 
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);

File.WriteAllText(HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString() + "\\folder path\\" + filename + ".xls", sb.ToString());
sw.Flush();
sw.Close();
sw.Dispose();

//To DownLoad the excel file. Set the appropriate ContentType.
Response.ContentType = "Application/vnd.ms-excel";
//Get the physical path to the file.
string filePath = HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"].ToString() + "\\folderpath\\" + currYear + ".xls";
Response.AppendHeader("content-disposition", "attachment; filename= " + filename + ".xls");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(filePath);
Response.End();

Now first the file will be stored in your folderpath and automatically it will ask to download..

If u want how to write dataset into a stringbuilder means ask. I will give small example..
 
Share this answer
 
I want to upload pdf data(What ever details in pdf document sya roll number student name marks..etc) in aql server database using asp.net...
 
Share this answer
 
Comments
[no name] 24-May-13 8:24am    
So? How does this answer this already answered question that is over a year old?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900