public static void Run()
        {
            // Instantiating a Workbook object
            Workbook workbook = new Workbook();

            // Adding a new worksheet to the Workbook
            int sheetIndex = workbook.Worksheets.Add();

            // Obtaining the reference of the newly added worksheet by passing its index to WorksheetCollection
            Worksheet worksheet = workbook.Worksheets[sheetIndex];

            // Adding sample values to cells
            worksheet.Cells["A1"].PutValue(50);
            worksheet.Cells["A2"].PutValue(100);
            worksheet.Cells["A3"].PutValue(150);
            worksheet.Cells["B1"].PutValue(4);
            worksheet.Cells["B2"].PutValue(20);
            worksheet.Cells["B3"].PutValue(50);

            // Adding a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);

            // Accessing the instance of the newly added chart
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];

            // Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3"
            chart.NSeries.Add("A1:B3", true);

            //------------------------------------------------
            //------------------------------------------------

            // Converting chart to image
            chart.ToImage(outputDir + "outputChartRendering.emf", System.Drawing.Imaging.ImageFormat.Emf);

            // Converting chart to Bitmap
            System.Drawing.Bitmap bitmap = chart.ToImage();
            bitmap.Save(outputDir + "outputChartRendering.bmp", System.Drawing.Imaging.ImageFormat.Bmp);

            //------------------------------------------------
            //------------------------------------------------

            //Rendering Chart To Image With Advanced Options
            // Create an instance of ImageOrPrintOptions and set a few properties
            ImageOrPrintOptions options = new ImageOrPrintOptions()
            {
                VerticalResolution   = 300,
                HorizontalResolution = 300,
                SmoothingMode        = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
            };

            // Convert chart to image with additional settings
            chart.ToImage(outputDir + "outputChartRendering.png", options);

            // Converting chart to PDF
            chart.ToPdf(outputDir + "outputChartRendering.pdf");

            Console.WriteLine("ChartRendering executed successfully.");
        }
        public static void Run()
        {
            // ExStart:ChartRenderingCreatingChart
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Instantiating a Workbook object
            Workbook workbook = new Workbook();
            // Adding a new worksheet to the Workbook
            int sheetIndex = workbook.Worksheets.Add();
            // Obtaining the reference of the newly added worksheet by passing its index to WorksheetCollection
            Worksheet worksheet = workbook.Worksheets[sheetIndex];

            // Adding sample values to cells
            worksheet.Cells["A1"].PutValue(50);
            worksheet.Cells["A2"].PutValue(100);
            worksheet.Cells["A3"].PutValue(150);
            worksheet.Cells["B1"].PutValue(4);
            worksheet.Cells["B2"].PutValue(20);
            worksheet.Cells["B3"].PutValue(50);

            // Adding a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);

            // Accessing the instance of the newly added chart
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
            // Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3"
            chart.NSeries.Add("A1:B3", true);
            // ExEnd:ChartRenderingCreatingChart

            // ExStart:ChartRenderingChartToImage
            // Converting chart to image
            chart.ToImage(dataDir + "chartEMF_out.emf", System.Drawing.Imaging.ImageFormat.Emf);

            // Converting chart to Bitmap
            System.Drawing.Bitmap bitmap = chart.ToImage();
            bitmap.Save(dataDir + "chartBMP_out.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
            // ExEnd:ChartRenderingChartToImage

            // ExStart:ChartRenderingChartToImageWithAdvancedOptions
            // Create an instance of ImageOrPrintOptions and set a few properties
            ImageOrPrintOptions options = new ImageOrPrintOptions()
            {
                VerticalResolution   = 300,
                HorizontalResolution = 300,
                SmoothingMode        = System.Drawing.Drawing2D.SmoothingMode.AntiAlias
            };

            // Convert chart to image with additional settings
            chart.ToImage(dataDir + "chartPNG_out.png", options);
            // ExEnd:ChartRenderingChartToImageWithAdvancedOptions

            // ExStart:ChartRenderingChartToPDF
            // Converting chart to PDF
            chart.ToPdf(dataDir + "chartPDF_out.pdf");
            // ExEnd:ChartRenderingChartToPDF
        }
        public static void Run()
        {
            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            // Create workbook object from source file
            Workbook workbook = new Workbook(sourceDir + "sampleExportChartToSvgWithViewBox.xlsx");

            // Access first worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // Access first chart inside the worksheet
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[0];

            // Set image or print options with SVGFitToViewPort true
            Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions();
            opts.SaveFormat       = SaveFormat.SVG;
            opts.SVGFitToViewPort = true;

            // Save the chart to svg format
            chart.ToImage(outputDir + "outputExportChartToSvgWithViewBox.svg", opts);

            Console.WriteLine("ExportChartToSvgWithViewBox executed successfully.");
        }
Beispiel #4
0
        public static void ConvertingCharttoPNG()
        {
            //Instantiating a Workbook object
            Workbook workbook = new Workbook();
            //Adding a new worksheet to the Excel object
            int sheetIndex = workbook.Worksheets.Add();
            //Obtaining the reference of the newly added worksheet by
            //passing its sheet index
            Worksheet worksheet = workbook.Worksheets[sheetIndex];

            //Adding a sample value to "A1" cell
            worksheet.Cells["A1"].PutValue(50);
            //Adding a sample value to "A2" cell
            worksheet.Cells["A2"].PutValue(100);
            //Adding a sample value to "A3" cell
            worksheet.Cells["A3"].PutValue(150);
            //Adding a sample value to "B1" cell
            worksheet.Cells["B1"].PutValue(4);
            //Adding a sample value to "B2" cell
            worksheet.Cells["B2"].PutValue(20);
            //Adding a sample value to "B3" cell
            worksheet.Cells["B3"].PutValue(50);

            //Adding a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);

            //Accessing the instance of the newly added chart
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
            //Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3"
            chart.NSeries.Add("A1:B3", true);
            //Converting chart to image.
            chart.ToImage(MyDir + "Chart to PNG Image.Png", System.Drawing.Imaging.ImageFormat.Png);
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            //ExStart:1
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            //Instantiating a Workbook object
            Workbook workbook = new Workbook();

            //Adding a new worksheet to the Excel object
            int sheetIndex = workbook.Worksheets.Add();

            //Obtaining the reference of the newly added worksheet by
            //passing its sheet index
            Worksheet worksheet = workbook.Worksheets[sheetIndex];

            //Adding a sample value to "A1" cell
            worksheet.Cells["A1"].PutValue(50);
            //Adding a sample value to "A2" cell
            worksheet.Cells["A2"].PutValue(100);
            //Adding a sample value to "A3" cell
            worksheet.Cells["A3"].PutValue(150);
            //Adding a sample value to "B1" cell
            worksheet.Cells["B1"].PutValue(4);
            //Adding a sample value to "B2" cell
            worksheet.Cells["B2"].PutValue(20);
            //Adding a sample value to "B3" cell
            worksheet.Cells["B3"].PutValue(50);

            //Adding a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);

            //Accessing the instance of the newly added chart
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];

            //Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3"
            chart.NSeries.Add("A1:B3", true);

            //Converting chart to image.
            chart.ToImage(dataDir + "Chart.emf", System.Drawing.Imaging.ImageFormat.Emf);

            // Display result, so that user knows the processing has finished.
            System.Console.WriteLine("Image generated successfully.");
            //ExEnd:1
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Open the existing excel file which contains the pie chart.
            Workbook workbook = new Workbook(dataDir + "PieChart.xlsx");

            // Get the designer chart (first chart) in the first worksheet of the workbook.
            Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0];

            // Convert the chart to an image file.
            chart.ToImage(dataDir + "PieChart.out.emf", System.Drawing.Imaging.ImageFormat.Emf);
            // ExEnd:1
        }
Beispiel #7
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");

            //Create a new workbook.
            //Open the existing excel file which contains the pie chart.
            Workbook workbook = new Workbook(dataDir + "PieChart.xls");

            //Get the designer chart (first chart) in the first worksheet.
            //of the workbook.
            Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0];

            //Convert the chart to an image file.
            chart.ToImage(dataDir + "PieChart.emf", System.Drawing.Imaging.ImageFormat.Emf);
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            string FilePath = @"..\..\..\Sample Files\";
            string FileName = FilePath + "Chart to Image with Image Options.tiff";

            //Instantiating a Workbook object
            Workbook workbook = new Workbook();
            //Adding a new worksheet to the Excel object
            int sheetIndex = workbook.Worksheets.Add();
            //Obtaining the reference of the newly added worksheet by
            //passing its sheet index
            Worksheet worksheet = workbook.Worksheets[sheetIndex];

            //Adding a sample value to "A1" cell
            worksheet.Cells["A1"].PutValue(50);
            //Adding a sample value to "A2" cell
            worksheet.Cells["A2"].PutValue(100);
            //Adding a sample value to "A3" cell
            worksheet.Cells["A3"].PutValue(150);
            //Adding a sample value to "B1" cell
            worksheet.Cells["B1"].PutValue(4);
            //Adding a sample value to "B2" cell
            worksheet.Cells["B2"].PutValue(20);
            //Adding a sample value to "B3" cell
            worksheet.Cells["B3"].PutValue(50);

            //Adding a chart to the worksheet
            int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5);

            //Accessing the instance of the newly added chart
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
            //Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3"
            chart.NSeries.Add("A1:B3", true);

            ImageOrPrintOptions options = new ImageOrPrintOptions();

            options.HorizontalResolution = 300;
            options.VerticalResolution   = 300;
            options.TiffCompression      = TiffCompression.CompressionLZW;
            options.IsCellAutoFit        = false;
            options.ImageFormat          = System.Drawing.Imaging.ImageFormat.Tiff;
            options.OnePagePerSheet      = true;
            //Converting chart to image.
            chart.ToImage(FileName, options);
        }
Beispiel #9
0
        public static void Main(string[] args)
        {
            //ExStart:1
            // The path to the documents directory.
            string dataDir = Aspose.Cells.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);


            //Create a new workbook.
            //Open the existing excel file which contains the column chart.
            Workbook workbook = new Workbook(dataDir + "ColumnChart.xlsx");

            //Get the designer chart (first chart) in the first worksheet.
            //of the workbook.
            Aspose.Cells.Charts.Chart chart = workbook.Worksheets[0].Charts[0];

            //Convert the chart to an image file.
            chart.ToImage(dataDir + "ColumnChart.out.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            //ExEnd:1
        }
Beispiel #10
0
        public static void Run()
        {
            //Source directory
            string sourceDir = RunExamples.Get_SourceDirectory();

            //Output directory
            string outputDir = RunExamples.Get_OutputDirectory();

            // Open the existing excel file which contains the column chart.
            Workbook workbook = new Workbook(sourceDir + "sampleConvertingColumnChartToImage.xlsx");

            Worksheet ws = workbook.Worksheets[0];

            // Get the designer chart (first chart) in the first worksheet of the workbook.
            Aspose.Cells.Charts.Chart chart = ws.Charts[0];

            // Convert the chart to an image file.
            chart.ToImage(outputDir + "outputConvertingColumnChartToImage.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);

            Console.WriteLine("ConvertingColumnChartToImage executed successfully.");
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            // Create workbook object from source file
            Workbook workbook = new Workbook(dataDir + "SampleChartBook.xlsx");

            // Access first worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // Access first chart inside the worksheet
            Aspose.Cells.Charts.Chart chart = worksheet.Charts[0];

            // Set image or print options
            Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions();
            opts.SaveFormat = SaveFormat.SVG;

            // Save the chart to svg format
            chart.ToImage(dataDir + "Image_out.svg", opts);
            // ExEnd:1
        }
Beispiel #12
0
        public static void ToImage(asp.Charts.Chart chart, string imagePath, System.Drawing.Imaging.ImageFormat imageFormat)
        {
            LicenseHelper.ModifyInMemory.EnsureActivateMemoryPatching();

            chart.ToImage(imagePath, imageFormat);
        }