Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Exception while reading a cell with datatype number and cell is empty.

$
0
0
Thanks MDeLeon for ur reply.

The exception issue is solved, but Arithmetic operations are not working when i try to reference those cells.

In the generated execl, Cell A3 is supposed to be 300, but it is showing 0 in-spite there are values under A1 and A2.
var locationValue1 = 100;
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue1  == 0 ? string.Empty : locationValue1.ToString());
worksheetProposal.Cell(cellindex ).Style.NumberFormat.NumberFormatId = 2;

var locationValue2 = 200;
cellindex = "A2";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue2  == 0 ? string.Empty : locationValue2.ToString());
worksheetProposal.Cell(cellindex ).Style.NumberFormat.NumberFormatId = 2;

cellindex = "A3";
var formula = "SUM(A1:A2)";
worksheetProposal.Cell(cellindex ).SetFormulaA1(formula);
See the attachment for the excel sheet.

https://www.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=closedxml&WorkItemId=9373&FileAttachmentId=919314

Viewing all articles
Browse latest Browse all 1877

Trending Articles