Question

Je dois exporter un peu (peut-être juste un ou plusieurs) Graphiques Microsoft au format PDF et Excel. Il doit se passer sur un bouton clic et les graphiques doivent être directement exportées vers un fichier PDF sans se rendre sur une page Web.

Environnement utilisé: ASP.NET

S'il vous plaît suggérer l'approche pour y parvenir.

hourras

Était-ce utile?

Autres conseils

Voici un exemple de code pour l'exportation contrôle graphique MS Excel. Espérons que cela aide.

    string tmpChartName = "test2.jpg";
    string imgPath = HttpContext.Current.Request.PhysicalApplicationPath + tmpChartName;

    Chart1.SaveImage(imgPath);
    string imgPath2 = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/" + tmpChartName);

    Response.Clear();
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("Content-Disposition", "attachment; filename=test.xls;");
    StringWriter stringWrite = new StringWriter();
    HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    string headerTable = @"<Table><tr><td><img src='" + imgPath2 + @"' \></td></tr></Table>";
    Response.Write(headerTable);
    Response.Write(stringWrite.ToString());
    Response.End();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top