hai guys...
Is there any other way to export gridview data to pdf file without using crystal reports?
if any method is there please let me know??thanku in advance...
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
George ericRank #9,604 · 204 reputationPosted Jul 23, 2012, 5:18 PM EDT
divya146 reputationPosted Jul 23, 2012, 10:04 PM EDT
Presently iam using below code to convert data to pdf ..
public void SalarySlipToPDF(string month, string year, string org, string loc)
{
// Code for export the data into pdf format
try
{
path();
if (saveFileDialog1.FileName != "")
{
FileInfo info = new FileInfo(getpath);
string type = info.Extension;
CrystalDecisions.Shared.ExportFormatType tp = CrystalDecisions.Shared.ExportFormatType.Excel;
switch (type)
{
case ".pdf":
tp = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
break;
default: MessageBox.Show("Invalid File type you entered"); break;
}
string str = "Select * from vwSalary where Month='" + month + "' and Year='" + year + "' and Organisation='" + org + "' and Location='" + loc + "'";
System.Data.DataTable dt = cd.executeSelectQueryNonParameter(str);
rptSal rsl = new rptSal();
rsl.SetDataSource(dt);
crystalReportViewer3.ReportSource = rsl;
ReportDocument doc = new ReportDocument();
doc.Load("D:\\June Projects\\Payroll\\CCMS\\CCMS\\CCMS\\rptSal.rpt");
doc.SetDataSource(dt);
doc.ExportToDisk(tp, getpath);
if (type != ".pdf")
{
MessageBox.Show("PDF file not created");
}
else
{
MessageBox.Show("PDF file exported successfully");
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
when iam executing my project in another system the above path does not exists ,so it will raises an exception ..is there any way to avoid this issue...thanku in advance
Abhijit baruaRank #3,722 · 397 reputationPosted Jul 24, 2012, 12:03 AM EDT
http://www.codeproject.com/Tips/375965/How-to-convert-GridView-data-to-Excel-PDF-Word-fil
http://c-sharp-paradise.blogspot.in/2012/04/how-to-export-data-to-pdf-in-cnet.html