using IronXL;
using IronXL.Drawing.Charts;
WorkBook workBook = WorkBook.Load("test.xlsx");
WorkSheet workSheet = workBook.DefaultWorkSheet;
// Set the chart type and it's position on the worksheet.
var chart = workSheet.CreateChart(ChartType.Line, 10, 10, 18, 20);
// Add the series to the chart
// The first parameter represents the address of the range for horizontal(category) axis.
// The second parameter represents the address of the range for vertical(value) axis.
var series = chart.AddSeries("B3:B8", "A3:A8");
// Set the chart title.
series.Title = "Line Chart";
// Set the legend position.
// Can be removed by setting it to None.
chart.SetLegendPosition(LegendPosition.Bottom);
// We can change the position of the chart.
chart.Position.LeftColumnIndex = 2;
chart.Position.RightColumnIndex = chart.Position.LeftColumnIndex + 3;
// Plot all the data that was added to the chart before.
// Multiple call of this method leads to plotting multiple charts instead of modifying the existing chart.
// Yet there is no possibility to remove chart or edit it's series/position.
// We can just create new one.
chart.Plot();
workBook.SaveAs("CreateLineChart.xlsx");
Imports IronXL
Imports IronXL.Drawing.Charts
Private workBook As WorkBook = WorkBook.Load("test.xlsx")
Private workSheet As WorkSheet = workBook.DefaultWorkSheet
' Set the chart type and it's position on the worksheet.
Private chart = workSheet.CreateChart(ChartType.Line, 10, 10, 18, 20)
' Add the series to the chart
' The first parameter represents the address of the range for horizontal(category) axis.
' The second parameter represents the address of the range for vertical(value) axis.
Private series = chart.AddSeries("B3:B8", "A3:A8")
' Set the chart title.
series.Title = "Line Chart"
' Set the legend position.
' Can be removed by setting it to None.
chart.SetLegendPosition(LegendPosition.Bottom)
' We can change the position of the chart.
chart.Position.LeftColumnIndex = 2
chart.Position.RightColumnIndex = chart.Position.LeftColumnIndex + 3
' Plot all the data that was added to the chart before.
' Multiple call of this method leads to plotting multiple charts instead of modifying the existing chart.
' Yet there is no possibility to remove chart or edit it's series/position.
' We can just create new one.
chart.Plot()
workBook.SaveAs("CreateLineChart.xlsx")
Install-Package IronXL.Excel
Créer un graphique Excel
IronXL prend en charge la création et l'édition de graphiques pour les documents Excel dans le format de fichier moderne XLSX.
Cet exemple montre comment créer un graphique linéaire. D'autres types de graphiques sont également pris en charge.
Des millions d'ingénieurs dans le monde entier lui font confiance
Réservez une démo en direct gratuite
Réservez une démonstration personnelle de 30 minutes.
Pas de contrat, pas de détails de carte, pas d'engagements.
Voici ce à quoi vous pouvez vous attendre :
Une démonstration en direct de notre produit et de ses principales fonctionnalités
Obtenez des recommandations de fonctionnalités spécifiques au projet
Toutes vos questions trouvent réponse pour vous assurer de disposer de toutes les informations dont vous avez besoin. (Aucune obligation de votre part.)
CHOISIR L'HEURE
VOS INFORMATIONS
Réservez votre gratuit Démonstration en direct
Fiable par plus de 2 millions d'ingénieurs dans le monde entier