• Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
Class XlsIORenderer - ASP.NETCore-EJ2 API Reference | Syncfusion

    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
    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
    TypeNameDescription
    Syncfusion.XlsIO.IChartchart

    The chart which is to be converted to image.

    System.IO.StreamoutputStream

    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
    TypeNameDescription
    Syncfusion.XlsIO.IRangerange

    The range which is to be converted to image.

    Syncfusion.XlsIO.ExportImageOptionsimageOptions

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

    System.IO.StreamoutputStream

    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
    TypeNameDescription
    Syncfusion.XlsIO.IRangerange

    The range which is to be converted to image.

    System.IO.StreamoutputStream

    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
    TypeNameDescription
    Syncfusion.XlsIO.IWorksheetworksheet

    Worksheet from which image will be created.

    System.Int32firstRow

    First row index. One-based.

    System.Int32firstColumn

    First column index. One-based.

    System.Int32lastRow

    Last row index. One-based.

    System.Int32lastColumn

    Last column index. One-based.

    Syncfusion.XlsIO.ExportImageOptionsimageOptions

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

    System.IO.StreamoutputStream

    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
    TypeNameDescription
    Syncfusion.XlsIO.IWorksheetworksheet

    Worksheet from which image will be created.

    System.Int32firstRow

    First row index. One-based.

    System.Int32firstColumn

    First column index. One-based.

    System.Int32lastRow

    Last row index. One-based.

    System.Int32lastColum
    System.IO.StreamoutputStream

    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
    TypeNameDescription
    Syncfusion.XlsIO.IChartchart
    Returns
    TypeDescription
    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
    TypeNameDescription
    Syncfusion.XlsIO.IChartchart
    XlsIORendererSettingsconverterSettings
    Returns
    TypeDescription
    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
    TypeNameDescription
    Syncfusion.XlsIO.IWorkbookworkbook
    Returns
    TypeDescription
    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
    TypeNameDescription
    Syncfusion.XlsIO.IWorkbookworkbook
    XlsIORendererSettingsconverterSettings
    Returns
    TypeDescription
    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
    TypeNameDescription
    Syncfusion.XlsIO.IWorksheetworksheet
    Returns
    TypeDescription
    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
    TypeNameDescription
    Syncfusion.XlsIO.IWorksheetworksheet
    XlsIORendererSettingsconverterSettings
    Returns
    TypeDescription
    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
    TypeNameDescription
    System.IO.Streamstream
    Returns
    TypeDescription
    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
    TypeNameDescription
    System.IO.Streamstream
    XlsIORendererSettingsconverterSettings
    Returns
    TypeDescription
    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();

    ConvertToPDF(String)

    Converts the fileName from path to PDF document.

    Declaration
    public PdfDocument ConvertToPDF(string fileName)
    Parameters
    TypeNameDescription
    System.StringfileName
    Returns
    TypeDescription
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the file by fileName to PDF.

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

    ConvertToPDF(String, XlsIORendererSettings)

    Converts the fileName from path to PDF document with the specified renderer settings.

    Declaration
    public PdfDocument ConvertToPDF(string fileName, XlsIORendererSettings converterSettings)
    Parameters
    TypeNameDescription
    System.StringfileName
    XlsIORendererSettingsconverterSettings
    Returns
    TypeDescription
    Syncfusion.Pdf.PdfDocument

    Returns the PDFDocument Object

    Examples

    The following code snippet illustrates how to convert the file from fileName to PDF with the specified renderer settings.

    //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("Template.xlsx", settings);
    
    //Saving the PDF as stream
    FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create, FileAccess.ReadWrite);
    document.Save(pdfStream);
    
    pdfStream.Dispose();
    document.Close();

    Implements

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