ASP.NET Core - EJ2

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class XlsIORenderer

    Show / Hide Table of Contents

    Class XlsIORenderer

    Inheritance
    System.Object
    XlsIORenderer
    Implements
    Syncfusion.XlsIO.IXlsIORenderer
    Namespace: Syncfusion.XlsIORenderer
    Assembly: Syncfusion.XlsIORenderer.Portable.dll
    Syntax
    public class XlsIORenderer : Object, IXlsIORenderer

    Constructors

    XlsIORenderer()

    Default constructor for XlsIO Renderer class.

    Declaration
    public XlsIORenderer()

    Properties

    ChartRenderingOptions

    Gets or sets the Chart to Image options.

    Declaration
    public ExportImageOptions ChartRenderingOptions { get; }
    Property Value
    Type Description
    Syncfusion.XlsIO.ExportImageOptions

    Methods

    ConvertToImage(IChart, Stream)

    Converts the specified chart into image with the image settings given.

    Declaration
    public void ConvertToImage(IChart chart, Stream outputStream)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IChart chart

    The chart which is to be converted to image.

    System.IO.Stream outputStream

    Stream to hold the converted image data.

    Remarks

    This method is supported in NetStandard supported platforms only.

    Examples
    using (ExcelEngine excelEngine = new ExcelEngine())
    {
    	IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
        IWorkbook workbook = application.Workbooks.Open(excelStream);
        IWorksheet sheet = workbook.Worksheets[0];
        IChart chart = sheet.Charts[0];
    
    	//Initialize XlsIORenderer
        XlsIORenderer renderer = new XlsIORenderer();
        renderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;
    
    	//Converts the chart to image
    	Stream image = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
        renderer.ConvertToImage(chart, image);
    }

    ConvertToImage(IRange, ExportImageOptions, Stream)

    Converts the specified range into image with the image settings given.

    Declaration
    public void ConvertToImage(IRange range, ExportImageOptions imageOptions, Stream outputStream)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IRange range

    The range which is to be converted to image.

    Syncfusion.XlsIO.ExportImageOptions imageOptions

    object that defines Image quality and image format to be used for conversion.

    System.IO.Stream outputStream

    Stream to hold the converted image data.

    Remarks

    Subscript/Superscript,Shrink to fit,Shapes (except TextBox shape and Image) and Complex conditional formatting features are not supported in Worksheet to image conversion. Gradient fill is partially supported

    Examples
    using (ExcelEngine excelEngine = new ExcelEngine())
    {
    	IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
        IWorkbook workbook = application.Workbooks.Open(excelStream);
        IWorksheet sheet = workbook.Worksheets[0];
    
    	//Initialize XlsIORenderer
        XlsIORenderer renderer = new XlsIORenderer();
    
    	Stream image = new FileStream("Sample.png", FileMode.Create, FileAccess.ReadWrite);
    
    	//Converts the Range used in worksheet to image
        ExportImageOptions imageOptions = new ExportImageOptions();
        imageOptions.ImageFormat = ExportImageFormat.Jpeg;
        renderer.ConvertToImage(sheet.UsedRange, imageOptions, image);
    }

    ConvertToImage(IRange, Stream)

    Converts the specified range into image with default image settings.

    Declaration
    public void ConvertToImage(IRange range, Stream outputStream)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IRange range

    The range which is to be converted to image.

    System.IO.Stream outputStream

    Stream to hold the converted image data.

    Remarks

    Subscript/Superscript,Shrink to fit,Shapes (except TextBox shape and Image) and Complex conditional formatting features are not supported in Worksheet to image conversion. Gradient fill is partially supported

    Examples
    using (ExcelEngine excelEngine = new ExcelEngine())
    {
    	IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
        IWorkbook workbook = application.Workbooks.Open(excelStream);
        IWorksheet sheet = workbook.Worksheets[0];
    
    	//Initialize XlsIORenderer
        XlsIORenderer renderer = new XlsIORenderer();
    
    	Stream image = new FileStream("Sample.png", FileMode.Create, FileAccess.ReadWrite);
    
    	//Converts the Range used in worksheet to image
        renderer.ConvertToImage(sheet.UsedRange, image);
    }

    ConvertToImage(IWorksheet, Int32, Int32, Int32, Int32, ExportImageOptions, Stream)

    Converts the specified range into image with the image options given. Default image format is PNG.

    Declaration
    public void ConvertToImage(IWorksheet worksheet, int firstRow, int firstColumn, int lastRow, int lastColumn, ExportImageOptions imageOptions, Stream outputStream)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IWorksheet worksheet

    Worksheet from which image will be created.

    System.Int32 firstRow

    First row index. One-based.

    System.Int32 firstColumn

    First column index. One-based.

    System.Int32 lastRow

    Last row index. One-based.

    System.Int32 lastColumn

    Last column index. One-based.

    Syncfusion.XlsIO.ExportImageOptions imageOptions

    object that defines Image quality and image format to be used for conversion.

    System.IO.Stream outputStream

    Stream to hold the converted image data.

    Remarks

    Subscript/Superscript,Shrink to fit,Shapes (except TextBox shape and Image), Complex conditional formatting features are not supported in Worksheet to image conversion. Gradient fill is partially supported

    Examples
    using (ExcelEngine excelEngine = new ExcelEngine())
    {
    	IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
        IWorkbook workbook = application.Workbooks.Open(excelStream);
        IWorksheet sheet = workbook.Worksheets[0];
    
    	//Initialize XlsIORenderer
        XlsIORenderer renderer = new XlsIORenderer();
    
    	Stream image = new FileStream("Sample.png", FileMode.Create, FileAccess.ReadWrite);
    
    	//Converts the Range(R1C1 to R10C20) in worksheet to image
        ExportImageOptions imageOptions = new ExportImageOptions();
        imageOptions.ImageFormat = ExportImageFormat.Jpeg;
        renderer.ConvertToImage(sheet, 1, 1, 10, 20, imageOptions, image);
    }

    ConvertToImage(IWorksheet, Int32, Int32, Int32, Int32, Stream)

    Converts the specified range into image. Default image format is PNG.

    Declaration
    public void ConvertToImage(IWorksheet worksheet, int firstRow, int firstColumn, int lastRow, int lastColum, Stream outputStream)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IWorksheet worksheet

    Worksheet from which image will be created.

    System.Int32 firstRow

    First row index. One-based.

    System.Int32 firstColumn

    First column index. One-based.

    System.Int32 lastRow

    Last row index. One-based.

    System.Int32 lastColum
    System.IO.Stream outputStream

    Stream to hold the converted image data.

    Remarks

    Subscript/Superscript,Shrink to fit,Shapes (except TextBox shape and Image) and Complex conditional formatting features are not supported in Worksheet to image conversion. Gradient fill is partially supported

    Examples
    using (ExcelEngine excelEngine = new ExcelEngine())
    {
    	IApplication application = excelEngine.Excel;
        application.DefaultVersion = ExcelVersion.Excel2013;
        FileStream excelStream = new FileStream("Sample.xlsx", FileMode.Open, FileAccess.Read);
        IWorkbook workbook = application.Workbooks.Open(excelStream);
        IWorksheet sheet = workbook.Worksheets[0];
    
    	//Initialize XlsIORenderer
        XlsIORenderer renderer = new XlsIORenderer();
    
    	Stream image = new FileStream("Sample.png", FileMode.Create, FileAccess.ReadWrite);
    
    	//Converts the Range(R1C1 to R10C20) in worksheet to image
        renderer.ConvertToImage(sheet, 1, 1, 10, 20, image);
    }

    ConvertToPDF(IChart)

    Converts the chart to PDF document.

    Declaration
    public PdfDocument ConvertToPDF(IChart chart)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IChart chart
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the chart to PDF.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    
    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(excelStream);
    IWorksheet worksheet = workbook.Worksheets[0];
    IChart chart = worksheet.Charts[0];
    
    //Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Set image options to be used on chart to image conversion
    renderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;
    
    //Convert the chart into PDF.
    PdfDocument document = renderer.ConvertToPDF(chart);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();
    workbook.Close();
    excelEngine.Dispose();

    ConvertToPDF(IChart, XlsIORendererSettings)

    Converts the chart to PDF document with the specified renderer settings.

    Declaration
    public PdfDocument ConvertToPDF(IChart chart, XlsIORendererSettings converterSettings)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IChart chart
    XlsIORendererSettings converterSettings
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the chart to PDF with the specified renderer settings.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    
    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(excelStream);
    IWorksheet worksheet = workbook.Worksheets[0];
    IChart chart = worksheet.Charts[0];
    
    //Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Creates an instance of XlsIORenderer settings.
    XlsIORendererSettings settings = new XlsIORendererSettings();
    
    //Set image options to be used on chart to image conversion
    renderer.ChartRenderingOptions.ImageFormat = ExportImageFormat.Png;
    
    //Set layout for the output Pdf page.
    settings.LayoutOptions = LayoutOptions.NoScaling;
    
    //Convert the chart into PDF.
    PdfDocument document = renderer.ConvertToPDF(chart, settings);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();
    workbook.Close();
    excelEngine.Dispose();

    ConvertToPDF(IWorkbook)

    Converts the workbook to PDF document.

    Declaration
    public PdfDocument ConvertToPDF(IWorkbook workbook)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IWorkbook workbook
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the workbook to PDF.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    
    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(excelStream);
    
    // Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Convert the workbook into PDF.
    PdfDocument document = renderer.ConvertToPDF(workbook);
    
    //Saving the PDF as stream
    FileStream stream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();
    workbook.Close();
    excelEngine.Dispose();

    ConvertToPDF(IWorkbook, XlsIORendererSettings)

    Converts the workbook to PDF document with the specified renderer settings.

    Declaration
    public PdfDocument ConvertToPDF(IWorkbook workbook, XlsIORendererSettings converterSettings)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IWorkbook workbook
    XlsIORendererSettings converterSettings
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the workbook to PDF with the specified renderer settings.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    
    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(excelStream);
    
    // Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Creates an instance of XlsIORenderer settings.
    XlsIORendererSettings settings = new XlsIORendererSettings();
    
    //Set layout for the output Pdf page.
    settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
    
    //Convert the workbook into PDF.
    PdfDocument document = renderer.ConvertToPDF(workbook, settings);
    
    //Saving the PDF as stream
    FileStream stream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();
    workbook.Close();
    excelEngine.Dispose();

    ConvertToPDF(IWorksheet)

    Converts the worksheet to PDF document.

    Declaration
    public PdfDocument ConvertToPDF(IWorksheet worksheet)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IWorksheet worksheet
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the worksheet to PDF.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    
    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(excelStream);
    IWorksheet worksheet = workbook.Worksheets[0];
    
    //Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Convert the worksheet into PDF.
    PdfDocument document = renderer.ConvertToPDF(worksheet);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();
    workbook.Close();
    excelEngine.Dispose();

    ConvertToPDF(IWorksheet, XlsIORendererSettings)

    Converts the worksheet to PDF document with the specified renderer settings.

    Declaration
    public PdfDocument ConvertToPDF(IWorksheet worksheet, XlsIORendererSettings converterSettings)
    Parameters
    Type Name Description
    Syncfusion.XlsIO.IWorksheet worksheet
    XlsIORendererSettings converterSettings
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the worksheet to PDF with the specified renderer settings.

    ExcelEngine excelEngine = new ExcelEngine();
    IApplication application = excelEngine.Excel;
    
    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    IWorkbook workbook = application.Workbooks.Open(excelStream);
    IWorksheet worksheet = workbook.Worksheets[0];
    
    //Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Creates an instance of XlsIORenderer settings.
    XlsIORendererSettings settings = new XlsIORendererSettings();
    
    //Set layout for the output Pdf page.
    settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
    
    //Convert the worksheet into PDF.
    PdfDocument document = renderer.ConvertToPDF(worksheet, settings);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();
    workbook.Close();
    excelEngine.Dispose();

    ConvertToPDF(Stream)

    Converts the Excel stream to PDF document.

    Declaration
    public PdfDocument ConvertToPDF(Stream stream)
    Parameters
    Type Name Description
    System.IO.Stream stream
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the workbook to PDF.

    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    
    // Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Convert the workbook into PDF.
    PdfDocument document = renderer.ConvertToPDF(excelStream);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();

    ConvertToPDF(Stream, XlsIORendererSettings)

    Converts the Excel stream to PDF document with the specified renderer settings.

    Declaration
    public PdfDocument ConvertToPDF(Stream stream, XlsIORendererSettings converterSettings)
    Parameters
    Type Name Description
    System.IO.Stream stream
    XlsIORendererSettings converterSettings
    Returns
    Type Description
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the workbook to PDF with the specified renderer settings.

    //Open the file as Stream
    FileStream excelStream = new FileStream("Template.xlsx", FileMode.Open, FileAccess.Read);
    
    //Creates an instance of XlsIORenderer for Excel to PDF conversion
    XlsIORenderer renderer = new XlsIORenderer();
    
    //Creates an instance of XlsIORenderer settings.
    XlsIORendererSettings settings = new XlsIORendererSettings();
    
    //Set layout for the output Pdf page.
    settings.LayoutOptions = LayoutOptions.FitAllColumnsOnOnePage;
    
    //Convert the Excel stream into PDF.
    PdfDocument document = renderer.ConvertToPDF(excelStream, settings);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    excelStream.Dispose();
    document.Close();
    renderer.Dispose();

    Implements

    Syncfusion.XlsIO.IXlsIORenderer
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved