0

I'm using Python 3.6, xlwings 0.11.4 and Excel 2016 on Windows 10. I'd like to load and save a copy of a workbook with data computed by formulas, not the formulas. E.g. if test.xlsx contained =1+1 in cell A1, copy.xlsx should contain 2 in cell A1.

import xlwings
wb = xlwings.Book('test.xlsx')
wb.save('copy.xlsx')  # Something like break_links or data_only=True?

I can do this with openpyxl using data_only, but unfortunately openpyxl does not support image loading which is a requirement in my current project.

I know it's possible to manually read and set every computed value, but I'm looking for a built-in / quick way to 'break formula links' automatically on save. Thanks

Aralox
  • 1,441
  • 1
  • 24
  • 44
  • You can use `Pandas` with `openpyxl` to convert `xlxs` to `csv` and back to `xlsx`, and it only take seconds. Let me know and I can post some sample code for you to try. – ian0411 Oct 09 '17 at 13:17
  • I don't know of anything built in, but the first method contained in the VBA *question* you linked to looks fine to me. Can't you just use the xlwings equivalent of that? (For that matter, I agree with the people who don't understand why the asker of that question isn't happy with that method. That they are already using. Successfully.) – John Y Oct 09 '17 at 21:40
  • @ian0411 `csv` wouldn't preserve my images, which I need. @John I'm pretty new to xlwings, and I cant find a `paste` with a quick search in the API docs. Do you know how to implement this? Btw, I want to avoid using `win32com` to call `pasteSpecial` for now, to avoid the loss of cross-platform code gained with xlwings – Aralox Oct 10 '17 at 01:22

0 Answers0