Quantcast
Viewing all articles
Browse latest Browse all 1621

Commented Issue: Hyperlink issue with ShiftRows [11569]

I have created a hyperlink cell and set the "cell.Hyperlink = link;" property. After doing this I am using ShiftRows() in order to eliminate blank rows in our code. When I do that, I see that the cell text/style etc are being copied, but the cell.hyperlink property is still in the original cell and is not being moved to the destination cell.

Is there any other function that can be used to delete rows/ copy rows so that the hyperlink property is copied as well?
Comments: ** Comment from web user: meerashan **

Hi,

I have resolved the issue by making changes to the HSSFSheet ShiftRows() method source code. The issue was that the hyperlink was being set after the row was removed and interchanging this logic fixed the issue

List<ICell> cells = row.Cells;
foreach (ICell cell in cells)
{
NPOI.SS.UserModel.IHyperlink link = cell.Hyperlink;
if (link != null)
{
link.FirstRow = (link.FirstRow + n);
link.LastRow = (link.LastRow + n);
}

row.RemoveCell(cell);
CellValueRecordInterface cellRecord = ((HSSFCell)cell).CellValueRecord;
cellRecord.Row = (rowNum + n);
row2Replace.CreateCellFromRecord(cellRecord);
_sheet.AddValueRecord(rowNum + n, cellRecord);
}


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>