openpyxl
我想在这个视频中使用 python 创建一个 Excel 文件: https ://youtu.be/fqvZZp2q2uE
代码很简单:
# See full Toturial at my Youtube Channel(YB TV): https://www.youtube.com/channel/UCvnhhDKv5takEN412dmVW8g/featured
# GitHab Page:https://github.com/yasser64b/
#Email: big3del@gmail.com
from openpyxl import Workbook
from openpyxl.chart import BarChart, Reference, Series, LineChart, ScatterChart
from openpyxl.styles import Font, Color, colors
wb = Workbook()
ws = wb.active
for i in range(10):
ws.append([i])
# drawing a graph
values = Reference(ws, min_col=1, min_row=1, max_col=1, max_row=10)
# chart = LineChart()
chart = BarChart()
ws.add_chart(chart, "A15")
chart.title = "Chart"
chart.y_axis.title = 'Size'
chart.x_axis.title = 'Test Number'
chart.add_data(values)
s1 = chart.series[0]
s1.marker.symbol = "triangle"
wb.save("Chart-1.xlsx")
但我在使用 LibreOffice Calc 打开它时遇到问题:
如果使用 Gnumeric 打开它看起来会更好:
如何使 .xlsx 文件与 LibreOffice Calc 更兼容?