تصدير الرسوم البيانية MS إلى PDF و Excel
-
19-09-2019 - |
سؤال
أحتاج إلى تصدير بعض مخططات Microsoft فقط أو أكثر من واحد) إلى PDF و Excel. يحتاج إلى حدوث ذلك على زر النقر ويجب تصدير المخططات مباشرة إلى PDF دون الحصول على صفحة ويب.
البيئة المستخدمة: ASP.NET
يرجى اقتراح النهج لتحقيق ذلك.
في صحتك
المحلول
نصائح أخرى
فيما يلي رمز عينة لتصدير عنصر تحكم MS Chart إلى Excel. أتمنى أن يساعدك هذا.
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();
لا تنتمي إلى StackOverflow