asposecells.api

Encapsulates the object that represents a single Excel chart.

Example:

workbook = Workbook()
sheet = workbook.getWorksheets().get(0)
cells = sheet.getCells()
cells.get(0, 1).putValue("Income")
cells.get(1, 0).putValue("Company A")
cells.get(2, 0).putValue("Company B")
cells.get(3, 0).putValue("Company C")
cells.get(1, 1).putValue(10000)
cells.get(2, 1).putValue(20000)
cells.get(3, 1).putValue(30000)
chartIndex = sheet.getCharts().add(ChartType.COLUMN, 9, 9, 21, 15)
chart = sheet.getCharts().get(chartIndex)
chart.getNSeries().add("B2:B4", True)
chart.getNSeries().setCategoryData("A2:A4")
aSeries = chart.getNSeries().get(0)
aSeries.setName("=B1")
chart.setShowLegend(True)
chart.getTitle().setText("Income Analysis")

Property Getters/Setters Summary
methodgetActualChartSize()
Gets actual size of chart in unit of pixels.
methodgetAutoScaling()
method
           True if Microsoft Excel scales a 3-D chart so that it's closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.
methodgetBackWall()
Returns a Walls object that represents the back wall of a 3-D chart.
methodgetCategoryAxis()
Gets the chart's X axis.
methodgetChartArea()
Gets the chart area in the worksheet.
methodgetChartDataTable()
Represents the chart data table.
methodgetChartObject()
Represents the chartShape;
methodgetChartShape()
Represents the chartShape;
methodgetDepthPercent()
method
           Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
methodgetDisplayNaAsBlank()
method
           Indicates whether displaying #N/A as blank value.
methodgetElevation()
method
           Represents the elevation of the 3-D chart view, in degrees.
methodgetFilteredNSeries()
Gets a SeriesCollection collection representing the data series that are filtered in the chart.
methodgetFirstSliceAngle()
method
           Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.
methodgetFloor()
Returns a Floor object that represents the walls of a 3-D chart.
methodgetGapDepth()
method
           Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.
methodgetGapWidth()
method
           Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.
methodgetHeightPercent()
method
           Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
methodgetHidePivotFieldButtons()
method
           Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.
methodgetIs3D()
Indicates whether the chart is a 3d chart.
methodisRectangularCornered()
method
           Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
methodgetLegend()
Gets the chart legend.
methodgetLine()
Gets the line.
methodgetName()
method
setName(value)
           Gets and sets the name of the chart.
methodgetNSeries()
Gets a SeriesCollection collection representing the data series in the chart.
methodgetPageSetup()
Represents the page setup description in this chart.
methodgetPerspective()
method
           Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.
methodgetPivotOptions()
Specifies the pivot controls that appear on the chart
methodgetPivotSource()
method
           The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart.
methodgetPlacement()
method
           Represents the way the chart is attached to the cells below it. The value of the property is PlacementType integer constant.
methodgetPlotArea()
Gets the chart's plot area which includes axis tick labels.
methodgetPlotBy()
Gets and sets whether plot by row or column. The value of the property is PlotDataByType integer constant.
methodgetPlotEmptyCellsType()
method
           Gets and sets how to plot the empty cells. The value of the property is PlotEmptyCellsType integer constant.
methodgetPlotVisibleCells()
method
           Indicates whether only plot visible cells.
methodgetPlotVisibleCellsOnly()
method
           Indicates whether plot visible cells only.
methodgetPrintSize()
method
           Gets and sets the printed chart size. The value of the property is PrintSizeType integer constant.
methodgetRightAngleAxes()
method
           True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts).
methodgetRotationAngle()
method
           Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees).
methodgetSecondCategoryAxis()
Gets the chart's second X axis.
methodgetSecondValueAxis()
Gets the chart's second Y axis.
methodgetSeriesAxis()
Gets the chart's series axis.
methodgetShapes()
Returns all drawing shapes in this chart.
methodgetShowDataTable()
method
           Gets or sets a value indicating whether the chart displays a data table.
methodgetShowLegend()
method
           Gets or sets a value indicating whether the chart legend will be displayed. Default is true.
methodgetSideWall()
Returns a Walls object that represents the side wall of a 3-D chart.
methodgetSizeWithWindow()
method
           True if Microsoft Excel resizes the chart to match the size of the chart sheet window.
methodgetStyle()
method
setStyle(value)
           Gets and sets the builtin style.
methodgetSubTitle()
Gets the chart's sub-title. Only for ODS format file.
methodgetTitle()
Gets the chart's title.
methodgetType()
method
setType(value)
           Gets or sets a chart's type. The value of the property is ChartType integer constant.
methodgetValueAxis()
Gets the chart's Y axis.
methodgetWalls()
Returns a Walls object that represents the walls of a 3-D chart.
methodgetWallsAndGridlines2D()
method
           True if gridlines are drawn two-dimensionally on a 3-D chart.
methodgetWorksheet()
Gets the worksheet which contains this chart.
 
Method Summary
methodcalculate()
Calculates the custom position of plot area, axes if the position of them are auto assigned.
methodcalculate(calculateOptions)
Calculates the custom position of plot area, axes if the position of them are auto assigned, with Chart Calculate Options.
methodchangeTemplate(data)
Change chart type with preset template.
methodgetActualSize()
Gets actual size of chart in unit of pixels.
methodgetChartDataRange()
Gets the data source range of the chart.
methodhasAxis(aixsType, isPrimary)
Returns which axes exist on the chart.
methodisCellReferedByChart(sheetIndex, rowIndex, columnIndex)
Returns whether the cell refered by the chart.
methodisChartDataChanged()
Detects if a chart's data source has changed.
methodisReferedByChart(rowIndex, columnIndex)
Returns whether the cell refered by the chart.
methodmove(upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn)
Moves the chart to a specified location.
methodrefreshPivotData()
Refreshes chart's data from pivot table.
methodsetChartDataRange(area, isVertical)
Specifies data range for a chart.
methodswitchRowColumn()
Switches row/column.
methodtoImage(imageFile)
Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
methodtoImage(imageFile, imageFormat)
Creates the chart image and saves it to a file in the specified format.
methodtoImage(imageFile, options)
Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.
methodtoImage(imageFile, imageType)
Creates the chart image and saves it to a file in the specified image type.
methodtoImage(imageFile, jpegQuality)
Creates the chart image and saves it to a file in the Jpeg format.
methodtoImageBytes(options)
Creates the chart image and saves it to a byte array in the specified format.
methodtoPdf(fileName)
Saves the chart to a pdf file.
methodtoPdf(fileName, desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType)
Saves the chart to a pdf file.
methodtoPdfBytes()
Creates the chart pdf and saves it to a byte array.
methodtoPdfBytes(desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType)
Creates the chart pdf and saves it to a byte array.
 

    • Property Getters/Setters Detail

      • getStyle/setStyle : int 

        int getStyle() / setStyle(value)
        
        Gets and sets the builtin style. It should be between 1 and 48. Return -1 if it's not be set.
      • getHidePivotFieldButtons/setHidePivotFieldButtons : boolean 

        boolean getHidePivotFieldButtons() / setHidePivotFieldButtons(value)
        
        Indicates whether hide the pivot chart field buttons only when the chart is PivotChart.
      • getPivotSource/setPivotSource : String 

        String getPivotSource() / setPivotSource(value)
        
        The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart. If the pivot table "PivotTable1" in the Worksheet "Sheet1" in the file "Book1.xls". The pivotSource could be "[Book1.xls]Sheet1!PivotTable1" if the chart and the PivotTable is not in the same workbook. If you set this property ,the previous data source setting will be lost.
      • getPlotBy : int 

        int getPlotBy()
        
        Gets and sets whether plot by row or column. The value of the property is PlotDataByType integer constant.
      • getPlotEmptyCellsType/setPlotEmptyCellsType : int 

        int getPlotEmptyCellsType() / setPlotEmptyCellsType(value)
        
        Gets and sets how to plot the empty cells. The value of the property is PlotEmptyCellsType integer constant.
      • getPlotVisibleCells/setPlotVisibleCells : boolean 

        boolean getPlotVisibleCells() / setPlotVisibleCells(value)
        
        Indicates whether only plot visible cells. NOTE: This member is now obsolete. Instead, please use PlotVisibleCellsOnly property. This method will be removed 12 months later since December 2022. Aspose apologizes for any inconvenience you may have experienced.
      • getPlotVisibleCellsOnly/setPlotVisibleCellsOnly : boolean 

        boolean getPlotVisibleCellsOnly() / setPlotVisibleCellsOnly(value)
        
        Indicates whether plot visible cells only.
      • getDisplayNaAsBlank/setDisplayNaAsBlank : boolean 

        boolean getDisplayNaAsBlank() / setDisplayNaAsBlank(value)
        
        Indicates whether displaying #N/A as blank value.
      • getName/setName : String 

        String getName() / setName(value)
        
        Gets and sets the name of the chart.
      • getSizeWithWindow/setSizeWithWindow : boolean 

        boolean getSizeWithWindow() / setSizeWithWindow(value)
        
        True if Microsoft Excel resizes the chart to match the size of the chart sheet window.
      • getWorksheet : Worksheet 

        Worksheet getWorksheet()
        
        Gets the worksheet which contains this chart.
      • getPrintSize/setPrintSize : int 

        int getPrintSize() / setPrintSize(value)
        
        Gets and sets the printed chart size. The value of the property is PrintSizeType integer constant.
      • getType/setType : int 

        int getType() / setType(value)
        
        Gets or sets a chart's type. The value of the property is ChartType integer constant.
      • getTitle : Title 

        Title getTitle()
        
        Gets the chart's title.
      • getSubTitle : Title 

        Title getSubTitle()
        
        Gets the chart's sub-title. Only for ODS format file.
      • getPlotArea : PlotArea 

        PlotArea getPlotArea()
        
        Gets the chart's plot area which includes axis tick labels.
      • getChartArea : ChartArea 

        ChartArea getChartArea()
        
        Gets the chart area in the worksheet.
      • getCategoryAxis : Axis 

        Axis getCategoryAxis()
        
        Gets the chart's X axis.
      • getValueAxis : Axis 

        Axis getValueAxis()
        
        Gets the chart's Y axis.
      • getSecondValueAxis : Axis 

        Axis getSecondValueAxis()
        
        Gets the chart's second Y axis.
      • getSecondCategoryAxis : Axis 

        Axis getSecondCategoryAxis()
        
        Gets the chart's second X axis.
      • getSeriesAxis : Axis 

        Axis getSeriesAxis()
        
        Gets the chart's series axis.
      • getLegend : Legend 

        Legend getLegend()
        
        Gets the chart legend.
      • getShowLegend/setShowLegend : boolean 

        boolean getShowLegend() / setShowLegend(value)
        
        Gets or sets a value indicating whether the chart legend will be displayed. Default is true.
      • isRectangularCornered/setRectangularCornered : boolean 

        boolean isRectangularCornered() / setRectangularCornered(value)
        
        Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true.
      • getShowDataTable/setShowDataTable : boolean 

        boolean getShowDataTable() / setShowDataTable(value)
        
        Gets or sets a value indicating whether the chart displays a data table.
      • getFirstSliceAngle/setFirstSliceAngle : int 

        int getFirstSliceAngle() / setFirstSliceAngle(value)
        
        Gets or sets the angle of the first pie-chart or doughnut-chart slice, in degrees (clockwise from vertical). Applies only to pie, 3-D pie, and doughnut charts, 0 to 360.
      • getGapWidth/setGapWidth : int 

        int getGapWidth() / setGapWidth(value)
        
        Returns or sets the space between bar or column clusters, as a percentage of the bar or column width. The value of this property must be between 0 and 500.
      • getGapDepth/setGapDepth : int 

        int getGapDepth() / setGapDepth(value)
        
        Gets or sets the distance between the data series in a 3-D chart, as a percentage of the marker width. The value of this property must be between 0 and 500.
      • getFloor : Floor 

        Floor getFloor()
        
        Returns a Floor object that represents the walls of a 3-D chart. This property doesn't apply to 3-D pie charts.
      • getWalls : Walls 

        Walls getWalls()
        
        Returns a Walls object that represents the walls of a 3-D chart. This property doesn't apply to 3-D pie charts.
      • getBackWall : Walls 

        Walls getBackWall()
        
        Returns a Walls object that represents the back wall of a 3-D chart.
      • getSideWall : Walls 

        Walls getSideWall()
        
        Returns a Walls object that represents the side wall of a 3-D chart.
      • getWallsAndGridlines2D/setWallsAndGridlines2D : boolean 

        boolean getWallsAndGridlines2D() / setWallsAndGridlines2D(value)
        
        True if gridlines are drawn two-dimensionally on a 3-D chart.
      • getRotationAngle/setRotationAngle : int 

        int getRotationAngle() / setRotationAngle(value)
        
        Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees). The value of this property must be from 0 to 360, except for 3-D bar charts, where the value must be from 0 to 44. The default value is 20. Applies only to 3-D charts.
      • getElevation/setElevation : int 

        int getElevation() / setElevation(value)
        
        Represents the elevation of the 3-D chart view, in degrees. The chart elevation is the height at which you view the chart, in degrees. The default is 15 for most chart types. The value of this property must be between -90 and 90, except for 3-D bar charts, where it must be between 0 and 44.
      • getRightAngleAxes/setRightAngleAxes : boolean 

        boolean getRightAngleAxes() / setRightAngleAxes(value)
        
        True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts). If this property is True, the Perspective property is ignored.
      • getAutoScaling/setAutoScaling : boolean 

        boolean getAutoScaling() / setAutoScaling(value)
        
        True if Microsoft Excel scales a 3-D chart so that it's closer in size to the equivalent 2-D chart. The RightAngleAxes property must be True.
      • getHeightPercent/setHeightPercent : int 

        int getHeightPercent() / setHeightPercent(value)
        
        Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent).
      • getPerspective/setPerspective : int 

        int getPerspective() / setPerspective(value)
        
        Returns or sets the perspective for the 3-D chart view. Must be between 0 and 100. This property is ignored if the RightAngleAxes property is True.
      • getIs3D : boolean 

        boolean getIs3D()
        
        Indicates whether the chart is a 3d chart.
      • getDepthPercent/setDepthPercent : int 

        int getDepthPercent() / setDepthPercent(value)
        
        Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent).
      • getActualChartSize : int[] 

        int[] getActualChartSize()
        
        Gets actual size of chart in unit of pixels. NOTE: This member is now obsolete. Instead, please use Chart.getActualSize() method. This property will be removed 12 months later since July 2022. Aspose apologizes for any inconvenience you may have experienced.
        Returns:
        Actual size in an array(width and height). [0] is width; [1] is height.
      • getPlacement/setPlacement : int 

        int getPlacement() / setPlacement(value)
        
        Represents the way the chart is attached to the cells below it. The value of the property is PlacementType integer constant.
      • getPageSetup : PageSetup 

        PageSetup getPageSetup()
        
        Represents the page setup description in this chart.
      • getChartShape : ChartShape 

        ChartShape getChartShape()
        
        Represents the chartShape; NOTE: This member is now obsolete. Instead, please use Aspose.Cells.Charts.Chart.ChartObject property. This property will be removed 12 months later since JANUARY 2012. Aspose apologizes for any inconvenience you may have experienced.
      • getLine : Line 

        Line getLine()
        
        Gets the line.
    • Method Detail

      • toImage

         toImage(imageFile)
        Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

        The format of the image is specified by using the extension of the file name. For example, if you specify "myfile.png", then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

        If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
        Parameters:
        imageFile: String - The image file name with full path.
      • toImage

         toImage(imageFile, imageFormat)
        Creates the chart image and saves it to a file in the specified format. NOTE: This member is now obsolete. Instead, please use Chart.ToImage(string, ImageType) method. This property will be removed 12 months later since July 2022. Aspose apologizes for any inconvenience you may have experienced.
        Parameters:
        imageFile: String - The image file name with full path.
        imageFormat: ImageFormat - The format in which to save the image.
      • toImage

         toImage(imageFile, imageType)
        Creates the chart image and saves it to a file in the specified image type.

        The type of the image is specified by using imageType. The following types are supported: ImageType.Bmp, ImageType.Gif, ImageType.Png, ImageType.Jpeg, ImageType.Tiff, ImageType.Emf.

        If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
        Parameters:
        imageFile: String - The image file name with full path.
        imageType: int - A ImageType value. The image type in which to save the image.
      • toImage

         toImage(imageFile, jpegQuality)
        Creates the chart image and saves it to a file in the Jpeg format. If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing.
        Parameters:
        imageFile: String - The image file name with full path.
        jpegQuality: long - Jpeg quality.
      • toPdf

         toPdf(fileName)
        Saves the chart to a pdf file.
        Parameters:
        fileName: String - the pdf file name with full path
      • toPdf

         toPdf(fileName, desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType)
        Saves the chart to a pdf file.
        Parameters:
        fileName: String - the pdf file name with full path
        desiredPageWidth: float - The desired page width in inches.
        desiredPageHeight: float - The desired page height in inches.
        hAlignmentType: int - A PageLayoutAlignmentType value. The chart horizontal alignment type in the output page.
        vAlignmentType: int - A PageLayoutAlignmentType value. The chart vertical alignment type in the output page.
      • toImage

         toImage(imageFile, options)
        Creates the chart image and saves it to a file. The extension of the file name determines the format of the image.

        The format of the image is specified by using the extension of the file name. For example, if you specify "myfile.png", then the image will be saved in the PNG format. The following file extensions are recognized: .bmp, .gif, .png, .jpg, .jpeg, .tiff, .tif, .emf.

        If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.
        Parameters:
        imageFile: String - The image file name with full path.
        options: ImageOrPrintOptions - Additional image creation options

        Example:

        options = ImageOrPrintOptions()
        options.setHorizontalResolution(300)
        options.setVerticalResolution(300)
        
        book = Workbook("Book2.xlsx")
        book.getWorksheets().get(3).getCharts().get(0).toImage("chart.png", options)
      • getActualSize

        int[] getActualSize()
        Gets actual size of chart in unit of pixels.
        Returns:
        Actual size in an array(width and height). [0] is width; [1] is height.
      • hasAxis

        boolean hasAxis(aixsType, isPrimary)
        Returns which axes exist on the chart. Normally, Pie, PieExploded, PiePie,PieBar, Pie3D, Pie3DExploded,Doughnut, DoughnutExploded is no axis.
        Parameters:
        aixsType - A AxisType value.
      • switchRowColumn

        boolean switchRowColumn()
        Switches row/column.
        Returns:
        False means switching row/column fails.
      • getChartDataRange

        String getChartDataRange()
        Gets the data source range of the chart. Only supports range.
        Returns:
        The data source.
      • setChartDataRange

         setChartDataRange(area, isVertical)
        Specifies data range for a chart.
        Parameters:
        area: String - Specifies values from which to plot the data series
        isVertical: boolean - Specifies whether to plot the series from a range of cell values by row or by column.
      • isReferedByChart

        boolean isReferedByChart(rowIndex, columnIndex)
        Returns whether the cell refered by the chart. NOTE: This method is now obsolete. Instead, please use IsCellReferedByChart(int,int,int) method. This method will be removed 12 months later since April 2023. Aspose apologizes for any inconvenience you may have experienced.
        Parameters:
        rowIndex: int - The row index
        columnIndex: int - The column index
        Returns:
      • isCellReferedByChart

        boolean isCellReferedByChart(sheetIndex, rowIndex, columnIndex)
        Returns whether the cell refered by the chart.
        Parameters:
        sheetIndex: int - The sheet Index.-1 means the worksheet which contains current chart.
        rowIndex: int - The row index
        columnIndex: int - The column index
        Returns:
      • isChartDataChanged

        boolean isChartDataChanged()
        Detects if a chart's data source has changed. The method detects the changes in the chart's data source before rendering the chart to image format. At first Chart.toImage call, the chart source data (e.g. XValuesParseData, ValuesParseData) will be recorded. Before calling the Chart.toImage method again, call IsChartDataChanged method to check if Chart needs re-rendering.
        Returns:
        Returns true if the chart has changed otherwise returns false
      • refreshPivotData

         refreshPivotData()
        Refreshes chart's data from pivot table. We will gather data from pivot data source to the pivot table report. This method is only used to gather all data to a pivot chart.
      • changeTemplate

         changeTemplate(data)
        Change chart type with preset template.
        Parameters:
        data: byte[] - The data of chart template file(.crtx).
      • move

         move(upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn)
        Moves the chart to a specified location.
        Parameters:
        upperLeftColumn: int - Upper left column index.
        upperLeftRow: int - Upper left row index.
        lowerRightColumn: int - Lower right column index
        lowerRightRow: int - Lower right row index
      • calculate

         calculate()
        Calculates the custom position of plot area, axes if the position of them are auto assigned.
      • calculate

         calculate(calculateOptions)
        Calculates the custom position of plot area, axes if the position of them are auto assigned, with Chart Calculate Options.
      • toImageBytes

         toImageBytes(options)
        Creates the chart image and saves it to a byte array in the specified format.

        The format of the image is specified by using options.ImageFormat. The following formats are supported: ImageFormat.Bmp, ImageFormat.Gif, ImageFormat.Png, ImageFormat.Jpeg, ImageFormat.Tiff, ImageFormat.Emf.

        If the width or height is zero or the chart is not supported according to Supported Charts List, this method will do nothing. Please refer to Supported Charts List for more details.
        Parameters:
        options: ImageOrPrintOptions - Addtional image creation options
        Returns:
        A byte array.

        Example:

        import jpype
        import asposecells
        jpype.startJVM()
        from asposecells.api import *
        
        wb = Workbook("Book2.xlsx")
        imgOptions = ImageOrPrintOptions()
        imgOptions.setHorizontalResolution(200)
        imgOptions.setVerticalResolution(300)
        imgOptions.setImageFormat(ImageFormat.getJpeg())
        chart = wb.getWorksheets().get("Chart").getCharts().get(0)
        with open("chart.jpeg", "wb") as w:
            content = chart.toImageBytes(imgOptions)
            w.write(content)
        
        jpype.shutdownJVM()
        				
      • toPdfBytes

         toPdfBytes()
        Creates the chart pdf and saves it to a byte array.
        Returns:
        A byte array.

        Example:

        import jpype
        import asposecells
        jpype.startJVM()
        from asposecells.api import *
        
        wb = Workbook("Book2.xlsx")
        chart = wb.getWorksheets().get("Chart").getCharts().get(0)
        with open("chart.pdf", "wb") as w:
            content = chart.toPdfBytes()
            w.write(content)
        
        jpype.shutdownJVM()
        				
      • toPdfBytes

         toPdfBytes(desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType)
        Creates the chart pdf and saves it to a byte array.
        Parameters:
        desiredPageWidth: float - The desired page width in inches
        desiredPageHeight: float - The desired page height in inches
        hAlignmentType: int - A PageLayoutAlignmentType value. The chart horizontal alignment type in the output page
        vAlignmentType: int - A PageLayoutAlignmentType value. The chart vertical alignment type in the output page
        Returns:
        A byte array.

        Example:

        import jpype
        import asposecells
        jpype.startJVM()
        from asposecells.api import *
        
        wb = Workbook("Book2.xlsx")
        chart = wb.getWorksheets().get("Chart").getCharts().get(0)
        with open("chart2.pdf", "wb") as w:
            content = chart.toPdfBytes(80, 60, PageLayoutAlignmentType.LEFT, PageLayoutAlignmentType.TOP)
            w.write(content)
        
        jpype.shutdownJVM()