dfinke / ImportExcel

PowerShell module to import/export Excel spreadsheets, without Excel
https://www.powershellgallery.com/packages/ImportExcel/
Apache License 2.0
2.47k stars 400 forks source link

Import-Excel error: Exception calling "Load" with "1" argument(s): " Bad signature (0x0000041D) #1329

Closed loicyannou closed 1 year ago

loicyannou commented 1 year ago

Hello I'm using this module (7.8.3) to import data of XLSX files. For a couple of days, I'm meeting this error:

Exception calling "Load" with "1" argument(s): "  Bad signature (0x0000041D) at position  0x0000017C"
At C:\Program Files\WindowsPowerShell\Modules\ImportExcel\7.8.3\Public\Import-Excel.ps1:125 char:24
+                 else { $ExcelPackage.Load($stream) }

When it happens, I have to open the XLSX file with Excel and save it. Then, import-excel command runs with no error. It's like if the file was corrupted (or not using the right format). Yet, Excel is able to open it. I contacted the company providing those XLSX files to know whether it recently changed the export process, because my script is still able to open XLSX files created before november the 28th. Also, I compared the files created 11/27 (working) and 11/28 (not working) and I can't see no difference (data is exactly the same). Any idea, please ? Best

dfinke commented 1 year ago

Can you open a simple xlsx you create with Excel to get a sanity check that the module is not working?

Maybe re-install? Install an older version of ImportExcel to see if that causes the same issue?

loicyannou commented 1 year ago

Hello The company providing those XLSX files confirmed that they changed the way those XLSX files are built:

Indeed we made some updates to our reports infrastructure on that date that might have effected the PS module you are using. The main change was updating our Java libraries and mitigating some security issue. So it is logical that other, non excel, modules might were effected. As such files should be open in Excel, there is nothing much we can do about external modules that are not Excel. Best

thkn-hofa commented 1 year ago

Maybe this would be fixed with a newer EPPlus DLL but I think there's a reason why @dfinke is on the second to last version under LGPL. Maybe a license issue because the new license is non-commercial or because version 5 introduced a breaking change that makes row and column numbers zero-based in stead of one-based.

Dropping in the newer DLL probably isn't an easy option to test it out.

dfinke commented 1 year ago

@thkn-hofa yes. A number of the unit tests fail amongst other things. It could open a whole new set of problems, and they moved onto a completely new offering, requiring a paid license.

dfinke commented 1 year ago

no, there has been no resolution.

prodtech22 commented 1 year ago

I am having the same issue with files created by PeopleSoft 8.58 - this was working fine before the upgrade. If I open and save the file and then use again import-excel on the new saved file, it works.

dfinke commented 1 year ago

@prodtech22 The upgrade was on the PeopleSoft side?

prodtech22 commented 1 year ago

Yes. One thing I just discovered, and just tested it, is that by removing the signature on the file and saving it, the conversion works.

prodtech22 commented 1 year ago

So now I have to figure out how to script removing the signature so I can automate it

dfinke commented 1 year ago

Not familiar with that, "signature". They sign the xlsx?

prodtech22 commented 1 year ago

It's the 'author', the user who created the file

prodtech22 commented 1 year ago

[cid:940bcedd-4b63-4371-b1fd-06d538215521]


From: Doug Finke @.> Sent: Tuesday, February 28, 2023 5:21 PM To: dfinke/ImportExcel @.> Cc: Lumi Mihalcea @.>; Mention @.> Subject: Re: [dfinke/ImportExcel] Import-Excel error: Exception calling "Load" with "1" argument(s): " Bad signature (0x0000041D) (Issue #1329)

Not familiar with that, "signature". They sign the xlsx?

— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdfinke%2FImportExcel%2Fissues%2F1329%23issuecomment-1449077608&data=05%7C01%7Cmihalcea%40uwm.edu%7Ca54da08435f04f0829f408db19e2918b%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132233159048072%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sP9LLikg4DHFI%2FF5ygMwkSBw%2BbognVcBXoyqDjI4s50%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARBWT734J7F5UCYNFGPEL2TWZ2CA3ANCNFSM6AAAAAASUF4GJM&data=05%7C01%7Cmihalcea%40uwm.edu%7Ca54da08435f04f0829f408db19e2918b%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132233159048072%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hg3GcOwJn9FHmW60BqO9zZuR2dmeKPZbermZG82msGs%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

prodtech22 commented 1 year ago

If I remove that, import-excel works. Well, until now I tested it by manually removing the signature and saving the file. I hope it still works works if I figure out how to do via script. [cid:a753a782-8b8e-4bcb-91d0-aaf3ff5c4c67]


From: Doug Finke @.> Sent: Tuesday, February 28, 2023 5:21 PM To: dfinke/ImportExcel @.> Cc: Lumi Mihalcea @.>; Mention @.> Subject: Re: [dfinke/ImportExcel] Import-Excel error: Exception calling "Load" with "1" argument(s): " Bad signature (0x0000041D) (Issue #1329)

Not familiar with that, "signature". They sign the xlsx?

— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdfinke%2FImportExcel%2Fissues%2F1329%23issuecomment-1449077608&data=05%7C01%7Cmihalcea%40uwm.edu%7Ca54da08435f04f0829f408db19e2918b%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132233159048072%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sP9LLikg4DHFI%2FF5ygMwkSBw%2BbognVcBXoyqDjI4s50%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARBWT734J7F5UCYNFGPEL2TWZ2CA3ANCNFSM6AAAAAASUF4GJM&data=05%7C01%7Cmihalcea%40uwm.edu%7Ca54da08435f04f0829f408db19e2918b%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132233159048072%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hg3GcOwJn9FHmW60BqO9zZuR2dmeKPZbermZG82msGs%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

dfinke commented 1 year ago

Nothing in the module accesses "author". Not sure if can be done. Please post if you find a way.

prodtech22 commented 1 year ago

I will, thank you!


From: Doug Finke @.> Sent: Tuesday, February 28, 2023 5:57 PM To: dfinke/ImportExcel @.> Cc: Lumi Mihalcea @.>; Mention @.> Subject: Re: [dfinke/ImportExcel] Import-Excel error: Exception calling "Load" with "1" argument(s): " Bad signature (0x0000041D) (Issue #1329)

Nothing in the module accesses "author". Not sure if can be done. Please post if you find a way.

— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdfinke%2FImportExcel%2Fissues%2F1329%23issuecomment-1449104196&data=05%7C01%7Cmihalcea%40uwm.edu%7C382ec92537834f32c61b08db19e788a2%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132254442877965%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bOSaKy%2BPMvKsX%2BGCkdjr%2FGqoseWLd9LFevNchhV5mTQ%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARBWT7ZG5NYASRWQB6AMI6TWZ2GGDANCNFSM6AAAAAASUF4GJM&data=05%7C01%7Cmihalcea%40uwm.edu%7C382ec92537834f32c61b08db19e788a2%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132254442877965%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=M4h617cnZnvaZLoW3ROWU3GLVZPsf99QxXqbuKbreww%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

prodtech22 commented 1 year ago

We discovered an encoding issue on the Excel files coming from Peoplesoft after upgrade. We were looking at 2 different solutions - open and save the file OR remove the 'author' from the file (in this case Apache POI); they both work but they require Excel installed on the server and we were not willing to do that. My co-worker tried a different approach that seems to work - created a .bat file running 7zip, which runs ahead of the import-excel in the PowerShell script, that will decompress and recompress the file then run the normal import-excel module.


From: Doug Finke @.> Sent: Tuesday, February 28, 2023 5:57 PM To: dfinke/ImportExcel @.> Cc: Lumi Mihalcea @.>; Mention @.> Subject: Re: [dfinke/ImportExcel] Import-Excel error: Exception calling "Load" with "1" argument(s): " Bad signature (0x0000041D) (Issue #1329)

Nothing in the module accesses "author". Not sure if can be done. Please post if you find a way.

— Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdfinke%2FImportExcel%2Fissues%2F1329%23issuecomment-1449104196&data=05%7C01%7Cmihalcea%40uwm.edu%7C382ec92537834f32c61b08db19e788a2%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132254442877965%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bOSaKy%2BPMvKsX%2BGCkdjr%2FGqoseWLd9LFevNchhV5mTQ%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FARBWT7ZG5NYASRWQB6AMI6TWZ2GGDANCNFSM6AAAAAASUF4GJM&data=05%7C01%7Cmihalcea%40uwm.edu%7C382ec92537834f32c61b08db19e788a2%7C0bca7ac3fcb64efd89eb6de97603cf21%7C0%7C0%7C638132254442877965%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=M4h617cnZnvaZLoW3ROWU3GLVZPsf99QxXqbuKbreww%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

dfinke commented 1 year ago

FWIW there is:

https://github.com/dfinke/ImportExcel/blob/24e5fccafe774bf14444728492813711e4a889f0/Private/Invoke-ExcelReZipFile.ps1#L1

Plus there is a -ReZip switch on Export-Excel

But, bat FTW!

dfinke commented 1 year ago

@tamahau30494 do you know what the fix would be?