Save crashes with after DeleteRange in some cases

This is a weird problem.


Run the code below on the attached XLSX-file. I receive “Specified argument was out of the range of valid values” at workbook.Save(…). I am using Aspose.Cells 6.0.1.8.

Any ideas?

Forgot the code…


public static void DoIt()
{
WorkbookDesigner designer = new WorkbookDesigner();
Workbook workbook = new Workbook(Constants.sourcePath + “DeleteRange.xlsx”);
designer.Workbook = workbook;

Range range = workbook.Worksheets.GetRangeByName(“DUP_Project”);
Worksheet worksheet = range.Worksheet;

Cells cells = range.Worksheet.Cells;

cells.DeleteRange(range.FirstRow, range.FirstColumn, range.FirstRow + range.RowCount-1, range.FirstColumn + range.ColumnCount-1, ShiftType.Left);

string output = Constants.destPath + “DeleteRange_result.xlsx”;
workbook.Save(output);
Process.Start(output);
}

Hi,

Thanks for reporting and considering Aspose.Cells for .NET.

I was able to replicate the problem using the latest version:
Aspose.Cells for .NET v7.0.1.5


We have logged this issue in our database. Once the issue is fixed or we get some update, we will let you know asap.

This issue has been logged as CELLSNET-31068.

Below is the code and exception for a reference.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\DeleteRange.xlsx”;


WorkbookDesigner designer = new WorkbookDesigner();

Workbook workbook = new Workbook(filePath);

designer.Workbook = workbook;


Range range = workbook.Worksheets.GetRangeByName(“DUP_Project”);

Worksheet worksheet = range.Worksheet;


Cells cells = range.Worksheet.Cells;


cells.DeleteRange(range.FirstRow, range.FirstColumn, range.FirstRow + range.RowCount - 1, range.FirstColumn + range.ColumnCount - 1, ShiftType.Left);



workbook.Save(filePath + “.out.xlsx”);




Exception
System.ArgumentOutOfRangeException was unhandled
Message="Specified argument was out of the range of valid values."
Source="Aspose.Cells"
StackTrace:
at Aspose.Cells.Workbook.Save(String fileName, SaveOptions saveOptions)
at Aspose.Cells.Workbook.Save(String fileName)
at AsposeProject.Program.f1() in F:\Shak-Data-RW\Projects\AsposeProject\AsposeProject\Program.cs:line 91
at AsposeProject.Program.Main(String[] args) in F:\Shak-Data-RW\Projects\AsposeProject\AsposeProject\Program.cs:line 57
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Hi,

We have fixed this issue. Please download: Aspose.Cells for .NET v7.0.1.6

This does fix the problem with ShiftCellsLeft.


However, it seems to have introduced another bug (it workes with version 7.0.0.0). The problem is that I cannot reproduce it in a simple program, and I can’t send our entire solution as a repro.

I will try to find a small repro, but perhaps you have a clue what could be the problem.

What we are doing is that we have a dataset with multiple data-tables. For some of these tables, we do a e.g. SetDataSource(“DataTable1”, tbl.DefaultView) and SetDataSource(“DataTable2”, tbl.DefaultView).
We then use smart-markers, like &=DataTable1.Id and &=DataTable2.Id in the designer document.

However, with 7.0.1.6, only the first datasource seems to work. In the example above, only &=DataTable1.Id will be replaced with the Id-values. &=DataTable2.Id will remain.

When I try to repro this in a smaller program, it works, so there must be something else that we do with Aspose that keeps this from working. Perhaps you have an idea?

/Fredrik

Ok, I did find a repro.

For the code below, if you run it on “SmartMarkers.xlsx”, it works fine (both “Investment” and “Remaining” are accessible through smart-markers.

However, if you run the code on “SmartMarkers2.xlsx”, only the first datasource will be accessible (try this by commenting out one of the “SetDataSource” lines.

Please advice.

Thanks!
/Fredrik

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aspose.Cells;
using System.Data;
using System.Diagnostics;
using System.Collections;

namespace Infoweaver.Forms.AsposeTest
{
class SmartMarkers
{
public static void DoIt()
{
WorkbookDesigner designer = new WorkbookDesigner();
Workbook workbook = new Workbook(Constants.sourcePath + “SmartMarkers2.xlsx”);
designer.Workbook = workbook;

DataTable dt1 = CreateValidTable1();
DataTable dt2 = CreateValidTable2();

designer.SetDataSource(“Investment”, dt1.DefaultView);
designer.SetDataSource(“Remaining”, dt2.DefaultView);

designer.Process(true);

string output = Constants.destPath + “SmartMarkers_result.xlsx”;
workbook.Save(output);
Process.Start(output);
}

private static DataTable CreateValidTable1()
{
DataTable dt = new DataTable(“Table 1”);
dt.Columns.Add(“Id”, typeof(string));
dt.Rows.Add(“Id number 1”);
return dt;
}

private static DataTable CreateValidTable2()
{
DataTable dt = new DataTable(“Table 2”);
dt.Columns.Add(“Id”, typeof(string));
dt.Rows.Add(“Id number 2”);
return dt;
}

}
}

Hi,


Thanks for the sample code and template files.

I am able to reproduce this new Smart markers issue now. I have re-opened your issue and we will fix it soon.

Thank you.

Hi,

We have fixed this issue. Please download: Aspose.Cells for .NET v7.0.1.7

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.