3

I'm currently updating values in an Excel template and I keep getting my currency fields to have the green triangle in the top corner and the "Number Stored as Text" message. How do I get Excel to recognize the cell is a number and I want it to treat it that way since I already have the cell formatted as currency? (just like what happens if I'm on the cell in Excel, hit F2, and then hit enter)

Here's a simplified version of what I'm currently doing:

UInt32Value moneyFormat = report.createCellFormat(report.Stylesheet, fontIndex, backgroundIndex, borderIndex, 168);
report.UpdateValue("Workbook", "I29", "1234.56", moneyFormat, true, String.Empty);

And here's an image of what my cells look like s

Miles
  • 5,646
  • 18
  • 62
  • 86
  • 2
    Not a direct solution, but you should look into the [ClosedXML](https://closedxml.codeplex.com/) library. It's much easier than trying to dive into the hell that is the OpenXML API. – Polynomial Mar 10 '14 at 15:14
  • OpenXML isn't that bad if you use the, "Open XML SDK 2.0 Productivity Tool for Microsoft Office" (free software by Microsoft). You can customize the spreadsheet in Excel for example, then use the tool to show you the created code to use. – eaglei22 Sep 11 '17 at 16:20

1 Answers1

2

You might find the answer in this post:

Open XML SDK 2.0 - how to update a cell in a spreadsheet?

Probably the DataType of the cell is not set correct.

Community
  • 1
  • 1
RFerwerda
  • 1,267
  • 2
  • 10
  • 24