Images overwrite when using Copy-ExcelWorkSheet
This is a re-open of a previous issue (https://github.com/dfinke/ImportExcel/issues/513), asking if other users have managed to overcome it differently?
We're using ImportExcel to (amongst other things) stick together reports rendered to xlsx from SQL Server Reporting Services. When downloading to Excel, SSRS renders all graphs with the same internal image filename (first graph will always be image1.jpeg or png). That means we start with 3 spreadsheets, and each has one graph with internal name image1. The EPPlus backend to ImportExcel has a known bug, the result is that when adding the tabs together, the graph image in the base (first) spreadsheet is duplicated to the other tabs (and skewed to fit); the graphs in the other tabs are completely lost.
Our fix was a PowerShell script, attached as a .txt. You pass it parameter folder name; it then:
- iterates through all xlsx files in the folder
- extracts the xlsx content to folder (we know that none have a password so it's easy)
- updates each image file name to something unique, not just for that workbook but in all workbooks in the folder being worked
- updates the image file name in drawings relationships
- recompresses the xlsx
It works but is a touch messy. Has anyone else come up with a different fix for this?