社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
import openpyxl
from openpyxl.styles import Font
from openpyxl.utils import get_column_letter
wb=openpyxl.Workbook()
sheet=wb.active
fontGoal1=Font(name='Microsoft YaHei',bold='True')
print('Please type the number of formula:')
i=int(input())
#sheet['B1':get_column_letter(i+1)+str(1)].font=fontGoal1
for rowOfUtilGoal in sheet['B1':get_column_letter(i+1)+str(1)]: #加粗每列乘数字体
for UtilGoal in rowOfUtilGoal:
UtilGoal.font=fontGoal1
#sheet['A2':A+str(i+1)].font=fontGoal1
for rowOfUtilGoal in sheet['A2':'A'+str(i+1)]: #加粗每行乘数的字体
for UtilGoal in rowOfUtilGoal:
UtilGoal.font=fontGoal1
#for rowOfGoal in sheet['B1:get_column_letter(i+1)+str(1)']:
#rowOfGoal.value=
for row in range(2,i+2): #赋值给乘法口诀表的行
sheet[get_column_letter(row)+str(1)].value=row-1
for row in range(2,i+2): #赋值给乘法口诀表的列
sheet['A'+str(row)].value=row-1
for rowOfUtilGoal in sheet['B2':get_column_letter(i+1)+str(i+1)]: #赋值乘法公式
for UtilGoal in rowOfUtilGoal:
#UtilGoal.value='='+get_column_letter(UtilGoal.row)+str(UtilGoal.column-(UtilGoal.column-1))+'*'+get_column_letter(UtilGoal.row-1)+str(UtilGoal.column)
UtilGoal.value='='+'A'+str(UtilGoal.row)+'*'+get_column_letter(UtilGoal.column)+str(1)
wb.save('multiplication.xlsx')
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!