How can I GZip compress a file from Excel VBA using code in an .xla file only?

前端 未结 5 1318
情深已故
情深已故 2021-01-06 08:32

I need to be able to GZip compress a file in an Excel VBA function. Specifically I need to be able to use the \'deflate\' algorithm.

Is there a way to do this withou

5条回答
  •  渐次进展
    2021-01-06 09:09

    If somebody wanted to compress files without relying on 3rd-party software they would generally implement it as a COM object/DLL so it would be available to more than just Excel. If somebody wanted to incorporate zip functionality into Excel they would use 3rd-party tools so they wouldn't have to re-implement the algorithm. So you're swimming against the tide. However...

    http://www.cpearson.com/excel/SaveCopyAndZip.htm

    There are two versions. The COM Add-in version "...allows you to zip any workbook that has been saved to disk (but it may be in an unsaved state)." It relies on a Moonlight Software component but all the components and set-up are contained in the installer. It's not quite public domain but the license is less restrictive than the GPL. The end result is an Excel add-in (that uses a 3rd-party component).

    But if you really, truly don't want any dependencies on external tools you're either going to have to implement the compression algorithm yourself or wait until Microsoft builds that functionality into Windows and exposes it through Excel.

    I hope this helps.

提交回复
热议问题