Answer the question
In order to leave comments, you need to log in
OpenXML SDK: how to get formatted cell value?
How can I get the formatted (with number format applied) cell value from an XLSX file? In other words, such a value, as Excel itself would show it?
I understand that there is no ready-made such function and most likely it is necessary to act in two stages - get the format string and format the value using it.
Well, using this piece of code, you can get a CellFormat object that will contain NumberFormatId:
CellFormat cellFormat =<br/>
(CellFormat) document.WorkbookPart.WorkbookStylesPart.Stylesheet.CellFormats.ElementAt(cell.StyleIndex);
Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();<br/>
<br/>
value = excelApp.WorksheetFunction.Text(value, currentNumberingFormat.FormatCode.Value);<br/>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question