BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi Cornel,
Thanks for using Syncfusion products.
We are unable to reproduce the reported errors from the provided code. Could you please share the following information to us to sort out the cause of the issue and provide you the solution as early as possible?
1. Share the replication procedure of the issue, which you faced while exporting.
2. Also update us what you have mentioned in the payments parameter given in the below table.
ExportToExcel(GridModel, payments); return Json("done"); |
3. Where you are using the below mentioned data in your sample?
case 0: data = GetPeopleOlderThan(30); break; case 1: data = GetPeopleYoungerThan(30); break; |
4. Share your full grid code snippet to us.
We have created a export sample using two parameters in ExportToExcel() method. One parameter is GridModel and another one is data. Please refer the following code snippet.
public ActionResult GetGridData(int? id, string GridModel) { var data = new List<Order>(); IEnumerable res; if (!id.HasValue) id = 0; switch (id) { case 0: data = new NORTHWNDEntities1().Orders.ToList(); break;
case 1: data = new NORTHWNDEntities1().Orders.ToList(); break; } ExportToExcel(GridModel, data); return Json("done"); }
public void ExportToExcel(string GridModel, IEnumerable dataSource) { ExcelExport exp = new ExcelExport(); GridProperties obj = ConvertGridObject(GridModel); exp.Export(obj, dataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); }
function toolbarClick(args) { switch (args.itemName) { case "Excel Export": var dropDown = $("#status").data("ejDropDownList"); var selectedValue = dropDown.getSelectedValue(); this.export("/Home/GetGridData/" + selectedValue); args.cancel = true; break; } } |
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/118253/Sample_118253315599700.zip
Please try the above sample if we misunderstood your query get back to us with the mentioned details.
Regards,
Hi Cornel,
Thanks for using Syncfusion products.
We are unable to reproduce the reported errors from the provided code. Could you please share the following information to us to sort out the cause of the issue and provide you the solution as early as possible?
1. Share the replication procedure of the issue, which you faced while exporting.
2. Also update us what you have mentioned in the payments parameter given in the below table.
ExportToExcel(GridModel, payments);
return Json("done");
3. Where you are using the below mentioned data in your sample?
case 0:
data = GetPeopleOlderThan(30);
break;
case 1:
data = GetPeopleYoungerThan(30);
break;
4. Share your full grid code snippet to us.
We have created a export sample using two parameters in ExportToExcel() method. One parameter is GridModel and another one is data. Please refer the following code snippet.
public ActionResult GetGridData(int? id, string GridModel)
{
var data = new List<Order>();
IEnumerable res;
if (!id.HasValue)
id = 0;
switch (id)
{
case 0:
data = new NORTHWNDEntities1().Orders.ToList();
break;
case 1:
data = new NORTHWNDEntities1().Orders.ToList();
break;
}
ExportToExcel(GridModel, data);
return Json("done");
}
public void ExportToExcel(string GridModel, IEnumerable dataSource)
{
ExcelExport exp = new ExcelExport();
GridProperties obj = ConvertGridObject(GridModel);
exp.Export(obj, dataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");
}
function toolbarClick(args) {
switch (args.itemName) {
case "Excel Export":
var dropDown = $("#status").data("ejDropDownList");
var selectedValue = dropDown.getSelectedValue();
this.export("/Home/GetGridData/" + selectedValue);
args.cancel = true;
break;
}
}
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/118253/Sample_118253315599700.zip
Please try the above sample if we misunderstood your query get back to us with the mentioned details.
Regards,
Sellappandi R
Hi Cornel,
We are sorry to let you know that we are unable to get your requirements. Could you please provide the details regarding your achievements of this project. This will be helpful to sort out your requirements.
Regards,
public void ExportToPdf(string GridModel) { PdfDocument document = new PdfDocument(); document.DocumentInformation.Title = "Essential PDF Sample"; document.PageSettings.Orientation = PdfPageOrientation.Landscape;//Sets landscape page orientation. PdfExport exp = new PdfExport(); var DataSource = new NorthwindDataContext().OrdersViews.ToList(); GridProperties obj = ConvertGridObject(GridModel); PdfDocument pdfdocument = exp.Export(obj, DataSource, "Export.pdf", true, true, "flat-saffron", true, document, document.DocumentInformation.Title);
MemoryStream ms = new MemoryStream(); pdfdocument.Save(ms); pdfdocument.Close(true); ms.Position = 0; PdfLoadedDocument ldDoc = new PdfLoadedDocument(ms); pdfdocument = new PdfDocument(); pdfdocument.PageSettings.Margins.All = 0; //Get the templates from loadeddocument. for (var i = 0; i < ldDoc.Pages.Count; i++) { PdfTemplate template = ldDoc.Pages[i].CreateTemplate(); pdfdocument.Pages.Add(); pdfdocument.Pages[i].Graphics.DrawPdfTemplate(template, new PointF(0, 0)); } RectangleF rect = new RectangleF(0, 0, pdfdocument.PageSettings.Width, 50);
//Create a page template PdfPageTemplateElement footer = new PdfPageTemplateElement(rect); PdfPageTemplateElement header = new PdfPageTemplateElement(rect); Font f = new Font("Helvetica", 8, FontStyle.Regular); PdfFont font = new PdfTrueTypeFont(f, true); PdfSolidBrush brush = new PdfSolidBrush(Color.Gray); PdfPen pen = new PdfPen(Color.DarkBlue, 3f); f = new Font("Helvetica", 6, FontStyle.Bold); font = new PdfTrueTypeFont(f, true); PdfStringFormat format = new PdfStringFormat(); format.Alignment = PdfTextAlignment.Center; format.LineAlignment = PdfVerticalAlignment.Middle; footer.Graphics.DrawString("Custom Text - Footer", font, brush, rect, format); //Add custom text to the header header.Graphics.DrawString("Custom Text - Header", font, brush, rect, format); //Add custom text to the footer
pdfdocument.Template.Bottom = footer; //Append custom template to the document pdfdocument.Template.Top = header; pdfdocument.Save("Export.pdf", HttpContext.ApplicationInstance.Response,HttpReadType.Save); |