fill a template and save it, some style missing.

Issue #1169 closed
created an issue

I want to open a xlsx file as template and fill it with values, then save as a result file, but some style missing. the temp file: temp.png the result file: rst.png

  1. the cell's width and height is changed
  2. the merged cell 's border's style is changed, just the left-top cell has border.
  3. How can I got the cell's width, height then reshape the image fit. the column_dimensions/row_dimensions return None.
  4. I can add image to a cell coordinate, if there are some way to insert it with offset (margin) or give a (x,y) anchor?

at last I want to insert a image from numpy (not from file), so I use a BytesIO as buffer, which works in v 2.5.3, but not work in the latest version. what is the right usage?

Comments (8)

  1. yxdragon reporter

    Thanks for update about the border! I want to write a engine to fill a template(with mark in cell) with a parameter dictionary, auto detect location, and trans numpy to picture, pandas to table, auto loop the dataframe, (It is great if we can trans the result to a PDF doc, but I did not find a pure python solution)

    now I am troubled in these problem.

    1. the merged cell's border (waiting the update)
    2. a method to got a merged cell's size is needed
    3. add offset para in add_image (sometimes we want to lay a image in the center of a merged cell),

    4. can you give a demo to show add image from memory? (not from file)

    I try to got the merged_cell's range, and sum the column_dimensions's width and row_dimension's height, but I got None. I had set the col width in ms office, but I can not got it in openpyxl.

  2. yxdragon reporter

    Hi, I will try the mailing list, But I am sure it is bug or new feature, I do not think it could be solved without openpyxl's update. should I split these and give 3 issues?

    Indeed I has read the code, Image save the path in the ref, read to get the width and height, then close it. when save the workbook, reload the image from ref, So if it is a BytesIO buffer, will cause a error (I can set a new opened buffer to ref from out, but I think it is not elegant)

    and the image offset, I think it is a useful feature. I had solve it from out, But I wish openpyxl add this in future.

  3. CharlieC

    Separate issues should indeed have separate reports, but questions should be directed to the mailing list. At the moment it's not clear what are bug reports, feature requests, or questions.

    Also, there is no team behind openpyxl. It is an open source project and features will only be added if people are prepared to do the work themselves or sponsor someone else to do it.

  4. Log in to comment