GridDesktop : misformatted Excel xml file cause infinte loop

Hello,


If an Excel file is misforatted (add a “” field in the file without closing tag) cause infinite loop in the importer:

called function :
// import the spreadsheetML and populate the grid
gridDesktop1.ImportExcelFile(xmlSSFilename);

Any trick or patch to avoid this behaviour ?

Hi Richard,


Thank you for contacting Aspose support.

Please share the malformed spreadsheet for our testing. Once we have been able to replicate the said issue, we will be in a better position to assist you with it.

See the attached file.


Best Regards.

Hi Richard,


Thank you for sharing the sample for our testing. I have evaluated the presented scenario while using the latest version of Aspose.Cells.GridDesktop 9.0.0, and I’m able to notice the said problem, that is; application hangs for indefinite time while loading the provided sample. I have raised this problem with the product team under the ticket CELLSNET-44753. Please spare us little time to further analyze the scenario and get back with updates in this regard.

Hi,


Thanks for the template file.

Well, your attached file is corrupt and MS Excel cannot load it. Do you need to throw same exception “The file is corrupt and cannot be opened.” by Aspose.Cells.GridDesktop (and it should not go into infinite loop) as per MS Excel? After your confirmation, we may log comments to your ticket accordingly.

Thank you.
I use this code as a Workarround, maybe you should use it or improve by using an open source XML/Excel validator :

public bool TryParse(string s)
{
try
{
//RegistryKey key = Registry.ClassesRoot;
//RegistryKey excelKey = key.OpenSubKey("Excel.Application");
//bool excelInstalled = excelKey == null ? false : true;

if (xlApp == null)
xlApp = new Microsoft.Office.Interop.Excel.Application();
System.Object UpdateLinks,
ReadOnly = false,
Format,
Password,
WriteResPassword,
IgnoreReadOnlyRecommended,
Origin,
Delimiter,
Editable,
Notify,
Converter,
AddToMru,
Local,
CorruptLoad = XlCorruptLoad.xlRepairFile;

object misval = System.Reflection.Missing.Value;
if (xlApp == null)
{
MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " EXCEL could not be started. Check that your office installation and project references are correct.");
return true;
}
//xlApp.ShowStartupDialog = false;
xlApp.Visible = false;
//xlApp.ShowWindowsInTaskbar = true;

if (btest) MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " xlApp.Workbooks.Open->");
wb = xlApp.Workbooks.Open(s, misval, ReadOnly,
misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, misval, CorruptLoad);
if (btest) MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " xlApp.Workbooks.Open<-");

if (wb == null)
{
MessageBox.Show("XCL file is invalid.");
if (btest) MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " wb == null");

xlApp.Quit();
return false;
}
wb.Close(false, null, null);
xlApp.Quit();
wb = null;
/*XmlDocument result = new XmlDocument();
result.Validate(validationEventHandler);*/
return true;
}
catch (System.AccessViolationException ex)
{
if (btest) MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " FileNotFoundException : " + ex.ToString());
MessageBox.Show("Check file : EXCEL could not be started. Check that your office installation and project references are correct.");
}

catch (COMException ex)
{
MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " XML file misformatted : try to repair...");
return false;
}
catch (FileNotFoundException ex)
{
MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " FileNotFoundException : " + ex.ToString());
}
catch (XmlException ex)
{
MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " XML file misformatted : " + ex.ToString());
}
catch (System.ApplicationException aex)
{
MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " XML file misformatted : " + aex.ToString());
}
finally
{
if(xlApp != null) xlApp.Quit();
if (btest) MessageBox.Show(System.Reflection.MethodBase.GetCurrentMethod().Name + " finally");
}
return true;
}

Hi again,


Thank you for the suggestion. I have forwarded your comments to the concerned member of the product team for reference. As soon as we get any news in this regard, we will post here.
Hi,

This is to inform you that we have fixed your issue "CELLSNET-44753" now. We will soon provide the fix after performing QA and including other enhancements and fixes.

Thank you.

The issues you have found earlier (filed as CELLSNET-44753) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.