Hi team.
I receive the following error when opening a workbook: Index was outside of bounds of the array. Therefore, I cannot open this Excel file. I am using Aspose.Cells for .net version 4.5.0.0. That’s the license purchased by my client. I have this simple code to open the workbook from my Excel file, which includes 2 sheets:
public int UpdateAssetDataWithTemplateFile(string TemplateFileName, int userId)
{
{
if (File.Exists(TemplateFileName))
{
Workbook wb = new Workbook();
try
{
wb.Open(TemplateFileName);
}
catch (Exception ex)
{
LogBO log = new LogBO(this.GetType());
log.Error(ex.Message + "\r\n - " + ex.StackTrace);
return -1;
}Worksheet ws = null; if (wb.Worksheets == null || wb.Worksheets.Count < 1) return 0; int result = 0;
//code goes here for the worksheets…
return result;
}
Here is the StackTrace:
System.IndexOutOfRangeException
HResult=0x80131508
Message=Index was outside the bounds of the array.
Source=Aspose.Cells
StackTrace:
at Aspose.Cells.OpenXML.x7661ca2b53df3da9.xbd93b3b4862f01e7(XmlTextReader xb9763b0038341e6c)
at Aspose.Cells.OpenXML.x7661ca2b53df3da9.x06b0e25aa6ad68a9(XmlTextReader xb9763b0038341e6c)
at Aspose.Cells.OpenXML.x9d49ab444acbddce.x72bde2882aefe5af(x1f5f0dd7560ed867 xd9171314ec0b2957, String x7d11dcd405070662)
at Aspose.Cells.OpenXML.x9d49ab444acbddce.xc3266f78bb6c4216(x1f5f0dd7560ed867 xd9171314ec0b2957, String x7d11dcd405070662)
at Aspose.Cells.OpenXML.x9d49ab444acbddce.x88ae89d546ee9fdf()
at Aspose.Cells.OpenXML.xe95a61e48a6637a3.x2e7f798eabefe5b4(Workbook xce16031e3118b903, Stream xcf18e5243f8d5fd3)
at Aspose.Cells.Workbook.Open(String fileName)
at GISAP.AssetFramework.BO.Asset.AssetBOV2.UpdateAssetDataWithTemplateFile(String TemplateFileName, Int32 userId) in C:\Users\panayota.panayotou\source\repos\IPG-CorpIT-Global\IPGITHK_Asset_and_Benchmark_Backend\Source\AssetFramework_API\GISAP.AssetFramework\BO\Asset\AssetBOV2.cs:line 22
This exception was originally thrown at this call stack:
[External Code] GISAP.AssetFramework.BO.Asset.AssetBOV2.UpdateAssetDataWithTemplateFile(string, int) in AssetBOV2.cs
I attach the Excel file I am using to open. I can’t find what’s causing this error. I am thinking that the file is maybe corrupted. This file has been created from another function we have in the application we are using. I can also attach the code for this file creation.
AssetListReport_AL505_373.zip (8.6 KB)