REGR: close corrupt files in ExcelFile
State: closed

- [x] closes #41778
- [x] tests added / passed
- [x] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing.html#code-standards) for how to run them
- [x] whatsnew entry

@simonjayhawkins maybe for 1.2.5?

Labels:
name: Regression
description: Functionality that used to work in a prior pandas version
name: IO Excel
description: read_excel, to_excel

Comments:
lgtm. ping when ready.


@twoertwein some tests are failing, if you fix-up and remove the draft status so can be merged when green. 


(I think this is the last PR for 1.2.5, we have a few outstanding issues but no PRs to fix. https://github.com/pandas-dev/pandas/milestone/85  @jreback )
The remaining tests fail because `inspect_format` (in `xlrd`) uses `if content:` but content is `b""` (empty file). It should probably check `if content is not None` and check the length of the content.

I think we can avoid this bug by writing random data to the file.
@simonjayhawkins @jreback green
@meeseeksdev backport 1.2.x
thanks @twoertwein 
Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

1. Checkout backport branch and update it.

```
$ git checkout 1.2.x
$ git pull
```

2. Cherry pick the first parent branch of the this PR on top of the older branch:
```
$ git cherry-pick -m1 2973e4eb8a659172f4aa28dc1b9f0067a677f60d
```

3. You will likely have some merge/cherry-pick conflict here, fix them and commit:

```
$ git commit -am 'Backport PR #41806: REGR: close corrupt files in ExcelFile'
```

4. Push to a named branch :

```
git push YOURFORK 1.2.x:auto-backport-of-pr-41806-on-1.2.x
```

5. Create a PR against branch 1.2.x, I would have named this PR:

> "Backport PR #41806 on branch 1.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to [suggest an improvement](https://github.com/MeeseeksBox/MeeseeksDev).
                
Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

1. Checkout backport branch and update it.

```
$ git checkout 1.2.x
$ git pull
```

2. Cherry pick the first parent branch of the this PR on top of the older branch:
```
$ git cherry-pick -m1 2973e4eb8a659172f4aa28dc1b9f0067a677f60d
```

3. You will likely have some merge/cherry-pick conflict here, fix them and commit:

```
$ git commit -am 'Backport PR #41806: REGR: close corrupt files in ExcelFile'
```

4. Push to a named branch :

```
git push YOURFORK 1.2.x:auto-backport-of-pr-41806-on-1.2.x
```

5. Create a PR against branch 1.2.x, I would have named this PR:

> "Backport PR #41806 on branch 1.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to [suggest an improvement](https://github.com/MeeseeksBox/MeeseeksDev).
                
looks like needs manual backport