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 | ||
---|---|---|
method | getActualChartSize() | |
Gets actual size of chart
|
||
method | getAutoScaling() | |
method | 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. | ||
method | getBackWall() | |
Returns a |
||
method | getCategoryAxis() | |
Gets the chart's X axis.
|
||
method | getChartArea() | |
Gets the chart area in the worksheet
|
||
method | getChartDataTable() | |
Represents the chart data table.
|
||
method | getChartObject() | |
Represents the chartShape;
|
||
method | getChartShape() | |
Represents the chartShape;
|
||
method | getDepthPercent() | |
method | setDepthPercent(value) | |
Represents the depth of a 3-D chart as a percentage of the chart width (between 20 and 2000 percent). | ||
method | getDisplayNaAsBlank() | |
method | setDisplayNaAsBlank(value) | |
Indicates whether displaying #N/A as blank value. | ||
method | getElevation() | |
method | setElevation(value) | |
Represents the elevation of the 3-D chart view, in degrees. | ||
method | getFirstSliceAngle() | |
method | 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. | ||
method | getFloor() | |
Returns a |
||
method | getGapDepth() | |
method | 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. | ||
method | getGapWidth() | |
method | 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. | ||
method | getHeightPercent() | |
method | setHeightPercent(value) | |
Returns or sets the height of a 3-D chart as a percentage of the chart width (between 5 and 500 percent). | ||
method | getHidePivotFieldButtons() | |
method | setHidePivotFieldButtons(value) | |
Indicates whether hide the pivot chart field buttons only when the chart is PivotChart | ||
method | getIs3D() | |
Indicates whether the chart is a 3d chart.
|
||
method | isRectangularCornered() | |
method | setRectangularCornered(value) | |
Gets or sets a value indicating whether the chart area is rectangular cornered. Default is true. | ||
method | getLegend() | |
Gets the chart legend.
|
||
method | getLine() | |
Gets the line.
|
||
method | getName() | |
method | setName(value) | |
Gets and sets the name of the chart. | ||
method | getNSeries() | |
Gets a |
||
method | getPageSetup() | |
Represents the page setup description in this chart.
|
||
method | getPerspective() | |
method | 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. | ||
method | getPivotOptions() | |
Specifies the pivot controls that appear on the chart
|
||
method | getPivotSource() | |
method | setPivotSource(value) | |
The source is the data of the pivotTable. If PivotSource is not empty ,the chart is PivotChart. | ||
method | getPlacement() | |
method | setPlacement(value) | |
Represents the way the chart is attached to the cells below it. The value of the property is PlacementType integer constant. | ||
method | getPlotArea() | |
Gets the chart's plot area which includes axis tick labels.
|
||
method | getPlotBy() | |
Gets and sets whether plot by row or column.
The value of the property is PlotDataByType integer constant. |
||
method | getPlotEmptyCellsType() | |
method | setPlotEmptyCellsType(value) | |
Gets and sets how to plot the empty cells. The value of the property is PlotEmptyCellsType integer constant. | ||
method | getPlotVisibleCells() | |
method | setPlotVisibleCells(value) | |
Indicates whether only plot visible cells. | ||
method | getPrintSize() | |
method | setPrintSize(value) | |
Gets and sets the printed chart size. The value of the property is PrintSizeType integer constant. | ||
method | getRightAngleAxes() | |
method | setRightAngleAxes(value) | |
True if the chart axes are at right angles. Applies only for 3-D charts(except Column3D and 3-D Pie Charts). | ||
method | getRotationAngle() | |
method | setRotationAngle(value) | |
Represents the rotation of the 3-D chart view (the rotation of the plot area around the z-axis, in degrees). | ||
method | getSecondCategoryAxis() | |
Gets the chart's second X axis.
|
||
method | getSecondValueAxis() | |
Gets the chart's second Y axis.
|
||
method | getSeriesAxis() | |
Gets the chart's series axis.
|
||
method | getShapes() | |
Returns all drawing shapes in this chart.
|
||
method | getShowDataTable() | |
method | setShowDataTable(value) | |
Gets or sets a value indicating whether the chart displays a data table. | ||
method | getShowLegend() | |
method | setShowLegend(value) | |
Gets or sets a value indicating whether the chart legend will be displayed. Default is true. | ||
method | getSideWall() | |
Returns a |
||
method | getSizeWithWindow() | |
method | setSizeWithWindow(value) | |
True if Microsoft Excel resizes the chart to match the size of the chart sheet window. | ||
method | getStyle() | |
method | setStyle(value) | |
Gets and sets the builtin style. | ||
method | getSubTitle() | |
Gets the chart's sub-title.
Only for ODS format file.
|
||
method | getTitle() | |
Gets the chart's title.
|
||
method | getType() | |
method | setType(value) | |
Gets or sets a chart's type. The value of the property is ChartType integer constant. | ||
method | getValueAxis() | |
Gets the chart's Y axis.
|
||
method | getWalls() | |
Returns a |
||
method | getWallsAndGridlines2D() | |
method | setWallsAndGridlines2D(value) | |
True if gridlines are drawn two-dimensionally on a 3-D chart. | ||
method | getWorksheet() | |
Gets the worksheet which contains this chart.
|
Method Summary | ||
---|---|---|
method | calculate() | |
Calculates the custom position of plot area, axes if the position of them are auto assigned.
|
||
method | getChartDataRange() | |
Gets the data source range of the chart .
|
||
method | hasAxis(aixsType, isPrimary) | |
Returns which axes exist on the chart.
|
||
method | isChartDataChanged() | |
Detects if a chart's data source has changed.
|
||
method | move(upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn) | |
Moves the chart to a specified location.
|
||
method | refreshPivotData() | |
Refreshes pivot chart's data from it's pivot data source.
|
||
method | setChartDataRange(area, isVertical) | |
Specifies data range for a chart.
|
||
method | switchRowColumn() | |
Switches row/column.
|
||
method | toImage(imageFile) | |
Creates the chart image and saves it to a file.
The extension of the file name determines the format of the image.
|
||
method | toImage(imageFile, imageFormat) | |
Creates the chart image and saves it to a file in the specified format.
|
||
method | 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.
|
||
method | toImage(imageFile, jpegQuality) | |
Creates the chart image and saves it to a file in the Jpeg format.
|
||
method | toImageBytes(options) | |
Creates the chart image and saves it to a byte array in the specified format.
|
||
method | toPdf(fileName) | |
Saves the chart to a pdf file.
|
||
method | toPdf(fileName, desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType) | |
Saves the chart to a pdf file.
|
||
method | toPdfBytes() | |
Creates the chart pdf and saves it to a byte array.
|
||
method | toPdfBytes(desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType) | |
Creates the chart pdf and saves it to a byte array.
|
int getStyle() / setStyle(value)
ChartShape getChartObject()
boolean getHidePivotFieldButtons() / setHidePivotFieldButtons(value)
PivotOptions getPivotOptions()
String getPivotSource() / setPivotSource(value)
int getPlotBy()
int getPlotEmptyCellsType() / setPlotEmptyCellsType(value)
boolean getPlotVisibleCells() / setPlotVisibleCells(value)
boolean getDisplayNaAsBlank() / setDisplayNaAsBlank(value)
String getName() / setName(value)
boolean getSizeWithWindow() / setSizeWithWindow(value)
ShapeCollection getShapes()
int getPrintSize() / setPrintSize(value)
int getType() / setType(value)
SeriesCollection getNSeries()
PlotArea getPlotArea()
ChartDataTable getChartDataTable()
boolean getShowLegend() / setShowLegend(value)
boolean isRectangularCornered() / setRectangularCornered(value)
boolean getShowDataTable() / setShowDataTable(value)
int getFirstSliceAngle() / setFirstSliceAngle(value)
int getGapWidth() / setGapWidth(value)
int getGapDepth() / setGapDepth(value)
Floor getFloor()
Walls getWalls()
Walls getBackWall()
Walls getSideWall()
boolean getWallsAndGridlines2D() / setWallsAndGridlines2D(value)
int getRotationAngle() / setRotationAngle(value)
int getElevation() / setElevation(value)
boolean getRightAngleAxes() / setRightAngleAxes(value)
boolean getAutoScaling() / setAutoScaling(value)
int getHeightPercent() / setHeightPercent(value)
int getPerspective() / setPerspective(value)
boolean getIs3D()
int getDepthPercent() / setDepthPercent(value)
Dimension getActualChartSize()
int getPlacement() / setPlacement(value)
PageSetup getPageSetup()
ChartShape getChartShape()
toImage(imageFile)
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.imageFile: String
- The image file name with full path.toImage(imageFile, imageFormat)
The format of the image is specified by using imageFormat
.
The following formats are supported:
ImageFormat.Bmp, ImageFormat.Gif, ImageFormat.Png, ImageFormat.Jpeg, ImageFormat.Tiff, ImageFormat.Emf.
imageFile: String
- The image file name with full path.imageFormat: ImageFormat
- The format in which to save the image.toImage(imageFile, jpegQuality)
imageFile: String
- The image file name with full path.jpegQuality: long
- Jpeg quality.toPdf(fileName)
fileName: String
- the pdf file name with full pathtoPdf(fileName, desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType)
fileName: String
- the pdf file name with full pathdesiredPageWidth: float
- The desired page width in inches.desiredPageHeight: float
- The desired page height in inches.hAlignmentType: int
- A vAlignmentType: int
- A toImage(imageFile, options)
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.imageFile: String
- The image file name with full path.options: ImageOrPrintOptions
- Additional image creation optionsExample:
options = ImageOrPrintOptions() options.setHorizontalResolution(300) options.setVerticalResolution(300) book = Workbook("Book2.xlsx") book.getWorksheets().get(3).getCharts().get(0).toImage("chart.png", options)
boolean hasAxis(aixsType, isPrimary)
aixsType
- A AxisType value.boolean switchRowColumn()
String getChartDataRange()
setChartDataRange(area, isVertical)
area: String
- Specifies values from which to plot the data seriesisVertical: boolean
- Specifies whether to plot the series from a range of cell values by row or by column.boolean isChartDataChanged()
refreshPivotData()
move(upperLeftRow, upperLeftColumn, lowerRightRow, lowerRightColumn)
upperLeftColumn: int
- Upper left column index.upperLeftRow: int
- Upper left row index.lowerRightColumn: int
- Lower right column indexlowerRightRow: int
- Lower right row indexcalculate()
toImageBytes(options)
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.
options: ImageOrPrintOptions
- Addtional image creation optionsExample:
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()
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(desiredPageWidth, desiredPageHeight, hAlignmentType, vAlignmentType)
desiredPageWidth: float
- The desired page width in inchesdesiredPageHeight: float
- The desired page height in incheshAlignmentType: int
- A PageLayoutAlignmentType value. The chart horizontal alignment type in the output pagevAlignmentType: int
- A PageLayoutAlignmentType value. The chart vertical alignment type in the output pageExample:
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()