Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...