根据某一图片,用EXCEL做出来!!
from openpyxl import Workbook
from openpyxl.utils import get_column_letter
from openpyxl.styles import PatternFill,Color
from PIL import Image ##调用库,包含图像类
workbook=Workbook()
worksheet=workbook.active
im=Image.open("D:/0python/excel/tupian.jpg") #文件存在的路径,如果没有路径就是当前目录下文件,如要显示用 im.show() 保存 im.save('a.png')
im_width=im.size[0]
im_height=im.size[1]
pix=im.load()
for row in range(1,im_height):
for col in range(1,im_width):
cell=worksheet.cell(column=col,row=row)
pixpoint=pix[col-1,row-1]
pixColor="FF%02X%02x%02x" % (pixpoint[0],pixpoint[1],pixpoint[2])
fill=PatternFill(patternType="solid",fgColor=Color(rgb=pixColor)) #填充颜色 RGB
cell.fill=fill
worksheet.row_dimensions[row].height=6 #单元格高度
for col in range(1,im_width):
worksheet.column_dimensions[get_column_letter(col)].width=1 #单元格列宽
workbook.save(filename="d:/0python/excel/图像.xlsx")