Пример #1
0
        static void ExportTo(string title, string filter, string exportFormat, ImageFormat format, bool checkPrinterAvailable)
        {
            ChartControl chart = PrepeareForPrintOrExport(checkPrinterAvailable);

            if (chart == null)
            {
                return;
            }
            string fileName = ShowSaveFileDialog(title, filter);

            if (fileName != "")
            {
                Cursor currentCursor = Cursor.Current;
                Cursor.Current = Cursors.WaitCursor;
                switch (exportFormat)
                {
                case "HTML":
                    chart.ExportToHtml(fileName);
                    break;

                case "MHT":
                    chart.ExportToMht(fileName);
                    break;

                case "PDF":
                    PrintSizeMode sizeMode = chart.OptionsPrint.SizeMode;
                    chart.OptionsPrint.SizeMode = PrintSizeMode.Zoom;
                    try
                    {
                        chart.ExportToPdf(fileName);
                    }
                    finally
                    {
                        chart.OptionsPrint.SizeMode = sizeMode;
                    }
                    break;

                case "XLS":
                    chart.ExportToXls(fileName);
                    break;

                case "IMAGE":
                    chart.ExportToImage(fileName, format);
                    break;
                }
                Cursor.Current = currentCursor;
                OpenFile(fileName);
            }
        }
Пример #2
0
        private void ExportChartToHTML(ChartControl chart)
        {
            // Create an object containing HTML export options.
            HtmlExportOptions htmlOptions = new HtmlExportOptions();

            // Set HTML-specific export options.
            htmlOptions.CharacterSet           = "utf-8";
            htmlOptions.RemoveSecondarySymbols = false;
            htmlOptions.Title = "Unicode UTF-8 Example";

            // Specify print size mode.
            PrintSizeMode sizeMode = PrintSizeMode.Stretch;

            // Export a chart to an HTML file.
            chart.ExportToHtml("OutputUnicode.html", htmlOptions, sizeMode);
            Process.Start("OutputUnicode.html");
        }
Пример #3
0
 /// <summary>
 ///     导出图片
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="ext"></param>
 private void ExportToCore(ChartControl chart, string filename, string ext)
 {
     try
     {
         if (chart != null)
         {
             var currentCursor = Cursor.Current;
             Cursor.Current = Cursors.WaitCursor;
             if (ext == "rtf")
             {
                 chart.ExportToRtf(filename);
             }
             else if (ext == "pdf")
             {
                 chart.ExportToPdf(filename);
             }
             else if (ext == "mht")
             {
                 chart.ExportToMht(filename);
             }
             else if (ext == "html")
             {
                 chart.ExportToHtml(filename);
             }
             else if (ext == "xls")
             {
                 chart.ExportToXls(filename);
             }
             else if (ext == "xlsx")
             {
                 chart.ExportToXlsx(filename);
             }
             else
             {
                 ImageFormat currentImageFormat = null;
                 if (ext.ToLower().Contains("bmp"))
                 {
                     currentImageFormat = ImageFormat.Bmp;
                 }
                 else if (ext.ToLower().Contains("jpg"))
                 {
                     currentImageFormat = ImageFormat.Jpeg;
                 }
                 else if (ext.ToLower().Contains("png"))
                 {
                     currentImageFormat = ImageFormat.Png;
                 }
                 else if (ext.ToLower().Contains("gif"))
                 {
                     currentImageFormat = ImageFormat.Gif;
                 }
                 chart.ExportToImage(filename, currentImageFormat);
             }
             Cursor.Current = currentCursor;
         }
     }
     catch (Exception ex)
     {
         LogHelper.Error("Kgl_StateChg_ExportToCore" + ex.Message + ex.StackTrace);
     }
 }