This is a migrated thread and some comments may be shown as answers.
Getting ArgumentOutOfRange exception when opening a workbook hosted on a server
1 Answer 6 Views
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 2
Ivan asked on 18 Dec 2020, 10:21 PM

Hello!
Faced an incomprehensible problem.
When trying to open a workbook, an exception is thrown:
ArgumentOutOfRangeException: Index and count must refer to a location within the string. (Parameter 'count')
At the same time, everything works fine on the working computer during development, there is no exception.
The problem pops up when placing a project on a hosting.

The library from Syncfusion in a similar environment opens the file normally on the hosting.

Library version 2020.3.1019
.net5 Server-side project

private void LoadFile()
        {
            try
            {
                string path = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), "Templates", $"temp.xlsx");
                using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
 
                XlsxFormatProvider formatProvider = new XlsxFormatProvider();
 
                // Getting exception there while hosted
                using Workbook workbook = formatProvider.Import(stream);
            }
            catch (Exception error)
            {
                NotificationReference.Show(new NotificationModel()
                {
                    Text = $"{error.GetType().Name}: {error.Message}",
                    ThemeColor = "primary"
                });
            }
        }

1 Answer, 1 is accepted

Sort by
0
Peshito
Telerik team
answered on 21 Dec 2020, 01:22 PM

Hi Ivan, 

I tried reproducing the issue but to no avail. Could you provide a sample runnable project reproducing it? As this is a forum thread you could either use a third-party website for file-sharing or submit a support ticket.

I used the sample code from our documentation for downloading a file from a server and importing it into the workbook - Download and import xlsx file. Everything worked fine and the file was successfully imported.

Regards,
Peshito
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Ivan
Top achievements
Rank 2
Answers by
Peshito
Telerik team
Share this question
or