4

Using Winnovative's excel library I am able to parse an excel file (xls) that contains a hyperlink. It works when the program is run directly on my machine. The exact same file will fail if I try to upload it to a website and parse it. Here is an example of the logic:

// Works when bytes are parsed from a program running locally.
// Fails when bytes are parsed from a file uploaded to a website
public void TestRead(byte[] bytes)
{
    try
    {
        // Parse excel file
        var workBook = new ExcelWorkbook(new MemoryStream(bytes));

        // Save file
        var toSave = workBook.Save();
        System.IO.File.WriteAllBytes(@"C:\Users\[User]\Downloads\Test.xls", toSave);
    }
    catch (Exception e)
    {
    }
}

This is only an issue with xls files. I don't have trouble parsing a xlsx file with a hyperlink. The uploaded file fails to parse with an exception (which also crashes the application even though it is enclosed in a try-catch block):

Could not open the workbook.Arithmetic operation resulted in an overflow.

at Winnovative.ExcelLib.ExcelWorkbook..ctor(Stream excelStream, String openPassword, ExcelWorkbookDefaultSettings defaultSettings) at Winnovative.ExcelLib.ExcelWorkbook..ctor(Stream excelStream)

and

System.OverflowException was unhandled Message: An unhandled exception of type 'System.OverflowException' occurred in wnvxls.dll Additional information: Arithmetic operation resulted in an overflow.

Hans Vonn
  • 3,949
  • 3
  • 21
  • 15

0 Answers0