We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Cells.SheetType.Chart

Hi,
The example for the pie chart of the graphic displays not the grafic informed, but the graph of doughnut. I am working with the version 4.5.0.0 of ASPOSE.CELLS
Please, help me.
Dim workbook As Aspose.Cells.Workbook
workbook = vaPLanilha
vaPLanilha.Worksheets.Add(Aspose.Cells.SheetType.Worksheet)
Dim sheet As Aspose.Cells.Worksheet = workbook.Worksheets(2)
sheet.Name = "Data"
Dim cells As Aspose.Cells.Cells = workbook.Worksheets(2).Cells
cells("A1").PutValue("Region")
cells("A2").PutValue("France")
cells("A3").PutValue("Germany")
cells("A4").PutValue("England")
cells("A5").PutValue("Sweden")
cells("A6").PutValue("Italy")
cells("A7").PutValue("Spain")
cells("A8").PutValue("Portugal")
cells("B1").PutValue("Sale")
cells("B2").PutValue(70000)
cells("B3").PutValue(55000)
cells("B4").PutValue(30000)
cells("B5").PutValue(40000)
cells("B6").PutValue(35000)
cells("B7").PutValue(32000)
cells("B8").PutValue(10000)
'Add a chart sheet.
Dim sheetIndex As Integer = workbook.Worksheets.Add(Aspose.Cells.SheetType.Chart)
sheet = workbook.Worksheets(sheetIndex)
'Set the name of worksheet
sheet.Name = "Chart"
'Create chart
Dim chartIndex As Integer = 0
chartIndex = sheet.Charts.Add(Aspose.Cells.ChartType.Pie, 1, 1, 25, 10)
Dim chart As Aspose.Cells.Chart = sheet.Charts(chartIndex)
'Set some properties of chart plot area.
'to set the fill color and make the border invisible.
chart.PlotArea.Area.ForegroundColor = Color.Coral
chart.PlotArea.Area.FillFormat.SetTwoColorGradient(Color.Yellow, Color.White, Aspose.Cells.GradientStyleType.Vertical, 2)
chart.PlotArea.Border.IsVisible = False
'Set properties of chart title
chart.Title.Text = "Sales By Region"
chart.Title.TextFont.Color = Color.Blue
chart.Title.TextFont.IsBold = True
chart.Title.TextFont.Size = 12
'Set properties of nseries
chart.NSeries.Add("Data!B2:B8", True)
chart.NSeries.CategoryData = "Data!A2:A8"
chart.NSeries.IsColorVaried = True
'Set the DataLabels in the chart
Dim datalabels As Aspose.Cells.DataLabels
Dim i As Integer
For i = 0 To chart.NSeries.Count - 1 Step 1
datalabels = chart.NSeries(i).DataLabels
datalabels.Postion = Aspose.Cells.LabelPositionType.InsideBase
datalabels.IsCategoryNameShown = True
datalabels.IsValueShown = True
datalabels.IsPercentageShown = False
datalabels.IsLegendKeyShown = False
Next
'Set the ChartArea.
Dim chartarea As Aspose.Cells.ChartArea = chart.ChartArea
chartarea.Area.Formatting = Aspose.Cells.FormattingType.Custom
chartarea.Area.FillFormat.Texture = Aspose.Cells.TextureType.BlueTissuePaper
'Set the Legend.
Dim legend As Aspose.Cells.Legend = chart.Legend
legend.Position = Aspose.Cells.LegendPositionType.Left
legend.Height = 100
legend.Width = 130
legend.Y = 1500
legend.TextFont.IsBold = True
legend.Border.Color = Color.Blue
legend.Area.Formatting = Aspose.Cells.FormattingType.Custom
'Set FillFormat.
Dim fillformat As Aspose.Cells.FillFormat = legend.Area.FillFormat
fillformat.Texture = Aspose.Cells.TextureType.Bouquet
Alexandre

This message was posted using Page2Forum from Manipulating Designer Charts - Aspose.Cells for .NET and Java

Hi,

Well, I don't find the problem you have mentioned. The output chart is just fine and is a pie chart (not a doughnut chart).

Following is my code and attached is the output file, kindly check it. I used version 4.5.0.0.

Dim workbook As Aspose.Cells.Workbook
workbook = New Workbook
'workbook = vaPLanilha
workbook.Worksheets.Add(Aspose.Cells.SheetType.Worksheet)
Dim sheet As Aspose.Cells.Worksheet = workbook.Worksheets(1)
sheet.Name = "Data"
Dim cells As Aspose.Cells.Cells = workbook.Worksheets(1).Cells
cells("A1").PutValue("Region")
cells("A2").PutValue("France")
cells("A3").PutValue("Germany")
cells("A4").PutValue("England")
cells("A5").PutValue("Sweden")
cells("A6").PutValue("Italy")
cells("A7").PutValue("Spain")
cells("A8").PutValue("Portugal")
cells("B1").PutValue("Sale")
cells("B2").PutValue(70000)
cells("B3").PutValue(55000)
cells("B4").PutValue(30000)
cells("B5").PutValue(40000)
cells("B6").PutValue(35000)
cells("B7").PutValue(32000)
cells("B8").PutValue(10000)
'Add a chart sheet.
Dim sheetIndex As Integer = workbook.Worksheets.Add(Aspose.Cells.SheetType.Chart)
sheet = workbook.Worksheets(sheetIndex)
'Set the name of worksheet
sheet.Name = "Chart"
'Create chart
Dim chartIndex As Integer = 0
chartIndex = sheet.Charts.Add(Aspose.Cells.ChartType.Pie, 1, 1, 25, 10)
Dim chart As Aspose.Cells.Chart = sheet.Charts(chartIndex)
'Set some properties of chart plot area.
'to set the fill color and make the border invisible.
chart.PlotArea.Area.ForegroundColor = Color.Coral
chart.PlotArea.Area.FillFormat.SetTwoColorGradient(Color.Yellow, Color.White, Aspose.Cells.GradientStyleType.Vertical, 2)
chart.PlotArea.Border.IsVisible = False
'Set properties of chart title
chart.Title.Text = "Sales By Region"
chart.Title.TextFont.Color = Color.Blue
chart.Title.TextFont.IsBold = True
chart.Title.TextFont.Size = 12
'Set properties of nseries
chart.NSeries.Add("Data!B2:B8", True)
chart.NSeries.CategoryData = "Data!A2:A8"
chart.NSeries.IsColorVaried = True
'Set the DataLabels in the chart
Dim datalabels As Aspose.Cells.DataLabels
Dim i As Integer
For i = 0 To chart.NSeries.Count - 1 Step 1
datalabels = chart.NSeries(i).DataLabels
datalabels.Postion = Aspose.Cells.LabelPositionType.InsideBase
datalabels.IsCategoryNameShown = True
datalabels.IsValueShown = True
datalabels.IsPercentageShown = False
datalabels.IsLegendKeyShown = False
Next
'Set the ChartArea.
Dim chartarea As Aspose.Cells.ChartArea = chart.ChartArea
chartarea.Area.Formatting = Aspose.Cells.FormattingType.Custom
chartarea.Area.FillFormat.Texture = Aspose.Cells.TextureType.BlueTissuePaper
'Set the Legend.
Dim legend As Aspose.Cells.Legend = chart.Legend
legend.Position = Aspose.Cells.LegendPositionType.Left
legend.Height = 100
legend.Width = 130
legend.Y = 1500
legend.TextFont.IsBold = True
legend.Border.Color = Color.Blue
legend.Area.Formatting = Aspose.Cells.FormattingType.Custom
'Set FillFormat.
Dim fillformat As Aspose.Cells.FillFormat = legend.Area.FillFormat
fillformat.Texture = Aspose.Cells.TextureType.Bouquet

workbook.Save("f:\test\out_pie_chart1.xls")

Could you run the code above and attach your output file using Aspose.Cells for .NET 4.5

Thank you.