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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhijit baruaPosted Jul 24, 2012, 4:03 AM
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
divyaPosted Jul 24, 2012, 2:04 AM
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
George ericPosted Jul 23, 2012, 9:18 PM