Click here to Skip to main content
15,867,950 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
Posted
Comments
[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[^]
 
Share this answer
 
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
 
Share this answer
 
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();

controlRange.execCommand("Copy");

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.Paste;

objExcel.Cells.ColumnWidth=20;

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

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

//objExcel.Cells.RowWidth=20;

objExcel.Cells.columns.AutoFit;

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

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

objExcel.Cells.rows.AutoFit;

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

{

objWorksheet.Shapes(1).Visible=-1;

objWorksheet.Shapes(2).Visible=0;

}

objExcel.Application.Dialogs(5).Show('C:\\DocumentsandSettings\\arun\\');

// objExcel.Visible = false;
}
 
Share this answer
 

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