Validations getting copied to cells with similar settings

Hi,

Following code is copying validations to all the cells with similar settings.

Eg, in the code below; I am over-riding validation to "Test Content" at cell "E8" only, and at design time we have validations added till E27 with content as "Design Time Validation".

Unfortunately the validations are getting overridden in all the cells. Is there anything missing in the code?

I have attached template and output workbooks.

Page-Load

Workbook workbook = new Workbook();

workbook.Open(@"C:\Users\vdwivedi\Desktop\Archives\Book1.xls", FileFormatType.Excel97To2003);

this.AddValidation(sheet, "Test Test", "Test Content", sheet.Cells["E8"]);

workbook.Save(@"C:\Users\vdwivedi\Desktop\Archives\Book2.xls");

//Methods

private void AddValidation(Worksheet localSheet, String hText, String content, Cell dCell)

{

try

{

Validation ValCell = GetCurrentValidation(localSheet, dCell.Name);

if (ValCell == null) { ValCell = localSheet.Validations[localSheet.Validations.Add()]; }

ValCell.InputTitle = hText;

ValCell.InputMessage = content;

ValCell.ShowInput = true;

CellArea area;

area.StartColumn = dCell.Column;

area.EndColumn = dCell.Column;

area.StartRow = dCell.Row;

area.EndRow = dCell.Row;

ValCell.AreaList.Add(area);

}

catch { throw; }

}

private Validation GetCurrentValidation(Worksheet localSheet, String cellID)

{

Validation v = null;

Cell dCell = localSheet.Cells[cellID];

try

{

for (int i = 0; i < localSheet.Validations.Count; i++)

{

Validation localVal = localSheet.Validations[i];

for (int j = 0; j < localVal.AreaList.Count; j++)

{

CellArea ca = (CellArea)localVal.AreaList[j];

if (dCell.Row >= ca.StartRow && dCell.Row <= ca.EndRow

&& dCell.Column >= ca.StartColumn && dCell.Column <= ca.EndColumn)

{

v = localVal;

localVal = null;

break;

}

}

}

}

catch { throw; }

return v;

}

Regards, Vinay

Hi,

Apparently, I can find the issue using your code with your template file.

But we need to further investigate it, we will soon look into it and get back to you soon.

I have logged it into our issue tracking system with an id: CELLSNET-17065.

Thank you.

Hi,

<span style=“font-size: 11pt; font-family: “Arial”,“sans-serif”;”>Please
use the following sample code with the attached version to add or modify the validations in a cell:<o:p></o:p>

int row, column;

CellsHelper.CellNameToIndex("E8", out row, out column);

Validation v = workbook.Worksheets[0].Validations.GetValidationInCell(row, column);

v.InputTitle = "Test Test";

v.InputMessage = "Test Content";

v.ShowInput = true;

<span style=“font-family: “Calibri”,“sans-serif”;”> workbook.Worksheets[0].Validations.Add(v);


Thank you.

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


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

While trying to keep the API as straightforward and clear as possible, we have decided to recognize and honor the common development practices of the platform; we have re-arranged API Structure/ Namespaces.

With this release, we have reorganized the API classes for Aspose.Cells component. This change has some major aspects that we follow. We have added new namespaces. The entire API (classes, interfaces, enumerations, structures etc.) were previously located in the Aspose.Cells namespace. Now, certain sets of API have been moved to their relative namespaces, which make the relationship of classes (with their members) and namespaces clear and simplified. It is to be noted here, we have not renamed existing API (classes, enumerations etc.) but, I am afraid you still need to make certain adjustments in your existing projects accordingly.

For complete reference, please see the product's API Reference.