I have a web app in C#. And am using an xlsx template to create documents. The formatting of xlsx is fairly involved and hence I chose the template route instead of creating from scratch. In a cell x2, most data coming in as a percent, but in some cases it would be an amount. But I cannot seem to change the format of that cell when it is amount to percent. The template was saved with percent format in that cell. The code to set the cell value is as below and works for other cells, which were saved with currency format. I tried to set the cell style index to 103U based on that code in another cell with the same format.
How do I change the format of the cell x2? ANy help would be greatly appreciated. Thanks in advance.`
public void setCellValueNum(WorksheetPart ws, int row, int col, Double newVal)
{
Cell cl = getCell(ws.Worksheet, getColLetter(col), row);
cl.CellValue = new CellValue(newVal.ToString());
cl.CellReference = getColLetter(col) + row.ToString();
cl.DataType =
new EnumValue<CellValues>(CellValues.Number);
//cl.StyleIndex = (UInt32Value)103U;
}