Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Description

Excerpt

A Chartsheet object represents a worksheet that contains only a chart.

Signature
C#
C#
 public sealed class Chartsheet : Worksheet
{signature}{signature:
}
Signature
vb.net
vb.net
Public NotInheritable Class Chartsheet
		Inherits Worksheet
{signature}
{remarks}
To create a {{Chartsheet}}, use [
Remarks

To create a Chartsheet, use Worksheets.createChartsheet()

|Worksheets.createChartsheet]

or

[

Chart.MoveChart()

|Chart

.

MoveChart].

To

get

an

existing

{{

Chartsheet

}}

,

get

a

[

Worksheet

|Worksheet]

using

[

Workbook.Worksheets

\

[i

\

]

|Worksheets.Item(Int32)]

and

check

if

it

is

of

type

{{

Chartsheet

}}

.

[Anchors|Anchor] behave slightly differently on Chartsheets than on regular worksheets. When creating an anchor, the row and column properties are ignored. The OffsetX and OffsetY properties specify a percentage value, with 0 corresponding to the left or top edge, and 100 corresponding to the bottom or right edge of the Chartsheet. This allows you to add a shape or picture to an arbitrary position on the Chartsheet. Similarly, the Width and Height properties on Shapes, Pictures, and Groups specify a percentage of the total width or height of the chartsheet. So a Shape with a width of 25 would occupy 25% of the Chartsheet. You can have as many Shape, Pictures, and Groups as you wish on the chartsheet. However, you may only have one chart on the chartsheet, which is specified with the [Chart|Chartsheet.Chart] property. Some [Worksheet] properties are not valid on a Chartsheet. {web-only:For a summary of the behavior of Worksheet properties on Chartsheets, refer to our online documentation} The following table summarizes the behavior of Worksheet properties on Chartsheets. If you try to access or set a property on a Chartsheet that is not valid, an InvalidOperationException will be thrown. Some properties will behave as AutoProperties, but will have no effect in the saved file. If the property is supported but there are differences in behavior from Worksheets, the differences are described in the Notes column. (x) Property or method is not valid on Chartsheets, and will throw an InvalidOperationException (/) Property or method is fully supported on Chartsheets (!) Property behaves as an autoproperty, but will have no effect on the resulting file. || Property || Valid on Chartsheet || Notes || | [Cells|Worksheet.Cells] | (!) | Returns a [Cells] object, but using any methods or properties on the object will throw an InvalidOperationException. | | [Charts|Worksheet.Charts] | (x) | | | [Comments|Worksheet.Comments] | (x) | | | [FirstShownColumn|Worksheet.FirstShownColumn] | (!) | | | [FirstShownRow|Worksheet.FirstShownRow] | (!) | | | [FreezePanes|Worksheet.FreezePanes] | (x) | | | [GridlinesColor|Worksheet.GridlinesColor] | (!) | | | [Hyperlinks|Worksheet.Hyperlinks] | (x) | | | [IsProtected|Worksheet.IsProtected] | (/) | | | [IsSelected|Worksheet.IsSelected] | (/) | | | [Name|Worksheet.Name] | (/) | | | [NamedRanges|Worksheet.NamedRanges] | (!) | Returns an empty enumeration | | [PageSetup|Worksheet.PageSetup] | (/) | Returns a [ChartPageSetup] object | | [Pictures|Worksheet.Pictures] | (/) | | | [PopulatedCells|Worksheet.PopulatedCells] | (x) | | | [Position|Worksheet.Position] | (/) | | | [ProtectPasswordHash|Worksheet.ProtectPasswordHash] | (/) | | | [ShapeGroups|Worksheet.ShapeGroups] | (/) | | | [Shapes|Worksheet.Shapes] | (/) | | | [ShowFormulas|Worksheet.ShowFormulas] | (!) | | | [ShowGridlines|Worksheet.ShowGridlines] | (!) | | | [ShowRowColHeaders|Worksheet.ShowRowColHeaders] | (!) | | | [ShowZeroValues|Worksheet.ShowZeroValues] | (!) | | | [StandardHeight|Worksheet.StandardHeight] | (x) | | | [StandardWidth|Worksheet.StandardWidth] | (x) | | | [StandardWidthInChars|Worksheet.StandardWidthInChars] | (x) | | | [SummaryColumns|Worksheet.SummaryColumns] | (x) | | | [SummaryRows|Worksheet.SummaryRows] | (x) | | | [TabColor|Worksheet.TabColor] | (/) | | | [Workbook|Worksheet.Workbook] | (/) | | | [ViewState|Worksheet.ViewState] | (!) | Returns SheetViewState.Normal. Setting it to a different value with throw an InvalidOperationException. | | [Visibility|Worksheet.Visibility] | (/) | | | [ZoomPercentage|Worksheet.ZoomPercentage] | (/) | Defaults to 120% | || Method || Valid on Chartsheet || Notes || | [Item(Int32, Int32)|Worksheet.Item(Int32, Int32)] | (x) | | | [Item(String)|Worksheet.Item(String)] | (x) | | | [CopyPaste|Worksheet.CopyPaste] | (x) | | | [CreateAnchor|Worksheet.CreateAnchor(Int32, Int32, Double, Double)] | (/) | The row and column properties will be ignored. The offset properties should specify a percentage of the entire chartsheet. | | [CreateArea|Worksheet.CreateArea] | (x) | | | [CreateAreaOfColumns|Worksheet.CreateAreaOfColumns(Int32, Int32)] | (x) | | | [CreateAreaOfRows|Worksheet.CreateAreaOfRows(Int32, Int32)] | (x) | | | [CreateNamedRange|Worksheet.CreateNamedRange] | (x) | | | [CreateRange|Worksheet.CreateRange(String)] | (x) | | | [DeleteColumn|Worksheet.DeleteColumn(Int32)] | (x) | | | [DeleteColumns|Worksheet.DeleteColumns(Int32, Int32)] | (x) | | | [DeleteRow|Worksheet.DeleteRow(Int32)] | (x) | | | [DeleteRows|Worksheet.DeleteRows(Int32, Int32)] | (x) | | | [GetColumnProperties|Worksheet.GetColumnProperties(Int32)] | (x) | | | [GetNamedObject|Worksheet.GetNamedObject(String)] | (x) | | | [GetNamedRange|Worksheet.GetNamedRange(String)] | (x) | | | [GetRowProperties|Worksheet.GetRowProperties(Int32)] | (x) | | | [GroupColumns|Worksheet.GroupColumns(Int32, Int32, Boolean)] | (x) | | | [GroupRows|Worksheet.GroupRows(Int32, Int32, Boolean)] | (x) | | | [ImportData|Worksheet.ImportData] | (x) | | | [InsertColumn|Worksheet.InsertColumn] | (x) | | | [InsertColumns|Worksheet.InsertColumns] | (x) | | | [InsertHorizontalPageBreak|Worksheet.InsertHorizontalPageBreak(Cell)] | (x) | | | [InsertRow|Worksheet.InsertRow] | (x) | | | [InsertRows|Worksheet.InsertRows] | (x) | | | [InsertVerticalPageBreak|Worksheet.InsertVerticalPageBreak(Cell)] | (x) | | | [Protect|Worksheet.Protect(String)] | (/) | | | [Select|Worksheet.Select()] | (/) | | | [UngroupColumns|Worksheet.UngroupColumns(Int32, Int32)] | (x) | | | [UngroupRows|Worksheet.UngroupRows(Int32, Int32)] | (x) | | | [Unprotect|Worksheet.Unprotect()] | (/) | | {web-only} {remarks} {example}{code:csharp|title=C#}

Anchors behave slightly differently on Chartsheets than on regular worksheets. When creating an anchor, the row and column properties are ignored. The OffsetX and OffsetY properties specify a percentage value, with 0 corresponding to the left or top edge, and 100 corresponding to the bottom or right edge of the Chartsheet. This allows you to add a shape or picture to an arbitrary position on the Chartsheet.

Similarly, the Width and Height properties on Shapes, Pictures, and Groups specify a percentage of the total width or height of the chartsheet. So a Shape with a width of 25 would occupy 25% of the Chartsheet.

You can have as many Shape, Pictures, and Groups as you wish on the chartsheet. However, you may only have one chart on the chartsheet, which is specified with the Chart property.

Some Worksheet properties are not valid on a Chartsheet.

Web only
For a summary of the behavior of Worksheet properties on Chartsheets, refer to our online documentation
For a summary of the behavior of Worksheet properties on Chartsheets, refer to our online documentation

The following table summarizes the behavior of Worksheet properties on Chartsheets. If you try to access or set a property on a Chartsheet that is not valid, an InvalidOperationException will be thrown. Some properties will behave as AutoProperties, but will have no effect in the saved file. If the property is supported but there are differences in behavior from Worksheets, the differences are described in the Notes column.

(error) Property or method is not valid on Chartsheets, and will throw an InvalidOperationException
(tick) Property or method is fully supported on Chartsheets
(warning) Property behaves as an autoproperty, but will have no effect on the resulting file.

Property

Valid on Chartsheet

Notes

Cells

(warning)

Returns a Cells object, but using any methods or properties on the object will throw an InvalidOperationException.

Charts

(error)

 

Comments

(error)

 

FirstShownColumn

(warning)

 

FirstShownRow

(warning)

 

FreezePanes

(error)

 

GridlinesColor

(warning)

 

Hyperlinks

(error)

 

IsProtected

(tick)

 

IsSelected

(tick)

 

Name

(tick)

 

NamedRanges

(warning)

Returns an empty enumeration

PageSetup

(tick)

Returns a ChartPageSetup object

Pictures

(tick)

 

PopulatedCells

(error)

 

Position

(tick)

 

ProtectPasswordHash

(tick)

 

ShapeGroups

(tick)

 

Shapes

(tick)

 

ShowFormulas

(warning)

 

ShowGridlines

(warning)

 

ShowRowColHeaders

(warning)

 

ShowZeroValues

(warning)

 

StandardHeight

(error)

 

StandardWidth

(error)

 

StandardWidthInChars

(error)

 

SummaryColumns

(error)

 

SummaryRows

(error)

 

TabColor

(tick)

 

Workbook

(tick)

 

ViewState

(warning)

Returns SheetViewState.Normal. Setting it to a different value with throw an InvalidOperationException.

Visibility

(tick)

 

ZoomPercentage

(tick)

Defaults to 120%

Method

Valid on Chartsheet

Notes

Item(Int32, Int32)

(error)

 

Item(String)

(error)

 

CopyPaste

(error)

 

CreateAnchor

(tick)

The row and column properties will be ignored. The offset properties should specify a percentage of the entire chartsheet.

CreateArea

(error)

 

CreateAreaOfColumns

(error)

 

CreateAreaOfRows

(error)

 

CreateNamedRange

(error)

 

CreateRange

(error)

 

DeleteColumn

(error)

 

DeleteColumns

(error)

 

DeleteRow

(error)

 

DeleteRows

(error)

 

GetColumnProperties

(error)

 

GetNamedObject

(error)

 

GetNamedRange

(error)

 

GetRowProperties

(error)

 

GroupColumns

(error)

 

GroupRows

(error)

 

ImportData

(error)

 

InsertColumn

(error)

 

InsertColumns

(error)

 

InsertHorizontalPageBreak

(error)

 

InsertRow

(error)

 

InsertRows

(error)

 

InsertVerticalPageBreak

(error)

 

Protect

(tick)

 

Select

(tick)

 

UngroupColumns

(error)

 

UngroupRows

(error)

 

Unprotect

(tick)

 

Web only

Example
Code Block
csharp
csharp
titleC#


          //--- Create a Chartsheet
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Create();
          Worksheet ws = wb.Worksheets[0];
          Chartsheet cs = wb.Worksheets.CreateChartsheet
               (ChartType.Pie.Pie3D, "Chart");

          //--- Get the first Chartsheet from a Workbook
          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Open("C:\\MySpreadsheet.xls");
          bool found = false;
          for(int i = 0; i < wb.Worksheets.Count; i++)
          {
               if (found == false)
               {
                    Worksheet ws = wb.Worksheets[i];
                    
                    if(ws is Chartsheet)
                    {
                         Chartsheet cs = (Chartsheet)ws;
                         found = true;
                    }
               }
          }
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          '--- Create a Chartsheet
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Create()
          Dim ws As Worksheet = wb.Worksheets(0)
          Dim cs As Chartsheet = wb.Worksheets.CreateChartsheet _
               (ChartType.Pie.Pie3D, "Chart")

          '--- Get the first Chartsheet from a Workbook
          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Open("C:\MySpreadsheet.xls")
          Dim found As Boolean = False
          Dim i As Integer
          For i = 0 To wb.Worksheets.Count - 1
               If found = False Then
                    Dim ws As Worksheet = wb.Worksheets(i)

                    If ws Is Chartsheet Then
                         Dim cs As Chartsheet = CType(ws, Chartsheet)
                         found = True
                    End If
               End If
          Next
        
{code} {example} {properties} ||Name||Description|| |[Chart|Chartsheet.Chart]|{excerpt-include:Chartsheet.Chart|nopanel=true}|
Properties

Name

Description

Chart

Excerpt Include
Chartsheet.Chart
Chartsheet.Chart
nopaneltrue