IRONSOFTWAREHOME
建立 Excel 圖表
from ironxl import *

# Load the Excel workbook
workbook = WorkBook.Load("test.xlsx")
worksheet = workbook.DefaultWorkSheet

# Set the chart type and its position on the worksheet.
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 the horizontal(category) axis.
# The second parameter represents the address of the range for the vertical(value) axis.
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 calls to this method lead to plotting multiple charts instead of modifying the existing chart.
# Yet there is no possibility to remove a chart or edit its series/position.
# We can just create a new one.
chart.Plot()

# Save changes with the created line chart
workbook.SaveAs("CreateLineChart.xlsx")
pip install ironxl
建立 Excel 圖表

建立 Excel 圖表

IronXL for Python支援在現代XLSX文件格式中的Excel文件內建立和編輯圖表。

此範例展示如何建立折線圖。 其他圖表型別也受到支援。

探索Python Excel圖表建立和編輯指南

準備好開始了嗎?

版本:2026.10剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰。

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronXL for Python
預訂您的免費 即時示範
Booking Badge

獲得數百萬工程師的信賴世界各地

Iron Software 的客戶標誌
獲取無需承諾的諮詢
您的資訊將永遠 保持機密。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
獲得數百萬工程師的信賴世界各地
立即獲取您的30天試用金鑰。
無需信用卡或帳戶建立
Excel 用的 Python 模組下載
用 pip 安裝

版本: 2026.10

  1. 下載並安裝 Python 3.7+。
  2. 從 pypi.org 安裝 pip 如果尚未安裝。
  3. 在終端執行上述命令。
Python PDF 模組
下載 模組

版本: 2026.10

手動安裝到您的專案

  1. 下載套件
  2. 從終端執行此命令
    pip install IronXL-2026.10-py37-none-win_amd64.whi

授權從 $999