NanoXLSX icon indicating copy to clipboard operation
NanoXLSX copied to clipboard

Set cell value

Open Ryba1986 opened this issue 3 years ago • 3 comments
trafficstars

How can i set the value of a cell retrieved with the Worksheet.GetCell metod? I try set Value property but not work

Ryba1986 avatar Sep 22 '22 09:09 Ryba1986

Hi, A cell object is currently more or less a read-only object. I assume you want to adjust data from a loaded workbook. As a workaround, you can do the following:

  • Get the cell "cell1"
  • Get the address of the cell
  • Add a new cell in in your worksheet with the new value and the address of "cell1". This will override the old cell worksheet.AddCell(newValue, cell1.CellAddress);

It is probably an enhancement if the value can be set directly.

rabanti-github avatar Sep 22 '22 11:09 rabanti-github

I think is a good option. Before that the Value property of Cell object should by read only.

Ryba1986 avatar Sep 22 '22 11:09 Ryba1986

Hi, Cell values can now be set by the Value property of the cell. This was possible earlier too, but a type check was missing. This was added now. The fix was released with v2.0.2. The NuGet package should be available in a few minutes

rabanti-github avatar Sep 29 '22 20:09 rabanti-github

I will close this issue for now. Please do not hesitate to re-open or file a new one, if further problems occur. Thank you for the report.

rabanti-github avatar Nov 09 '22 21:11 rabanti-github