Example:
//Instantiating a Workbook object $workbook = new cells\Workbook(); //Adding a new worksheet to the Excel object $sheetIndex = $workbook->getWorksheets()->add(); //Obtaining the reference of the newly added worksheet by passing its sheet index $worksheet = $workbook->getWorksheets()->get($sheetIndex); //Adding a sample value to "A1" cell $worksheet->getCells()->get("A1")->putValue(50); //Adding a sample value to "A2" cell $worksheet->getCells()->get("A2")->putValue(100); //Adding a sample value to "A3" cell $worksheet->getCells()->get("A3")->putValue(150); //Adding a sample value to "A4" cell $worksheet->getCells()->get("A4")->putValue(200); //Adding a sample value to "B1" cell $worksheet->getCells()->get("B1")->putValue(60); //Adding a sample value to "B2" cell $worksheet->getCells()->get("B2")->putValue(32); //Adding a sample value to "B3" cell $worksheet->getCells()->get("B3")->putValue(50); //Adding a sample value to "B4" cell $worksheet->getCells()->get("B4")->putValue(40); //Adding a sample value to "C1" cell as category data $worksheet->getCells()->get("C1")->putValue("Q1"); //Adding a sample value to "C2" cell as category data $worksheet->getCells()->get("C2")->putValue("Q2"); //Adding a sample value to "C3" cell as category data $worksheet->getCells()->get("C3")->putValue("Y1"); //Adding a sample value to "C4" cell as category data $worksheet->getCells()->get("C4")->putValue("Y2"); //Adding a chart to the worksheet $chartIndex = $worksheet->getCharts()->add(cells\ChartType::COLUMN, 5, 0, 15, 5); //Accessing the instance of the newly added chart $chart = $worksheet->getCharts()->get($chartIndex); //Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B4" $chart->getNSeries()->add("A1:B4", true); //Setting the data source for the category data of NSeries $chart->getNSeries()->setCategoryData("C1:C4"); //adding a linear trendline $index = $chart->getNSeries()->get(0)->getTrendLines()->add(cells\TrendlineType::LINEAR); $trendline = $chart->getNSeries()->get(0)->getTrendLines()->get($index); //Setting the custom name of the trendline $trendline->setName("Linear"); //Displaying the equation on chart $trendline->setDisplayEquation(true); //Displaying the R-Squared value on chart $trendline->setDisplayRSquared(true);
Property Getters/Setters Summary | ||
---|---|---|
function | getBackward() | |
function | setBackward(value) | |
Returns or sets the number of periods (or units on a scatter chart) that the trendline extends backward. The number of periods must be greater than or equal to zero. If the chart type is column ,the number of periods must be between 0 and 0.5 | ||
function | getBeginArrowLength() | |
function | setBeginArrowLength(value) | |
Specifies the length of the arrowhead for the begin of a line. The value of the property is MsoArrowheadLength integer constant. | ||
function | getBeginArrowWidth() | |
function | setBeginArrowWidth(value) | |
Specifies the width of the arrowhead for the begin of a line. The value of the property is MsoArrowheadWidth integer constant. | ||
function | getBeginType() | |
function | setBeginType(value) | |
Specifies an arrowhead for the begin of a line. The value of the property is MsoArrowheadStyle integer constant. | ||
function | getCapType() | |
function | setCapType(value) | |
Specifies the ending caps. The value of the property is LineCapType integer constant. | ||
function | getColor() | |
function | setColor(value) | |
Represents the |
||
function | getCompoundType() | |
function | setCompoundType(value) | |
Specifies the compound line type The value of the property is MsoLineStyle integer constant. | ||
function | getDashType() | |
function | setDashType(value) | |
Specifies the dash line type The value of the property is MsoLineDashStyle integer constant. | ||
function | getDataLabels() | |
Represents the DataLabels object for the specified series.
|
||
function | getDisplayEquation() | |
function | setDisplayEquation(value) | |
Represents if the equation for the trendline is displayed on the chart (in the same data label as the R-squared value). Setting this property to True automatically turns on data labels. | ||
function | getDisplayRSquared() | |
function | setDisplayRSquared(value) | |
Represents if the R-squared value of the trendline is displayed on the chart (in the same data label as the equation). Setting this property to True automatically turns on data labels. | ||
function | getEndArrowLength() | |
function | setEndArrowLength(value) | |
Specifies the length of the arrowhead for the end of a line. The value of the property is MsoArrowheadLength integer constant. | ||
function | getEndArrowWidth() | |
function | setEndArrowWidth(value) | |
Specifies the width of the arrowhead for the end of a line. The value of the property is MsoArrowheadWidth integer constant. | ||
function | getEndType() | |
function | setEndType(value) | |
Specifies an arrowhead for the end of a line. The value of the property is MsoArrowheadStyle integer constant. | ||
function | getFormattingType() | |
function | setFormattingType(value) | |
Gets or sets format type. The value of the property is ChartLineFormattingType integer constant. | ||
function | getForward() | |
function | setForward(value) | |
Returns or sets the number of periods (or units on a scatter chart) that the trendline extends forward. The number of periods must be greater than or equal to zero. | ||
function | getGradientFill() | |
Represents gradient fill.
|
||
function | getIntercept() | |
function | setIntercept(value) | |
Returns or sets the point where the trendline crosses the value axis. | ||
function | isAuto() | |
function | setAuto(value) | |
Indicates whether this line style is auto assigned. | ||
function | isAutomaticColor() | |
Indicates whether the color of line is automatic assigned.
|
||
function | isNameAuto() | |
function | setNameAuto(value) | |
Returns if Microsoft Excel automatically determines the name of the trendline. | ||
function | isVisible() | |
function | setVisible(value) | |
Represents whether the line is visible. | ||
function | getJoinType() | |
function | setJoinType(value) | |
Specifies the joining caps. The value of the property is LineJoinType integer constant. | ||
function | getLegendEntry() | |
Gets the legend entry according to this trendline
|
||
function | getName() | |
function | setName(value) | |
Returns the name of the trendline. | ||
function | getOrder() | |
function | setOrder(value) | |
Returns or sets the trendline order (an integer greater than 1) when the trendline type is Polynomial. The order must be between 2 and 6. | ||
function | getPeriod() | |
function | setPeriod(value) | |
Returns or sets the period for the moving-average trendline. | ||
function | getStyle() | |
function | setStyle(value) | |
Represents the style of the line. The value of the property is LineType integer constant. | ||
function | getThemeColor() | |
function | setThemeColor(value) | |
Gets and sets the theme color. | ||
function | getTransparency() | |
function | setTransparency(value) | |
Returns or sets the degree of transparency of the line as a value from 0.0 (opaque) through 1.0 (clear). | ||
function | getType() | |
Returns the trendline type.
The value of the property is TrendlineType integer constant. |
||
function | getWeight() | |
function | setWeight(value) | |
Gets or sets the |
||
function | getWeightPt() | |
function | setWeightPt(value) | |
Gets or sets the weight of the line in unit of points. | ||
function | getWeightPx() | |
function | setWeightPx(value) | |
Gets or sets the weight of the line in unit of pixels. |
Method Summary | ||
---|---|---|
function | isInterceptAuto() | |
Indicates whether Microsoft Workbook automatically determines the intercept of the trendline.
|
||
function | setInterceptAuto(isInterceptAuto) | |
Sets whether Microsoft Workbook automatically determines the intercept of the trendline.
|
function isNameAuto() / function setNameAuto(value)
function getType()
function getName() / function setName(value)
function getOrder() / function setOrder(value)
function getPeriod() / function setPeriod(value)
function getForward() / function setForward(value)
function getBackward() / function setBackward(value)
function getDisplayEquation() / function setDisplayEquation(value)
function getDisplayRSquared() / function setDisplayRSquared(value)
function getIntercept() / function setIntercept(value)
function getDataLabels()
function getLegendEntry()
function getCompoundType() / function setCompoundType(value)
function getDashType() / function setDashType(value)
function getCapType() / function setCapType(value)
function getJoinType() / function setJoinType(value)
function getBeginType() / function setBeginType(value)
function getEndType() / function setEndType(value)
function getBeginArrowLength() / function setBeginArrowLength(value)
function getEndArrowLength() / function setEndArrowLength(value)
function getBeginArrowWidth() / function setBeginArrowWidth(value)
function getEndArrowWidth() / function setEndArrowWidth(value)
function getThemeColor() / function setThemeColor(value)
function getColor() / function setColor(value)
function getTransparency() / function setTransparency(value)
function getStyle() / function setStyle(value)
function getWeight() / function setWeight(value)
function getWeightPt() / function setWeightPt(value)
function getWeightPx() / function setWeightPx(value)
function getFormattingType() / function setFormattingType(value)
function isAutomaticColor()
function isVisible() / function setVisible(value)
function isAuto() / function setAuto(value)
function getGradientFill()