I'm using ExcelDataReader to read .xls files and extract data. However, I cannot open .xls files which I got from external device due to Invalid file signature exception (I can open it with Excel, but it gives me a pop up that file format and extension don't match and if I want to open it anyway).
FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read); IExcelDataReader excelReader = ExcelReaderFactory.CreateReader(stream);I have tried to open it using Interop, however, got ***.xls file cannot be accessed. The file may be corrupted, located on a server that is not responding, or read-only exception.
Missing missing = Missing.Value; Application excel = new Application(); Workbook workbook = excel.Workbooks.Open(filePath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, XlCorruptLoad.xlRepairFile);Is there any way to repair/restore/open/read those corrupted files?
p.s. Open manually with Excel and do SaveAs is not an option as I would need to do it for hundred of files.
Symptom:
When opening a damaged or corrupt Excel XLS or XLSX file with Microsoft Excel, you see the following error message:
‘filename.xls’ cannot be accessed. The file may be read-only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding.
where ‘filename.xls’ is the corrupt Excel file name.
Below is a sample screenshot of the error message:
Precise Explanation:
When an Excel XLS or XLSX file is corrupt and Microsoft Excel cannot recognize it, the Excel may report this error. The error information is misleading since it says the file cannot be accessed because it is read-only. However, even the actual file is NOT read-only, if it is corrupt, Excel will still report this error by mistake.
Solution:
You can first check if the file is read-only, on a read only location, or on a remote server. If the file is on a read only location or on a remote server, then try to copy the file from the read-only location or server to a writable drive on the local computer. The make sure you remove the read-only attribute of the Excel file.
If the Excel file still cannot be opened, then we can confirm the file is corrupt. You can first use Excel built-in repair function to repair the corrupt Excel file. If that does not work, then only DataNumen Excel Repair can help you.
Sample File:
Sample corrupt XLS file that will cause the error. Error5.xls
The file recovered by DataNumen Excel Repair: Error5_fixed.xls
References:
- //support.microsoft.com/en-gb/office/repair-a-corrupted-workbook-153a45f4-6cab-44b1-93ca-801ddcd4ea53
The file may be corrupted, located on a server that is not responding, or read-only. Excel data recovery.
You receive error messages when you try to open an Office document:
“The file may be corrupted, located on a server
that is not responding, or read-only”
www.duomenu-atkurimas.lt data recovery center can help You recover Excel, Word data in a few hours (1-3 h).
Excel error message before recovery
After recovery in our center
Our data recovery center can help You recover corrupted MS Excel, Word data.
Excel file recovery price only 49$. You pay only for result after full recovery!
JSC ALFATEL
p/d 2829, Gedimino ave. 7, LT-01103 Vilnius, Lithuania
Our e-mail:
Phone: +370 604 65631
Web.: www.duomenu-atkurimas.lt