Quantcast
Viewing all articles
Browse latest Browse all 1877

Created Unassigned: Extra empty cells added when inserting comment [9434]

When adding a comment to a cell extra empty cells are added in the excel sheet which are not touched by the code.

With the following code:
```
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Test");

var cell = worksheet.Cell(1, 1);
cell.Comment.AddText("test comment");

using (var ms = File.Open("Test.xlsx", FileMode.CreateNew))
{
workbook.SaveAs(ms);
}
```

You can find these cells in the Excel application by using the 'Find & Select' option, select 'Go To Special' and select 'Blanks' and press OK (see screenshot).

I think it is strange because these cells are not actually touched, but they are updated when writing the excel data. Normally it is not a problem, but our client complaints about it because they are using it to import data with a script which cannot handle the extra blanks in the sheet.

The problem lies in the surrounding cells which are requested from the XLCellsCollection object. When the comments are added the GenerateShape method is called which calls the GetAnchor method. This method requests the surrounding cells to determine the anchor which updates the the MaxColumnUsed and MaxRowUsed properties of the collection. These properties are updated, but are not actually used.

I want to fix this problem, but I do not know what this anchor means or does. When I remove the anchor from the ClientData on the Shape which is generated it results in the exact same output and the comments are displayed ok.

Can someone help me fixing this problem?

Thnx, Erwin


Viewing all articles
Browse latest Browse all 1877

Trending Articles



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