Skip to content
Advertisement

Is it possible to merge cells with an openpyxl write-only worksheet?

I am creating worksheets with about 100,000 rows and openpyxl’s writing operation is quite slow. It would be useful to get a row object and to fill it in, but I can’t find an API for that. The documentation on optimization mentions write-only mode. My problem with this mode is that it doesn’t obviously support merged cells, because merging cells seems to be an operation that is done on a spreadsheet, not on a row that is appended.

JavaScript
JavaScript

Is there any way to support merging cells? Failing that, what’s a faster way to write cells than to get each cell with ws.cell() and manually set it?

Advertisement

Answer

Messing around with the merged_cells attribute of the worksheet worked for me. Here is an example:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement