Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

python - Problem streaming Excel file with images, Flask, Gcloud Storage, Openpyxl, doesn't saves file with all the images

if anybody can help me, please.

I am trying to work with an excel (xlsx) file that has images. The file is in a Gcloud storage Bucket that is downloaded from the main.py (flask) and is send to a python function in another file (createReport.py) the file is read, change and all functions well, but when I save it, the file doesn′t include the images from the template file.

This is han example of the code:

@app.route('/', methods= ['GET', 'POST'])
def root():
  wb = io.BytesIO()
  blob = bucket.blob(pathReportfile)
  blob.download_to_file(wb)

  wb = create(wb)

  blob = bucket.blob(path)
  blob.upload_from_string(wb.getvalue())
  wb.close

  return render_template('index.html')

def create(wb):
  wbReport = openpyxl.load_workbook(wb, read_only=False)
  .
  #makes changes to the file only data
  .
  wb = io.BytesIO()
  wbInforme.save(wb)
  wbInforme.close

  return wb
  

The file is downloaded directly from the public storage bucket "-https:www.google.com/...excelprojects..."

The image in the left is the template and the image on the right is the downloaded file: enter image description here

Thanks


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...