Click here to Skip to main content
14,976,254 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a requirement of exporting a formated div content to pdf. my page has information about a student profile with some grid view data and plain asp lable control. plz give the solution if any
[no name] 16-Sep-14 8:01am
show your code,
also check my solution as a tip

This is asked many times meaning if you just google it you'll find lots of examples. Here is a recent question of the same that has many links to get you going.

How Do I Convert Div Region Into Pdf And Excel Format Using C# In Offline[^]
you need to use linq to xml to read the div content or use regex once you get the data use one of this tools to create pdf file from scratch , here they are itext , pdfsharp
i have tried this funtion to export to excel you can try like this ,may be it help you

function exportToExcel() {

controlRange = document.getElementById("bdy1").createTextRange();


var objExcel = new ActiveXObject("Excel.Application");

// objExcel.Visible = true;

objExcel.Visible = false;

var objWorkbook = objExcel.Workbooks.Add;

objExcel.Application.IgnoreRemoteRequests = true;

var objWorksheet = objWorkbook.Worksheets(1);



objWorksheet.Range("A12", "A20").ColumnWidth=2;

objWorksheet.Range("B12", "B20").ColumnWidth=2;



objWorksheet.Range("A12", "A20").EntireColumn.AutoFit;

objWorksheet.Range("B12", "B20").EntireColumn.AutoFit;


if(objWorksheet.Shapes(1).Name == "Picture 1")






// objExcel.Visible = false;

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