Hello,
We have a workbook and are trying to copy one named range and setting the Value for the cells in it to override the formulas. On one of those cells the Index out of bound exception is thrown.
Sample Code:
var tempWorkbook = new Workbook(“error.xlsx”);
Range range = tempWorkbook.Worksheets.GetRangeByName(“ABC”);
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Range destinationRange = worksheet.Cells.CreateRange(0, 0, range.RowCount, range.ColumnCount);
destinationRange.CopyData(range);
destinationRange.Copy(range, new PasteOptions {SkipBlanks = false, PasteType = PasteType.All});
destinationRange.CopyStyle(range);
for (int i = 0; i < destinationRange.RowCount; i++)
{
for (int j = 0; j < destinationRange.ColumnCount; j++)
{
Cell cell = worksheet.Cells[i, j];
if (!cell.IsFormula)
continue;
object cellValue = cell.Value;
cell.PutValue(cellValue);
}
}
The workbook is attached
Best regards,
Stefan Botan,
IBM Romania