Jump to content

InetGet() gets a corrupt Excel file


Herb191
 Share

Recommended Posts

How do you know it is corrupt?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Have you tried flag $INET_FORCERELOAD?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Have you tried flag $INET_FORCERELOAD?

Sorry for the late response of have been sick the last couple of days.

Yes I have tried $INET_FORCERELOAD.

The exact message I get from Excel is:

The file format and extension of ‘list.xls’ don’t match. The file could be corrupted or unsafe. Unless you trust its source, don’t open it. Do you want to open it anyway?

When I open the file its is not readable.

When I download the file manually the extension is a .xls.

Link to comment
Share on other sites

When I manually download the file, Firefox thinks it downloaded a 223KB file. However, when you examine the actual file it is 992KB. It looks like the file being downloaded with InetGet is compressed. I was able to open it with 7Zip and extract the same 992KB file from within.

 

Hummm very interesting. I was also able to read it once I unzipped it. I guess I will have to use InetGet() to get the file and then have AutoIt unzip it. Thanks Danp2.

Link to comment
Share on other sites

So upon further research I found that the issue was that the file was being downloaded in gzip format. I thought I would post my code for anyone that ran into a similar problem. This code uses the zLib UDF found >here.

#include "ZLIB.au3"

$sFilePath = @ScriptDir & "\list.xls"
$sURL = "https://alachua.lienexpress.net/certificates/list.xls?q=%7B%7D%0A"
InetGet_GZ($sURL, $sFilePath)

Func InetGet_GZ($sDownloadURL, $sFileName)
    $Data = InetRead($sDownloadURL)
    $Data = BinaryToString(_ZLIB_GZUncompress($Data), 1)
    If FileExists($sFileName) Then FileDelete($sFileName)
    FileWrite($sFileName, $Data)
EndFunc   ;==>InetGet_GZ
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...