Documents for Excel, .NET Edition Documentation
Manage File Operations / Export to a PDF File / Export Charts
In This Topic
    Export Charts
    In This Topic

    In GcExcel, you can export charts to PDF documents. This helps in the easy generation of PDF reports from spreadsheets, like finance, sales, marketing, health care etc. Following chart types can be exported to PDF documents:

    Using Code

    Refer to the following example code to export charts in Excel files to PDF document.

    C#
    Copy Code
     // Initialize workbook
     Workbook workbook = new Workbook();
     // Fetch default worksheet 
     IWorksheet worksheet = workbook.Worksheets[0];
    
     IShape shape = worksheet.Shapes.AddChart(ChartType.ColumnStacked, 50, 120, 350, 250);
     worksheet.Range["A1:D6"].Value = new object[,]
     {
    {null, "S1", "S2", "S3"},
    {"Item1", 10, 25, 25},
    {"Item2", -51, -36, 27},
    {"Item3", 52, -85, -30},
    {"Item4", 22, 65, 65},
    {"Item5", 23, 69, 69}
     };
     shape.Chart.SeriesCollection.Add(worksheet.Range["A1:D6"], RowCol.Columns, true, true);
    
     // Saving workbook to pdf
     workbook.Save(@"ExportChartsToPDF.pdf", SaveFileFormat.Pdf);

    Limitations

    The following are the limitations for exporting charts to PDF documents:

    1. The following chart types are not supported: 3D, Pie of Pie, Bar of Pie, Combo chart with Pie or Doughnut or Radar, Map, Treemap, Sunburst, Histogram, Box & Whisker, Waterfall and Funnel.
    2. The chart layout, major unit and min or max value of the chart axis may not be exactly same as Excel after exporting to PDF document.
    3. The following chart features are not supported:
      • Line marker and round corners
      • Chart elements: Stock's upBar, Error bars, Trendline, data table and label callout
      • Fill settings: Gradient, Picture or Texture and Pattern