How to ignore warning messages when opening xls file

For few xls files generated from other sources, we are getting the below error when opening the file through Aspose.Cells.

“The file you are trying to open is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?”

When opening the file manually through MS Excel, we can ignore this error by clicking OK but when opening through Aspose.Cells, it’s throwing exception.

Please advice how to ignore this warning error message when opening xls files.

Note: We are using Aspose.Total.NET

Hi,

As the error (by both Aspose.Cells and MS Excel) suggests that the file has different extension, so its extension is not valid. So, this seems not an issue with Aspose.Cells APIs. Could you attach the template XLS file here, we will check it soon.

Thank you.

This error doesnt mean the extension is invalid all the times. It may be incompatible with source file generation mechanism.

But if you see MS Excel allows to open the file after ignoring the warning message (by clicking Yes or No) whereas Aspose.Cells dont have that option.

Attached the sample file for your reference.
Sample_file_open_error.zip (5.3 KB)

Hi,

Thanks for the template file.

I have tested your scenario/ case using our latest version/fix: Aspose.Cells for .NET v17.6.x (please download and try it from Downloads module), it works fine and I do not get any exception whatsoever. I am using the following sample code:
e.g
Sample code:

var workbook = new Workbook(“e:\test2\Sample_file_open_error.xls”);
workbook.Save(“e:\test2\out1.xls”);

The output file is fine tuned too and MS Excel does not give any exception when opening the file into it. By the way, your so called XLS file is actually a web page, you may try to open it into Notepad for confirmation.

Thank you.

Thanks for reverting quickly. We will check in the latest version and let you know.

Hi Amjad,

Aplogies for the delay. I have just tried with another sample xls file and able to simulate the error using the Aspose.Cells for .NET v17.6.x.

Attached the xls file and error screenshot for your reference.

SAMPLE_XLS_ISSUE.zip (59.9 KB)

Please note, we can able to open this xls file in MS WORD by ignoring the prompted warning message but whereas we dont have that option when opening using Aspose.Cells.

Request you to check and advice.

Regrads,
Senthil

@Senthil_B,

Thanks for the sample file and screenshot.

Well, your so called XLS file is actually a corrupted MHtml file which does not conform to MS Excel standards (of MHtml), the file has invalid characters in Base-64 strings. That is the reason and I am afraid, Aspose.Cells cannot parse your corrupted file. If it is an MHtml file, it should follow valid file format’s specifications. You may simply open the file into notepad and check this is not a regular Mhtml file. Aspose.Cells APIs would take it as “Unknown” file format. You may confirm this by using the following sample code:
e.g
Sample code:

 string fileName = "e:\\test2\\SAMPLE_XLS_ISSUE.xls";
            var o = FileFormatUtil.DetectFileFormat(fileName);
            Console.WriteLine(o.LoadFormat.ToString());

I think to make our APIs clean, I am afraid, we may not parse such a file with corrupted records/data in it. If you could resave your corrupted file into MS Excel manually (after forcefully opening into it) then it will become a valid MHTML file. Now you may use Aspose.Cells APIs to open/save the file.

Thank you.

@Amjad_Sahi

This file is being generated by external program and we are not supposed to change anything on this.

if you try to open this file in MS Word, it prompts with the warning message and it opens the file actually. I understand Aspose will support all the operations that is available in MS Word.

When we can open the file in MS Word, can he have some options to open the file using Aspose? or is there any other workaround to process this file using Aspose?

Since its getting failed in Aspose, we are unable to perform validations in our application which is causing some issues.

Request your support on this.

Thanks,
Senthil

@Senthil_B,

I have logged an investigation ticket with an id “CELLSNET-45478” for your issue as you are still persisting on evaluating your issue. Our concerned developer from product team will evaluate your issue soon. We do not promise that we will fix it (we have already provided details why we cannot parse such a file) but we can give it a try if we could do something for it to cope with it.

Once we have an update on it, we will let you know here.

By the way, Aspose.Cells follows MS Excel standards not MS Word standards.

Thank you.

@Amjad_Sahi

Thanks for considering the request. Since this file is being generated from external sources, we are unable to process it further in .our NET application using Aspose.Cells. Your team support on this will be greatly appreciated.

Yeah, it’s a typo error, i was also referring to MS EXCEL only.

@Senthil_B

Your issue has already been logged as CELLSNET-45478 in our database. Do you still have any question or comment? We will look into it and update you asap. Thank you and have a good day.

@Senthil_B,

We have a good news for you. We are working over your issue (logged earlier as “CELLSNET-45478”) and the ETA is July 12, 2017. We will try our level best to abide by this ETA. We might provide you the fix even before this deadline.

Keep in touch.

Thank you.

@Senthil_B,

Please try our latest version/fix: Aspose.Cells for .NET v17.6.5:

Please use the following code to test it:
e.g
Sample code:

LoadOptions ldps = new LoadOptions(LoadFormat.MHtml);
var workbook = new Workbook(filePath + "SAMPLE_XLS_ISSUE.xls, ldps);
workbook.Worksheets[0].AutoFitColumns();
workbook.Save(filePath + "out_issue.xlsx");

Your issue should be fixed in it.

Let us know your feedback.

Thank you.

@Amjad_Sahi,

Great to hear this from you. I’m glad Aspose responded so quickly and provided the solution so fast. Much appreciated.

Team is testing the scenario. I will revert you soon.

Thanks for your support.

@Senthil_B,

Sure, take your time to test the new fix/version. In case of any query, comments or issue feel free to contact us. We will try to help you soon.

Thank you.

@Amjad_Sahi

Is it possible to download Aspose.Cells for .NET v17.6.5 from Aspose download page? We are not having access to download the file from dropbox.com.

I tried the latest dll from download page but it looks like old version and we are getting error when loading with mhtml option.

Regards,
Senthil

@Senthil_B,

No, this is not possible as v17.6.5 is a hot fix which is released against some enhancements and other fixes in the forums. However our next official release, i.e., Aspose.Cells for .NET v17.7 (which will be published in the third/fourth week of July, 2007) will also include the functionality of the fix. We will notify you here once we publish our next official release of the product. So, either you may wait for our next official release or confirm us if we could upload to some other drive service (e.g Google drive, etc.) for you. Alternatively, we can send you the fix via email separately (you may confirm your email here).

Thank you.

@Amjad_Sahi

Sorry, we dont have access for google drives too. I have messaged you my email address. Request you to please share the Aspose.Cells.dll v17.6.5 from net4.0 folder alone to that email id.

Thanks for your support.

Regards,
Senthil

@Senthil_B,

The latest fix/version (Aspose.Cells for .NET v17.6.6) was sent @ your mentioned email id.

Thanks,

The issues you have found earlier (filed as CELLSNET-45478) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi