0

I've written some code that runs a number of simulations (a few dozen), and for each run of the sim it builds an openpyxl worksheet with the result data. I'm having trouble figuring out an effective mechanism to put each of these worksheets back together into a single workbook.

I found Copy whole worksheet with openpyxl -- which is disheartening as it led me down a road to probably not being able to "just copy a worksheet as an object into a new workbook".

Are there other mechanisms that might work here? Is it even legal (sensible?) to pass just a worksheet object around from one function to another, or is this totally barking up the wrong tree?

I suppose I could instead create a whole separate workbook in each simulation run, and then collect all those workbooks, and then for each one do a brute-force copy of the data in each worksheet over to a new worksheet in the main workbook... but that just SEEMS like the wrong way to approach it. Is there something more elegant that I haven't considered?

ljwobker
  • 832
  • 2
  • 10
  • 20
  • You can't just move worksheets from one workbook to another because they depend upon workbook-specific information. – Charlie Clark Dec 06 '19 at 09:12
  • Suggestions on how to speed this up? Is there anyway to efficiently multithread the creation of a couple hundred worksheets? The code generating the raw data is threaded but collating it all at the end in a single thread is pretty slow. – ljwobker Dec 10 '19 at 23:30

0 Answers0