Sparkline.ToImage

ToImage(ImageOrPrintOptions)

Converts a sparkline to an image.

public Bitmap ToImage(ImageOrPrintOptions options)
ParameterTypeDescription
optionsImageOrPrintOptionsThe image options

Return Value

Returns a Bitmap object.

See Also


ToImage(string, ImageOrPrintOptions)

Converts a sparkline to an image.

public void ToImage(string fileName, ImageOrPrintOptions options)
ParameterTypeDescription
fileNameStringThe image file name.
optionsImageOrPrintOptionsThe image options

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Charts;
using Aspose.Cells.Rendering;

namespace AsposeCellsExamples
{
    public class SparklineMethodToImageWithStringImageOrPrintOptionsDemo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            sheet.Cells["A1"].PutValue(5);
            sheet.Cells["B1"].PutValue(2);
            sheet.Cells["C1"].PutValue(1);
            sheet.Cells["D1"].PutValue(3);

            CellArea ca = new CellArea
            {
                StartColumn = 4,
                EndColumn = 4,
                StartRow = 0,
                EndRow = 0
            };

            int idx = sheet.SparklineGroups.Add(SparklineType.Line, sheet.Name + "!A1:D1", false, ca);
            SparklineGroup group = sheet.SparklineGroups[idx];
            Sparkline line = group.Sparklines[0];

            ImageOrPrintOptions options = new ImageOrPrintOptions
            {
                ImageType = Aspose.Cells.Drawing.ImageType.Png,
                HorizontalResolution = 300,
                VerticalResolution = 300
            };
            
            line.ToImage("sparkline_output.png", options);
        }
    }
}

See Also


ToImage(Stream, ImageOrPrintOptions)

Converts a sparkline to an image.

public void ToImage(Stream stream, ImageOrPrintOptions options)
ParameterTypeDescription
streamStreamThe image stream.
optionsImageOrPrintOptionsThe image options.

See Also