Free Support Forum - aspose.com

Getting workbook from inputstream is slow

Hi

Iam trying to get a workbook from a input stream but it takes about 2 minutes to get the workbook.

Iam using version 8.4.1. It works fine locally and on some IIS Servers, however on production it takes 2 minutes.

Code is below

            Workbook workbook = null;
var request = HttpContext.Current.Request;
// Check that we have a file
var loadOptions = new TxtLoadOptions(LoadFormat.Auto) { ConvertDateTimeData = false, ConvertNumericData = false };
if (request.Files.Count>0 && request.Files[0].ContentLength > 0)
{
workbook = new Workbook(request.Files[0].InputStream, loadOptions);
}

Hi,

Thanks for providing us some details.

I suspect it is not an issue with the product, it might be due to Request.Files property in your code segment. Could you try to evaluate Request.Files attribute by using .NET System.IO or FileStream API to open the file without involving Aspose.Cells APIs to check if you find different behavior and it takes less time.

Also, please try our latest version/ fix: Aspose.Cells for .NET (Latest Version) if it makes any difference. If you still find the issue with v8.5.2.2, kindly do create a sample web project (runnable), zip it and post us here to reproduce the issue on our end, we will check it soon. Also provide your template Excel file, this will help us to evaluate your issue precisely to consequently figure it out soon.

Thank you.

Thanks for getting back to me. I have tried it with the latest version and it still appears to take a long time to use the Workbook constructor.

I have tried reading the file from a path and passing the bytes to a memory stream and it still takes a long time. I cant replicate this on certain IIS servers but only on production. Any ideas?

Hi,

Did you try using System.IO or FileStream APIs without using Aspose.Cells APIs to read the file on your production server to check if you still find the performance issue. Although I am not entirely certain but I think your issue might be due to the IIS on your production server or due to your network, so you should debug your environment or browse internet to try to fix it, a few helping links (document) may assist you:
https://support.microsoft.com/en-us/kb/2560289
http://forums.iis.net/t/1175052.aspx?IIS+express+requests+take+4+times+longer+to+execute
etc.

Thank you.

What does new Workbook use? Memory in IIS or temp files? This still takes a long time writing file locally and getting the file on production server

Hi,

Well, surely Aspose.Cells.Workbook uses some memory (the memory amount depends upon the file’s size or contents in the file). By the way if you read the file in a simple console application, how it goes? If it reads the file instantly and efficiently, you should understand that it could be IIS or network issue.

If you still think it is an issue with the product, kindly create a sample runnable project in VS.NET, zip it and post us here to reproduce the issue, we will check it soon. Also attach your template Excel file which you are reading.

Thank you.

Hi

I just tried using the System.IO to retrieve the file into memorystream and that appears to be ok. The issue is writing memorystream to the workbook. How is the workbook constructed?

Hi,


Well, Aspose.Cells uses System.IO namepsapce to read Excel file(s) on the back end.
Could you simply try to read the file from its path or do the job via streams instead of your request.Files attribute:
e.g
Sample code:

1)
Workbook workbook = new Workbook(strfilePath);

Or
2)
FileStream stream = File.OpenRead(strFilePath);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
Workbook workbook = null;
using (MemoryStream templateStream = new MemoryStream(buffer))
{
workbook = new Workbook(templateStream); // Fetch template
}



Thank you.

Hi

I have tried both of the above

     Stopwatch sw = Stopwatch.StartNew();
var test = new Workbook(@“C:\WebSites\UK_Magazines_2014_Formatted - Antony Test.xlsx”);
Logger.Info(String.Format(“Time taken to test file: {0} ms”, sw.ElapsedMilliseconds));
var workbookTemplate = new Workbook(new MemoryStream(template.Content));
var workbookSupplier = new Workbook(new MemoryStream(supplierFile.Content));
        <span style="color:white;">sw</span><span style="color:#b4b4b4;">.</span><span style="color:white;">Stop</span>();</pre><br>The time taken to load the test file is 209882 ms.  It appears only to happen on the workbook construction on the server.  Is there something that needs to be addressed in IIS?<br>

Works fine on IIS 7.5 but very slow on IIS 8.0

Hi,


So, it looks to me an issue with IIS 8.0 on your side. You may keep using IIS 7.5 in your environment.

Thank you.